/* ============================================================
   Family Heritage — Chatbot Widget Styles
   ============================================================ */

/* ---- Floating Action Button ---- */
#chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary, #5B4A3F);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: transform 0.2s, box-shadow 0.2s;
}

#chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ---- Chat Panel ---- */
#chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 100px);
    background: var(--bg, #FDFAF6);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border, #E5DDD5);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    transition: opacity 0.2s, transform 0.2s;
}

.chat-panel-closed {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

.chat-panel-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---- Header ---- */
#chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--primary, #5B4A3F);
    color: #fff;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-header-right button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.chat-header-right button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

/* ---- Messages Area ---- */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-welcome {
    text-align: center;
    color: var(--text-light, #888);
    font-size: 0.85rem;
    padding: 1.5rem 0.5rem;
    line-height: 1.5;
}

.chat-welcome strong {
    color: var(--text, #3A2E25);
    font-size: 1rem;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.75rem;
}

.chat-suggestion {
    background: var(--bg-offset, #F5F0EB);
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 16px;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    color: var(--primary, #5B4A3F);
    cursor: pointer;
    transition: background 0.15s;
}

.chat-suggestion:hover {
    background: var(--border, #E5DDD5);
}

/* ---- Message Bubbles ---- */
.chat-msg {
    display: flex;
}

.chat-msg-user {
    justify-content: flex-end;
}

.chat-msg-bot {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-bubble-user {
    background: var(--primary, #5B4A3F);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble-bot {
    background: var(--bg-offset, #F5F0EB);
    color: var(--text, #3A2E25);
    border: 1px solid var(--border, #E5DDD5);
    border-bottom-left-radius: 4px;
}

.chat-bubble-bot strong {
    color: var(--primary, #5B4A3F);
}

.chat-person-link {
    color: var(--accent, #8B6914);
    text-decoration: underline;
    font-size: 0.75rem;
}

.chat-typing {
    color: var(--text-light, #888);
    font-style: italic;
    animation: chatPulse 1.5s ease-in-out infinite;
}

@keyframes chatPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ---- Sources ---- */
.chat-sources {
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border, #E5DDD5);
    font-size: 0.7rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

.chat-sources strong {
    font-size: 0.7rem;
    margin-right: 0.25rem;
}

.chat-sources a {
    color: var(--accent, #8B6914);
    text-decoration: underline;
    font-size: 0.7rem;
}

/* ---- Input Area ---- */
#chat-input-area {
    flex-shrink: 0;
    border-top: 1px solid var(--border, #E5DDD5);
}

#chat-context-bar {
    padding: 0.35rem 0.75rem;
    background: var(--bg-offset, #F5F0EB);
    font-size: 0.72rem;
    color: var(--text-light, #888);
    border-bottom: 1px solid var(--border, #E5DDD5);
}

#chat-form {
    display: flex;
    padding: 0.5rem;
    gap: 0.4rem;
}

#chat-input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border, #E5DDD5);
    border-radius: 20px;
    font-size: 0.85rem;
    background: var(--bg, #FDFAF6);
    color: var(--text, #3A2E25);
    outline: none;
    transition: border-color 0.15s;
}

#chat-input:focus {
    border-color: var(--primary, #5B4A3F);
}

#chat-input::placeholder {
    color: var(--text-light, #888);
}

#chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary, #5B4A3F);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

#chat-send:disabled {
    opacity: 0.4;
    cursor: default;
}

#chat-send:not(:disabled):hover {
    opacity: 0.85;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
    #chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 8px;
        right: 8px;
        border-radius: 12px;
    }

    #chat-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}

/* ---- Dark Mode Support ---- */
[data-theme="dark"] #chat-fab {
    background: #7A6B5F;
}

[data-theme="dark"] #chat-header {
    background: #4A3D34;
}

[data-theme="dark"] .chat-bubble-user {
    background: #6B5A4F;
}
