/* ══════════════════════════════════════════
   CHATBOT WIDGET  — chatbot.css
   Shared across all pages via _chatbot.html
   ══════════════════════════════════════════ */

/* ── Bubble ── */
#chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.2s ease,
                background 0.2s ease;
}

#chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}

#chat-bubble:focus-visible {
    outline: 3px solid #00d2ff;
    outline-offset: 3px;
}

body.dark-mode #chat-bubble {
    background: #00bcd4;
    color: #000;
    box-shadow: 0 4px 20px rgba(0,210,255,0.35);
}

body.dark-mode #chat-bubble:hover {
    background: #00d2ff;
}

#chat-bubble svg { display: block; width: 22px; height: 22px; }

/* ── Panel ── */
#chat-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 360px;
    max-height: 520px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    z-index: 9001;
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    border: 1px solid rgba(0,0,0,0.07);
}

#chat-panel[hidden] { display: none !important; }

body.dark-mode #chat-panel {
    background: #16213e;
    border-color: rgba(0,210,255,0.2);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,210,255,0.15);
}

/* ── Header ── */
#chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #111;
    color: #fff;
    border-radius: 18px 18px 0 0;
    flex-shrink: 0;
}

body.dark-mode #chat-header {
    background: linear-gradient(135deg, #0d1b2a, #1a2744);
    border-bottom: 1px solid rgba(0,210,255,0.2);
}

#chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00bcd4, #0077ff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

#chat-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

#chat-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    opacity: 0.75;
    margin-top: 2px;
}

#chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4caf50;
    flex-shrink: 0;
    transition: background 0.3s;
}

#chat-status-dot.busy {
    background: #ffb300;
    animation: chat-pulse 1s ease-in-out infinite;
}

@keyframes chat-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

#chat-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.2s, background 0.2s;
}

#chat-close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
#chat-close-btn:focus-visible { outline: 2px solid #00d2ff; outline-offset: 2px; }

/* ── Messages ── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }
body.dark-mode #chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.chat-msg-wrap {
    display: flex;
    margin-bottom: 6px;
}

.chat-wrap-user { justify-content: flex-end; }
.chat-wrap-bot  { justify-content: flex-start; }

.chat-msg {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}

.chat-user {
    background: #111;
    color: #fff;
    border-bottom-right-radius: 4px;
}

body.dark-mode .chat-user {
    background: #00bcd4;
    color: #000;
}

.chat-bot {
    background: #f3f4f6;
    color: #111;
    border-bottom-left-radius: 4px;
}

body.dark-mode .chat-bot {
    background: rgba(255,255,255,0.07);
    color: #e2e8f0;
}

/* ── Typing indicator ── */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 11px 14px;
}

.chat-typing span {
    display: block;
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: chat-bounce 1.2s ease-in-out infinite;
}

body.dark-mode .chat-typing span { background: rgba(0,210,255,0.5); }

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%            { transform: translateY(-6px); }
}

/* ── Input row ── */
#chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(0,0,0,0.07);
    background: #fff;
    flex-shrink: 0;
}

body.dark-mode #chat-input-row {
    background: #0d1b2a;
    border-top-color: rgba(0,210,255,0.12);
}

#chat-input {
    flex: 1;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 20px;
    padding: 8px 14px;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    outline: none;
    background: #f9fafb;
    color: #111;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#chat-input:focus {
    border-color: #111;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

#chat-input:disabled { opacity: 0.5; cursor: not-allowed; }

body.dark-mode #chat-input {
    background: rgba(255,255,255,0.06);
    border-color: rgba(0,210,255,0.2);
    color: #e2e8f0;
}

body.dark-mode #chat-input:focus {
    border-color: #00d2ff;
    box-shadow: 0 0 0 3px rgba(0,210,255,0.12);
}

#chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

#chat-send-btn:hover   { background: #333; transform: scale(1.08); }
#chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#chat-send-btn:focus-visible { outline: 2px solid #00d2ff; outline-offset: 2px; }

body.dark-mode #chat-send-btn { background: #00bcd4; color: #000; }
body.dark-mode #chat-send-btn:hover { background: #00d2ff; }

/* ── Mobile ── */
@media only screen and (max-width: 480px) {
    #chat-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        max-height: 70vh;
        border-radius: 14px;
    }

    #chat-bubble { bottom: 16px; right: 16px; }
}
