/* ═══════════════════════════════════════════════
   LORE MASTER CHATBOT — Venetian Dark Theme
   ═══════════════════════════════════════════════ */

#chatbot-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    font-family: 'Crimson Text', Georgia, serif;
}

/* ── Widget shell ── */
#chatbot-widget {
    width: 380px;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    background: rgba(10, 8, 14, 0.97);
    border: 1px solid rgba(201, 168, 76, 0.28);
    border-top: 2px solid #c9a84c;
    box-shadow:
        0 24px 64px rgba(0,0,0,0.75),
        0 0 0 1px rgba(201, 168, 76, 0.06),
        inset 0 0 60px rgba(0,0,0,0.4);
    transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1),
                opacity    0.25s ease;
}

/* Collapsed state */
#chatbot-widget.chatbot-collapsed {
    max-height: 52px;
    overflow: hidden;
}

/* ── Header ── */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: 52px;
    flex-shrink: 0;
    cursor: pointer;
    background: rgba(201, 168, 76, 0.05);
    border-bottom: 1px solid rgba(201, 168, 76, 0.15);
    user-select: none;
    transition: background 0.2s;
}
.chatbot-header:hover { background: rgba(201, 168, 76, 0.1); }

.chatbot-header span:first-child {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #c9a84c;
}

.toggle-icon {
    font-size: 0.7rem;
    color: rgba(201, 168, 76, 0.55);
    transition: transform 0.3s ease;
    line-height: 1;
}
#chatbot-widget:not(.chatbot-collapsed) .toggle-icon {
    transform: rotate(180deg);
}

/* ── Body ── */
.chatbot-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Messages ── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
    min-height: 260px;
    max-height: calc(78vh - 52px - 62px);
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.2);
    border-radius: 2px;
}
#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.4);
}

/* ── Individual messages ── */
.message {
    font-size: 0.98rem;
    line-height: 1.65;
    padding: 0.65rem 0.9rem;
    max-width: 88%;
    position: relative;
}

.message.user {
    align-self: flex-end;
    background: rgba(139, 26, 42, 0.25);
    border: 1px solid rgba(139, 26, 42, 0.4);
    border-top: 1px solid rgba(201, 168, 76, 0.15);
    color: #e8dcc8;
    font-family: 'Crimson Text', serif;
}

.message.assistant {
    align-self: flex-start;
    background: rgba(201, 168, 76, 0.05);
    border: 1px solid rgba(201, 168, 76, 0.18);
    border-left: 2px solid rgba(201, 168, 76, 0.45);
    color: #e8dcc8;
    font-family: 'IM Fell English', Georgia, serif;
    font-style: italic;
    font-size: 1rem;
}

.message.system {
    align-self: center;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    color: rgba(201, 168, 76, 0.55);
    text-align: center;
    padding: 0.3rem 0.5rem;
    border: none;
    background: none;
    max-width: 95%;
    font-style: normal;
}

/* Thinking indicator */
.thinking-indicator {
    align-self: flex-start;
    padding: 0.65rem 1rem;
}
.thinking-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}
.thinking-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.5);
    animation: thinking-pulse 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-pulse {
    0%, 80%, 100% { transform: scale(0.75); opacity: 0.4; }
    40%           { transform: scale(1);    opacity: 1;   }
}

/* ── Input area ── */
.chat-input-area {
    display: flex;
    gap: 0;
    padding: 0.65rem 0.9rem;
    background: rgba(201, 168, 76, 0.03);
    border-top: 1px solid rgba(201, 168, 76, 0.12);
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-right: none;
    color: #e8dcc8;
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1rem;
    padding: 0.5rem 0.85rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    min-width: 0;
}
#chat-input::placeholder { color: rgba(196, 180, 154, 0.35); font-style: italic; }
#chat-input:focus {
    border-color: rgba(201, 168, 76, 0.45);
    background: rgba(255,255,255,0.06);
}
#chat-input:disabled { opacity: 0.5; cursor: not-allowed; }

#chat-send-btn {
    background: rgba(201, 168, 76, 0.12);
    border: 1px solid rgba(201, 168, 76, 0.3);
    color: #c9a84c;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.65rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}
#chat-send-btn:hover:not(:disabled) {
    background: rgba(201, 168, 76, 0.22);
    color: #e8c84a;
}
#chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #chatbot-container {
        bottom: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
    }
    #chatbot-widget {
        width: 100%;
    }
}
