/**
 * ContentDB Support Chat Widget
 * Author: Damiano Parenti
 * Copyright © 2026 Damiano Parenti - All Rights Reserved
 */

.cdb-support-launcher {
    position: fixed;
    left: 24px;
    bottom: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    background: linear-gradient(135deg, #00d4ff 0%, #0099ff 50%, #0066ff 100%);
    box-shadow: 0 8px 24px rgba(0, 153, 255, 0.45), 0 0 0 0 rgba(0, 212, 255, 0.6);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    animation: cdbPulse 2.6s ease-in-out infinite;
}

.cdb-support-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 34px rgba(0, 153, 255, 0.6);
}

.cdb-support-launcher:active {
    transform: scale(0.96);
}

.cdb-support-launcher .cdb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #ff3366;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px rgba(10, 10, 10, 0.6);
}

@keyframes cdbPulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(0, 153, 255, 0.45), 0 0 0 0 rgba(0, 212, 255, 0.45); }
    50% { box-shadow: 0 8px 24px rgba(0, 153, 255, 0.55), 0 0 0 12px rgba(0, 212, 255, 0); }
}

.cdb-support-panel {
    position: fixed;
    left: 24px;
    bottom: 100px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: linear-gradient(180deg, rgba(18, 24, 38, 0.98) 0%, rgba(8, 10, 18, 0.99) 100%);
    border: 1px solid rgba(0, 212, 255, 0.25);
    border-radius: 20px;
    z-index: 10110;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 212, 255, 0.05);
    color: #fff;
    font-family: 'Outfit', 'Inter', sans-serif;
    transform-origin: bottom left;
}

.cdb-support-panel.cdb-open {
    display: flex;
    animation: cdbPanelIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cdbPanelIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.cdb-support-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.16), rgba(0, 102, 255, 0.10));
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.cdb-support-header .cdb-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #0066ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 14px rgba(0, 212, 255, 0.5);
}

.cdb-support-header .cdb-head-info {
    flex: 1;
    min-width: 0;
}

.cdb-support-header .cdb-title {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
}

.cdb-support-header .cdb-status {
    font-size: 0.78rem;
    color: #9fb3c8;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.cdb-support-header .cdb-status .cdb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
    flex-shrink: 0;
}

.cdb-support-header .cdb-status.cdb-waiting .cdb-dot { background: #ffaa00; box-shadow: 0 0 8px #ffaa00; }
.cdb-support-header .cdb-status.cdb-closed .cdb-dot { background: #888; box-shadow: none; }

.cdb-head-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cdb-btn-op {
    border: 1px solid rgba(0, 212, 255, 0.5);
    background: rgba(0, 212, 255, 0.12);
    color: #00d4ff;
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cdb-btn-op:hover { background: rgba(0, 212, 255, 0.25); color: #fff; }
.cdb-btn-op:disabled { opacity: 0.5; cursor: default; }

.cdb-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: #cfe0ee;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.cdb-icon-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.cdb-icon-btn.cdb-end:hover { background: rgba(255, 51, 102, 0.25); color: #ff8aa3; }

.cdb-support-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.cdb-support-body::-webkit-scrollbar { width: 6px; }
.cdb-support-body::-webkit-scrollbar-thumb { background: rgba(0, 212, 255, 0.4); border-radius: 3px; }

.cdb-msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: cdbMsgIn 0.25s ease both;
}

@keyframes cdbMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.cdb-msg .cdb-msg-name {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 3px;
    opacity: 0.85;
}

.cdb-msg.cdb-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #00a8cc, #0066ff);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cdb-msg.cdb-ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(0, 212, 255, 0.18);
    border-bottom-left-radius: 4px;
}

.cdb-msg.cdb-ai .cdb-msg-name { color: #00d4ff; }

.cdb-msg.cdb-operator {
    align-self: flex-start;
    background: rgba(0, 255, 136, 0.10);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-bottom-left-radius: 4px;
}

.cdb-msg.cdb-operator .cdb-msg-name { color: #00ff88; }

.cdb-msg.cdb-system {
    align-self: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: #b9c6d4;
    font-size: 0.8rem;
    text-align: center;
    max-width: 95%;
}

.cdb-typing {
    align-self: flex-start;
    display: none;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 14px;
}

.cdb-typing.cdb-show { display: flex; }
.cdb-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #00d4ff; opacity: 0.6;
    animation: cdbTyping 1.1s infinite ease-in-out;
}
.cdb-typing span:nth-child(2) { animation-delay: 0.18s; }
.cdb-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes cdbTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.cdb-support-footer {
    padding: 12px;
    border-top: 1px solid rgba(0, 212, 255, 0.18);
    background: rgba(0, 0, 0, 0.25);
}

.cdb-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.cdb-input {
    flex: 1;
    resize: none;
    max-height: 110px;
    min-height: 44px;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid rgba(0, 212, 255, 0.25);
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.cdb-input:focus { border-color: #00d4ff; }
.cdb-input::placeholder { color: #7e8ea0; }

.cdb-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #00d4ff, #0066ff);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 153, 255, 0.4);
}

.cdb-send:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 153, 255, 0.6); }
.cdb-send:disabled { opacity: 0.5; cursor: default; transform: none; }

.cdb-footer-note {
    text-align: center;
    font-size: 0.7rem;
    color: #6f8095;
    margin-top: 8px;
}

.cdb-closed-banner {
    margin: 8px 0 0;
    text-align: center;
}

.cdb-restart {
    border: 1px solid rgba(0, 212, 255, 0.5);
    background: rgba(0, 212, 255, 0.12);
    color: #00d4ff;
    border-radius: 10px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
}

.cdb-restart:hover { background: rgba(0, 212, 255, 0.25); color: #fff; }

@media (max-width: 480px) {
    .cdb-support-panel {
        left: 8px;
        right: 8px;
        bottom: 90px;
        width: auto;
        height: calc(100vh - 120px);
    }
    .cdb-support-launcher { left: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .cdb-support-launcher { animation: none; }
    .cdb-support-panel.cdb-open { animation: none; }
    .cdb-msg { animation: none; }
}
