/* ===== CHAT WIDGET ===== */
#chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Toggle Button */
#chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

#chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(59, 130, 246, 0.65);
}

#chat-toggle-btn svg {
    width: 26px;
    height: 26px;
    fill: white;
    transition: opacity 0.2s ease;
}

/* Unread badge */
#chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    font-size: 10px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    display: none;
}

/* Chat Box */
#chat-box {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-height: 520px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform-origin: bottom right;
}

#chat-box.hidden {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    pointer-events: none;
}

#chat-box.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Header */
#chat-header {
    background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chat-avatar svg {
    width: 22px;
    height: 22px;
    fill: white;
}

#chat-header-title {
    color: white;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}

#chat-header-status {
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
}

#chat-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#chat-close-btn svg {
    width: 14px;
    height: 14px;
    stroke: white;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
}

/* Messages area */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
    min-height: 220px;
    max-height: 320px;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Messages */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: msgSlide 0.2s ease;
}

@keyframes msgSlide {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-msg-avatar svg {
    width: 15px;
    height: 15px;
    fill: white;
}

.chat-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.chat-msg.bot .chat-msg-bubble {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.chat-msg.user .chat-msg-bubble {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-bubble a {
    color: #3b82f6;
    text-decoration: underline;
}

.chat-msg.user .chat-msg-bubble a {
    color: #bfdbfe;
}

/* Typing indicator */
#chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    display: none;
}

#chat-typing .typing-dots {
    background: white;
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    gap: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

#chat-typing .typing-dots span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

#chat-typing .typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

#chat-typing .typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }
}

/* Suggestions */
#chat-suggestions {
    padding: 8px 14px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.chat-chip {
    background: white;
    border: 1px solid #cbd5e1;
    color: #374151;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 11.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    font-weight: 500;
}

.chat-chip:hover {
    background: #1d4ed8;
    color: white;
    border-color: #1d4ed8;
}

/* Input area */
#chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: center;
    background: white;
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 22px;
    padding: 9px 15px;
    font-size: 13px;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: #3b82f6;
    background: white;
}

#chat-input::placeholder {
    color: #94a3b8;
}

#chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}

#chat-send-btn:hover {
    transform: scale(1.08);
}

#chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#chat-send-btn svg {
    width: 17px;
    height: 17px;
    fill: white;
}

/* === MOBILE === */
@media (max-width: 480px) {
    #chat-widget-container {
        bottom: 16px;
        right: 16px;
    }

    #chat-box {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
    }
}