/*
 * SDA Bible AI Chat — Base Stylesheet
 * CSS custom properties (variables) are injected dynamically
 * via wp_add_inline_style in sda-bible-ai-chat.php
 */

/* ══════════════════════════════════════════════
   LAUNCHER BUTTON
   all:unset resets theme button interference
══════════════════════════════════════════════ */
#sda-chat-launcher {
    all: unset;
    position: fixed !important;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sda-primary);
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 999999 !important;
    box-shadow: var(--sda-shadow);
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
#sda-chat-launcher:hover {
    background: var(--sda-dark);
    transform: scale(1.08);
}
#sda-chat-launcher svg {
    width: 28px;
    height: 28px;
    fill: white;
    pointer-events: none;
}
#sda-chat-launcher .sda-icon-close {
    display: none;
}

/* ══════════════════════════════════════════════
   CHAT WINDOW
   Hidden by default; .sda-open reveals it
   pointer-events:auto (not "all" — invalid on HTML)
══════════════════════════════════════════════ */
#sda-chat-window {
    position: fixed !important;
    bottom: 100px;
    right: 28px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: auto;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    box-shadow: var(--sda-shadow);
    display: flex !important;
    flex-direction: column;
    z-index: 999998 !important;
    overflow: hidden;
    transform: scale(0.93) translateY(18px);
    opacity: 0 !important;
    pointer-events: none;
    transform-origin: bottom right;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s;
    border-radius: var(--sda-radius);
    font-family: var(--sda-font);
    box-sizing: border-box;
}
#sda-chat-window.sda-open {
    transform: scale(1) translateY(0);
    opacity: 1 !important;
    pointer-events: auto;
}

/* ══════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════ */
#sda-chat-header {
    background: var(--sda-primary);
    color: white;
    padding: 15px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sda-avatar {
    background-color: #fff;
    width: 38px;
    height: 38px;
    border: 0.1em solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.sda-avatar img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    display: block;
}
.sda-header-info {
    flex: 1;
    min-width: 0;
}
.sda-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}
.sda-header-info p {
    margin: 2px 0 0;
    font-size: 11px;
    opacity: 0.8;
    color: white;
}

/* all:unset resets theme button interference */
#sda-chat-clear {
    all: unset;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    border-radius: 6px;
    padding: 5px 11px;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
    font-family: var(--sda-font);
    box-sizing: border-box;
    white-space: nowrap;
}
#sda-chat-clear:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ══════════════════════════════════════════════
   MESSAGES
══════════════════════════════════════════════ */
#sda-chat-messages {
    flex: 0.8;
    overflow-y: auto;
    padding: 1em 1em;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    font-family: var(--sda-font);
}
#sda-chat-messages::-webkit-scrollbar { width: 5px; }
#sda-chat-messages::-webkit-scrollbar-thumb {
    background: var(--sda-border);
    border-radius: 4px;
}

.sda-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: sdaIn 0.22s ease;
}
@keyframes sdaIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sda-msg.sda-user { flex-direction: row-reverse; }

.sda-msg-bubble {
    max-width: 82%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.56;
    word-wrap: break-word;
    color: var(--sda-text);
    border-radius: var(--sda-radius);
}
.sda-user .sda-msg-bubble {
    background: var(--sda-primary);
    color: white;
    border-bottom-right-radius: 2px;
}
.sda-bot .sda-msg-bubble {
    background: var(--sda-bubble-bot-bg);
    border-bottom-left-radius: 2px;
}

/* Rich text inside bubbles */
.sda-msg-bubble p { margin: 0 0 7px; }
.sda-msg-bubble p:last-child { margin-bottom: 0; }
.sda-msg-bubble strong { font-weight: 700; }
.sda-msg-bubble em { font-style: italic; }
.sda-msg-bubble ul,
.sda-msg-bubble ol { margin: 6px 0 6px 18px; padding: 0; }
.sda-msg-bubble li { margin-bottom: 3px; }
.sda-msg-bubble blockquote {
    border-left: 5px solid var(--sda-primary);
    margin: 8px 0;
    padding: 5px 5px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 0 4px 4px 0;
    font-style: italic;
    font-size: 1em !important;
    line-height: 1.5em !important;
}
.sda-user .sda-msg-bubble blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.sda-bot-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.sda-bot-icon img {
    width: 28px;
    height: 28px;
    object-fit: cover;
    display: block;
}

/* ══════════════════════════════════════════════
   TYPING INDICATOR
══════════════════════════════════════════════ */
.sda-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--sda-bubble-bot-bg);
    border-radius: var(--sda-radius) var(--sda-radius) var(--sda-radius) 2px;
    width: fit-content;
}
.sda-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sda-border);
    animation: sdaDot 1.2s infinite;
}
.sda-typing span:nth-child(2) { animation-delay: 0.2s; }
.sda-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sdaDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ══════════════════════════════════════════════
   SUGGESTION CHIPS
══════════════════════════════════════════════ */
#sda-suggestions {
    padding: 0 16px 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}
.sda-suggestion {
    all: unset;
    background: var(--sda-light);
    border: 1px solid var(--sda-border);
    border-radius: 20px;
    padding: 5px 12px;
    cursor: pointer;
    color: var(--sda-text);
    white-space: nowrap;
    font-family: var(--sda-font);
    font-size: 12px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    box-sizing: border-box;
}
.sda-suggestion:hover {
    background: var(--sda-primary);
    border-color: var(--sda-primary);
    color: white;
}

/* ══════════════════════════════════════════════
   INPUT AREA
══════════════════════════════════════════════ */
#sda-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--sda-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #ffffff;
}
#sda-chat-input {
        flex: 1;
    border: 1px solid var(--sda-border);
    border-radius: var(--sda-btn-radius);
    padding: 5px;
    font-size: 14px;
    line-height: 1.1;
    resize: none;
    outline: none;
    font-family: var(--sda-font);
    color: var(--sda-text);
    background: var(--sda-light);
    max-height: 120px;
    min-height: 2.9em;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
#sda-chat-input:focus {
    border-color: var(--sda-primary);
    background: white;
}
#sda-chat-input::placeholder { color: #b0b8c4; }

/* all:unset resets theme button interference */
#sda-chat-send {
    all: unset;
    width: 40px;
    height: 40px;
    background: var(--sda-primary);
    border-radius: var(--sda-btn-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
    box-sizing: border-box;
}
#sda-chat-send:hover { background: var(--sda-dark); }
#sda-chat-send:active { transform: scale(0.93); }
#sda-chat-send:disabled { opacity: 0.45; cursor: not-allowed; }
#sda-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
    pointer-events: none;
}

/* ══════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════ */
#sda-chat-footer {
    text-align: center;
    font-size: 10px;
    line-height: 1.1;
    color: #999;
    padding: 0 16px 10px;
    flex-shrink: 0;
    font-family: var(--sda-font);
}

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 430px) {
    #sda-chat-window {
        right: 10px !important;
        width: calc(100vw - 20px);
        bottom: 88px;
    }
    #sda-chat-launcher {
        right: 14px !important;
        bottom: 18px;
    }
}