/* =========================================================
   Hotflixx — Assistente IA (botão flutuante e janela)
========================================================= */

.ai-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 18px 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent, #fff);
    font: inherit;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgb(var(--shadow-color, 0 0 0) / 0.35);
    transition: transform 0.15s ease, background 0.15s ease;
}

.ai-fab:hover { background: var(--accent-hover, var(--accent)); transform: translateY(-1px); }
.ai-fab:focus-visible { outline: 3px solid var(--info, #6aa8ff); outline-offset: 3px; }
.ai-fab svg { width: 22px; height: 22px; flex: none; }
.ai-fab[hidden] { display: none; }
body.ai-open .ai-fab { display: none; }

.ai-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 40px));
    height: min(620px, calc(100vh - 40px));
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg-soft, var(--surface));
    color: var(--text);
    box-shadow: 0 24px 60px rgb(var(--shadow-color, 0 0 0) / 0.45);
    overflow: hidden;
}

.ai-panel[hidden] { display: none; }

.ai-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.ai-head-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent, #fff);
    flex: none;
}

.ai-head-icon svg { width: 20px; height: 20px; }
.ai-head-text { flex: 1; min-width: 0; }
.ai-head-text strong { display: block; font-size: 15px; }
.ai-head-text small { display: block; color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ai-icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    flex: none;
}

.ai-icon-btn:hover { background: var(--surface-3); color: var(--text); }
.ai-icon-btn svg { width: 18px; height: 18px; }
.ai-icon-btn.on { color: var(--success); }

.ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
}

.ai-msg {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: normal;
}

.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.ai-msg.me { align-self: flex-end; background: var(--accent); color: var(--on-accent, #fff); border-top-right-radius: 4px; }
.ai-msg.err { align-self: stretch; max-width: none; background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: var(--text); }
.ai-msg a { color: inherit; text-decoration: underline; }
.ai-msg.bot a { color: var(--info, #6aa8ff); }
.ai-msg ol, .ai-msg ul { margin: 4px 0; padding-left: 20px; }
.ai-msg p { margin: 0 0 6px; }
.ai-msg p:last-child { margin-bottom: 0; }

.ai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: ai-dot 1s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: 0.15s; }
.ai-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-typing i { animation: none; } }

.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip {
    padding: 7px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}
.ai-chip:hover { border-color: var(--accent); color: var(--text); }

.ai-foot { border-top: 1px solid var(--border); padding: 10px; background: var(--surface); }
.ai-form { display: flex; gap: 8px; align-items: flex-end; }
.ai-form textarea {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    resize: none;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--bg-soft, var(--surface-2));
    color: var(--text);
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
}
.ai-form textarea:focus { outline: none; border-color: var(--accent); }
.ai-send {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--on-accent, #fff);
    cursor: pointer;
    flex: none;
}
.ai-send:disabled { opacity: 0.45; cursor: not-allowed; }
.ai-send svg { width: 18px; height: 18px; }
.ai-note { margin: 6px 2px 0; color: var(--text-faint); font-size: 11px; line-height: 1.35; }

/* WhatsApp */
.ai-wa { padding: 16px; display: flex; flex-direction: column; gap: 12px; font-size: 14px; line-height: 1.5; }
.ai-wa h4 { margin: 0; font-size: 16px; }
.ai-wa p { margin: 0; color: var(--text-soft); }
.ai-wa ol { margin: 0; padding-left: 20px; color: var(--text-soft); }
.ai-wa li { margin-bottom: 6px; }
.ai-code {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    background: var(--surface-2);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 15px;
}
.ai-code b { font-size: 18px; letter-spacing: 1px; }
.ai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.ai-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.ai-btn.wa { background: #25d366; border-color: #25d366; color: #062b14; }
.ai-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-ok { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--text); }
.ai-muted { color: var(--text-muted); font-size: 12px; }

@media (max-width: 760px) {
    .ai-fab {
        right: 14px;
        bottom: calc(78px + env(safe-area-inset-bottom));
        width: 52px;
        padding: 0;
        justify-content: center;
    }
    .ai-fab span { display: none; }
    .ai-panel {
        right: 0;
        left: 0;
        bottom: 0;
        top: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        border: 0;
        z-index: 1300;
    }
    .ai-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .ai-form textarea { font-size: 16px; }
}
