/* ═══════════════════════════════════════════════
   AI Chat Widget — Petrologger
   ═══════════════════════════════════════════════ */

/* ── FAB button ── */
#chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--btn-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--btn-fg);
    box-shadow:
        0 0  0   1px  rgba(34,211,238,.20),
        0 4px 16px    rgba(34,211,238,.30),
        0 8px 32px    rgba(0,0,0,.45);
    z-index: 9000;
    transition: transform .25s cubic-bezier(.34,1.56,.64,1),
                box-shadow .25s ease;
    padding: 0;
}

/* Pulsing ring — stops when panel is open */
#chat-fab::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(34,211,238,.55);
    animation: fabRing 2.4s ease-out infinite;
    pointer-events: none;
}

#chat-fab.active::before { animation: none; opacity: 0; }

@keyframes fabRing {
    0%   { transform: scale(1);   opacity: .7; }
    70%  { transform: scale(1.4); opacity: 0;  }
    100% { transform: scale(1.4); opacity: 0;  }
}

/* Tooltip label */
#chat-fab::after {
    content: 'Central de Ajuda';
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    background: var(--bg-card);
    border: 1px solid var(--border-lit);
    color: var(--text);
    font-size: .67rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 5px 11px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    box-shadow: 0 2px 12px rgba(0,0,0,.35);
}

#chat-fab:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

#chat-fab:hover {
    transform: scale(1.1);
    box-shadow:
        0 0  0   1px  rgba(34,211,238,.35),
        0 6px 24px    rgba(34,211,238,.50),
        0 10px 40px   rgba(0,0,0,.55);
}

#chat-fab.active {
    transform: rotate(15deg) scale(1.05);
}

#chat-fab svg { pointer-events: none; }

/* ── Panel ── */
#chat-panel {
    position: fixed;
    bottom: 84px;
    right: 24px;
    width: 360px;
    max-height: 520px;
    background: var(--bg-raised);
    border: 1px solid var(--border-lit);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,.55);
    display: flex;
    flex-direction: column;
    z-index: 8999;
    overflow: hidden;
    transform: translateY(14px) scale(.97);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s ease, opacity .22s ease;
}

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

/* ── Header ── */
.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--btn-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--btn-fg);
    flex-shrink: 0;
}

.chat-header-info { flex: 1; min-width: 0; }

.chat-header-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.2;
}

.chat-header-sub {
    font-size: .6rem;
    color: var(--text-dim);
    opacity: .7;
}

.chat-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dim);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color .15s;
    flex-shrink: 0;
}

.chat-close:hover { color: var(--text-bright); }

/* ── Messages ── */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-msg {
    max-width: 88%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: .80rem;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(74,222,128,.12), rgba(34,211,238,.12));
    border: 1px solid rgba(34,211,238,.22);
    color: var(--text);
    border-bottom-right-radius: 3px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 3px;
}

/* ── Typing indicator ── */
.chat-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    border-bottom-left-radius: 3px;
}

.chat-typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: chatBounce 1.2s infinite ease-in-out;
}

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

@keyframes chatBounce {
    0%,80%,100% { transform: translateY(0);   opacity: .35; }
    40%          { transform: translateY(-6px); opacity: 1;   }
}

/* ── Input area ── */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: saira, sans-serif;
    font-size: .82rem;
    color: var(--text);
    resize: none;
    max-height: 100px;
    min-height: 36px;
    overflow-y: auto;
    outline: none;
    transition: border-color .15s;
    line-height: 1.45;
    box-sizing: border-box;
    scrollbar-width: thin;
}

#chat-input:focus { border-color: var(--accent2); }
#chat-input::placeholder { color: var(--text-dim); opacity: .6; }

#chat-send {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--btn-bg);
    border: none;
    cursor: pointer;
    color: var(--btn-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
    padding: 0;
}

#chat-send:disabled { opacity: .38; cursor: default; }
#chat-send svg { pointer-events: none; }

/* ── FAQ guided navigation ── */
.faq-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.faq-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-lit);
    border-radius: 8px;
    padding: 9px 13px;
    font-size: .78rem;
    font-family: saira, sans-serif;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1.4;
    width: 100%;
}

.faq-btn:hover {
    background: rgba(34,211,238,.08);
    border-color: var(--accent2);
    color: var(--text-bright);
}

.faq-nav {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.faq-back {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: .72rem;
    font-family: saira, sans-serif;
    color: var(--text-dim);
    cursor: pointer;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.faq-back:hover {
    color: var(--text-bright);
    border-color: var(--accent2);
}
