﻿/* ================================================================
   ASISTENTE IA — Dark Glassmorphism UI
   MetaLogic Design System · Plus Jakarta Sans
   ================================================================ */

/* ── Variables ────────────────────────────────────────────────── */
:root {
    --sky-blue:       #6EC1E4;
    --cog-blue:       #3F8FD2;
    --deep-blue:      #1F3C88;
    --neural-purple:  #5B2D8B;
    --deep-purple:    #3B1C5A;

    --bg:             #0a0a1a;
    --bg-panel:       #0d0d24;
    --bg-section:     rgba(255,255,255,0.03);

    --text:           #f0f0f8;
    --text-sec:       rgba(240,240,248,0.65);
    --text-muted:     rgba(240,240,248,0.38);

    --glass:          rgba(255,255,255,0.04);
    --glass-strong:   rgba(255,255,255,0.07);
    --glass-border:   rgba(255,255,255,0.08);
    --glass-hover:    rgba(255,255,255,0.10);

    --grad:           linear-gradient(135deg, #3F8FD2, #5B2D8B);
    --grad-text:      linear-gradient(135deg, #6EC1E4, #5B2D8B);
    --grad-glow:      0 0 32px rgba(91,45,139,0.35);

    --r:              16px;
    --r-sm:           10px;
    --r-lg:           24px;
    --r-pill:         50px;

    --shadow:         0 8px 32px rgba(0,0,0,0.35);
    --ease:           0.35s cubic-bezier(0.4,0,0.2,1);

    --panel-w:        340px;
    --font:           'Plus Jakarta Sans', system-ui, sans-serif;
    --mono:           'JetBrains Mono', monospace;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }

.input-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
}

/* ── App Shell ────────────────────────────────────────────────── */
.app-shell {
    display: grid;
    grid-template-columns: var(--panel-w) 1fr;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ══ LEFT PANEL ════════════════════════════════════════════════ */
.left-panel {
    background: var(--bg-panel);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px 20px;
    position: relative;
    z-index: 10;
}

.panel-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 20px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    box-shadow: none;
}

.brand-icon .material-icons-round { font-size: 20px; color: #fff; }
.brand-icon img {
    display: block;
    width: 46px;
    height: 46px;
    object-fit: contain;
}

.brand-icon .status-dot {
    position: absolute;
    right: 1px;
    bottom: 2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #070b2d;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18), 0 0 8px rgba(34, 197, 94, 0.45);
    overflow: visible;
}

.brand-icon .status-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: liveRing 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes liveRing {
    0%   { transform: scale(1);   opacity: 0.7; }
    65%  { transform: scale(2.6); opacity: 0;   }
    100% { transform: scale(2.6); opacity: 0;   }
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }

.brand-title {
    font-size: 1rem;
    font-weight: 700;
    background: var(--grad-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.brand-subtitle { font-size: 0.72rem; color: var(--text-muted); font-weight: 400; }

.panel-section { margin-bottom: 22px; }

.section-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.section-label-row .section-label { margin-bottom: 0; }

/* Upload Zone */
.upload-zone {
    border: 2px dashed rgba(91,45,139,0.5);
    border-radius: var(--r-lg);
    background: var(--bg-section);
    cursor: pointer;
    transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
    overflow: hidden;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--neural-purple);
    background: rgba(91,45,139,0.08);
    box-shadow: 0 0 24px rgba(91,45,139,0.25);
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    text-align: center;
    width: 100%;
}

.upload-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: var(--r-sm);
    background: rgba(91,45,139,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ease);
}

.upload-icon-wrap .material-icons-round { font-size: 24px; color: var(--neural-purple); }
.upload-zone:hover .upload-icon-wrap { background: rgba(91,45,139,0.35); }
.upload-main { font-size: 0.95rem; font-weight: 600; color: #fff; margin-top: 4px; }
.upload-sub { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; }

.btn-explore {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
}
.btn-explore:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}

.upload-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    width: 100%;
    cursor: default;
}

.upload-badge-icon { color: #6EC1E4; font-size: 20px; flex-shrink: 0; }

.upload-filename {
    flex: 1;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-sec);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-remove-file {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 8px;
    transition: color var(--ease), background var(--ease);
    flex-shrink: 0;
}
.btn-remove-file:hover { color: #ef4444; background: rgba(239,68,68,0.08); }
.btn-remove-file:hover { color: #ef4444; }
.btn-remove-file .material-icons-round { font-size: 16px; }

.btn-train {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    margin-top: 10px;
    background: var(--grad);
    border: none;
    border-radius: var(--r);
    color: #fff;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
}
.btn-train:hover { opacity: 0.88; box-shadow: 0 6px 24px rgba(91,45,139,0.5); }
.btn-train .material-icons-round { font-size: 16px; }

.upload-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    width: 100%;
}

.upload-spin {
    width: 18px; height: 18px;
    border: 2px solid rgba(91,45,139,0.3);
    border-top-color: var(--neural-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }
#upload-status { font-size: 0.78rem; color: var(--text-sec); }

/* Temperature */
.temp-value-badge {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--sky-blue);
    background: rgba(110,193,228,0.12);
    padding: 2px 8px;
    border-radius: var(--r-pill);
}

.temp-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 99px;
    background: linear-gradient(to right, var(--cog-blue), var(--neural-purple), #c084fc);
    outline: none;
    cursor: pointer;
    margin-bottom: 6px;
}

.temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(91,45,139,0.5), 0 2px 8px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: box-shadow var(--ease);
}

.temp-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 5px rgba(91,45,139,0.6), 0 2px 8px rgba(0,0,0,0.4);
}

.temp-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Temperature tooltip */
.tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
    vertical-align: middle;
}

.tooltip-trigger {
    font-size: 12px;
    color: var(--text-muted);
    cursor: help;
    opacity: 0.7;
    line-height: 1;
    transition: opacity 0.2s, color 0.2s;
}

.tooltip-wrap:hover .tooltip-trigger {
    opacity: 1;
    color: var(--sky-blue);
}

.tooltip-bubble {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 210px;
    background: rgba(8, 8, 28, 0.97);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: 0.71rem;
    color: var(--text-sec);
    line-height: 1.6;
    white-space: normal;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.tooltip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(8, 8, 28, 0.97);
}

.tooltip-wrap:hover .tooltip-bubble { opacity: 1; }

/* Tone pills */
.tone-grid { display: flex; flex-wrap: wrap; gap: 7px; }

.tone-pill {
    font-family: var(--font);
    font-size: 0.73rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--r-pill);
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-sec);
    cursor: pointer;
    transition: all var(--ease);
    line-height: 1;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.tone-pill i { font-size: 14px; }

.tone-pill:hover {
    border-color: rgba(91,45,139,0.5);
    color: var(--text);
    background: var(--glass-hover);
}

.tone-pill.active {
    background: var(--grad);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(91,45,139,0.4);
}

/* Panel footer */
.panel-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-new-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--r-pill);
    background: var(--grad);
    color: #fff;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity var(--ease), box-shadow var(--ease);
    box-shadow: 0 4px 16px rgba(91,45,139,0.35);
}

.btn-new-chat:hover { opacity: 0.88; box-shadow: 0 6px 24px rgba(91,45,139,0.5); }
.btn-new-chat .material-icons-round { font-size: 16px; }

.btn-icon-ghost {
    width: 38px; height: 38px;
    border-radius: var(--r-sm);
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--ease);
}

.btn-icon-ghost:hover { border-color: rgba(110,193,228,0.35); color: var(--sky-blue); background: var(--glass-hover); }
.btn-icon-ghost .material-icons-round { font-size: 18px; }

/* Mobile toggle */
.panel-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    width: 40px; height: 40px;
    border-radius: var(--r-sm);
    background: var(--grad);
    border: none;
    color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(91,45,139,0.4);
}

.panel-toggle .material-icons-round { font-size: 20px; }

.panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9;
    backdrop-filter: blur(4px);
}

/* ══ CHAT PANEL ════════════════════════════════════════════════ */
.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg);
    overflow: hidden;
    position: relative;
}

/* Hero (initial centered state) */
.chat-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px 16px;
    text-align: center;
    gap: 14px;
    pointer-events: auto;
}

.chat-hero {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.chat-hero.hero-exiting {
    opacity: 0;
    transform: scale(0.97) translateY(-8px);
    pointer-events: none;
}
.chat-hero.hero-hidden { display: none !important; }

.hero-robot {
    width: 148px;
    height: 148px;
    filter: drop-shadow(0 8px 28px rgba(0,150,255,0.40));
    animation: heroFloat 4s ease-in-out infinite;
}

.hero-robot img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@keyframes heroFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-7px); }
}

.hero-title {
    font-size: 1.55rem;
    font-weight: 700;
    background: var(--grad-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
}

.hero-sub {
    font-size: 0.86rem;
    color: var(--text-muted);
    max-width: 300px;
    line-height: 1.7;
}

.hero-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 580px;
    margin-top: 8px;
}

.suggestion-chip {
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-pill);
    color: var(--text-sec);
    font-family: var(--font);
    font-size: 0.81rem;
    font-weight: 500;
    padding: 10px 20px;
    cursor: pointer;
    transition: all var(--ease);
    text-align: center;
    max-width: 340px;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.suggestion-chip i {
    font-size: 14px;
    opacity: 0.6;
    flex-shrink: 0;
}

.suggestion-chip:hover {
    background: var(--glass-hover);
    border-color: rgba(91,45,139,0.55);
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(91,45,139,0.25);
}

.suggestion-chip:hover i { opacity: 1; }

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    max-width: 720px;
    animation: fadeUp 0.3s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-message { align-self: flex-end; flex-direction: row-reverse; }

.user-message .message-content {
    background: var(--grad);
    color: #fff;
    border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
    padding: 12px 18px;
    font-size: 0.9rem;
    line-height: 1.6;
    box-shadow: 0 4px 16px rgba(63,143,210,0.25);
    max-width: 480px;
    word-break: break-word;
}

.bot-message { align-self: flex-start; flex-direction: column; transition: all 0.3s ease; }
.bot-message.hidden { opacity: 0; transform: scale(0.95) translateY(10px); }

.bot-message .message-content,
.bot-message .bot-answer {
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg);
    padding: 14px 18px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-sec);
    max-width: 600px;
    word-break: break-word;
    backdrop-filter: blur(12px);
    transition: width 0.3s ease, height 0.3s ease, padding 0.3s ease;
}

.fade-text {
    animation: fadeInOp 0.3s ease-in forwards;
    white-space: pre-wrap;
}
@keyframes fadeInOp {
    from { opacity: 0; }
    to { opacity: 1; }
}

.bot-answer .stream-plain,
.bot-answer .stream-final { font-size: inherit; line-height: inherit; color: inherit; }

.bot-answer.final-shown .stream-plain { display: none; }
.bot-answer:not(.final-shown) .stream-final { display: none; }

.bot-message strong { color: var(--text); font-weight: 600; }
.bot-message ul { padding-left: 1.4em; margin: 4px 0; display: flex; flex-direction: column; gap: 4px; }
.bot-message li { color: var(--text-sec); }

.message-actions { display: flex; gap: 6px; margin-top: 8px; padding-left: 2px; }

.btn-icon-sm {
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.78rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-icon-sm:hover { border-color: rgba(110,193,228,0.4); color: var(--sky-blue); background: rgba(110,193,228,0.08); }

/* Typing */
.typing-indicator { display: flex; align-items: center; gap: 10px; padding: 0 28px 8px; }

.typing-dots { display: flex; gap: 4px; align-items: center; }

.typing-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--neural-purple);
    animation: bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

.typing-label { font-size: 0.78rem; color: var(--text-muted); font-style: italic; }

/* Input bar */
.chat-input-bar {
    padding: 16px 24px 20px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: rgba(10, 10, 26, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(91, 45, 139, 0.22);
    box-shadow: 0 -1px 0 rgba(110, 193, 228, 0.07),
                0 -14px 36px rgba(0, 0, 0, 0.22);
}

#user-input {
    flex: 1;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    border-radius: var(--r);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 12px 16px;
    resize: none;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease);
    max-height: 120px;
    overflow-y: auto;
    box-sizing: border-box;
}

#user-input::placeholder { color: var(--text-muted); white-space: pre-wrap; word-wrap: break-word; }

#user-input:focus {
    border-color: rgba(91,45,139,0.6);
    box-shadow: 0 0 0 3px rgba(91,45,139,0.15);
}

.btn-send {
    width: 44px; height: 44px;
    flex-shrink: 0;
    border-radius: var(--r);
    background: var(--grad);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--ease), box-shadow var(--ease);
    box-shadow: 0 4px 16px rgba(91,45,139,0.35);
}

.btn-send:hover { opacity: 0.88; box-shadow: 0 6px 24px rgba(91,45,139,0.5); }
.btn-send .material-icons-round { font-size: 20px; }

/* ══ MODALS ════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-glass {
    background: rgba(13,13,36,0.92);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow), 0 0 32px rgba(91,45,139,0.2);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 28px;
}

.modal-sm { max-width: 400px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-header h2 .material-icons-round { font-size: 20px; color: var(--sky-blue); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
}

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--glass-border); margin-bottom: 20px; }

.tab-btn {
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 8px 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color var(--ease), border-color var(--ease);
    margin-bottom: -1px;
}

.tab-btn.active, .tab-btn:hover { color: var(--sky-blue); }
.tab-btn.active { border-bottom-color: var(--sky-blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }

.stat-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--r);
    padding: 14px 16px;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
    display: block;
}

.stat-value-large { font-size: 1.5rem; font-weight: 700; color: var(--text); font-family: var(--mono); }

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.85rem;
}

.stat-value { font-family: var(--mono); color: var(--sky-blue); font-weight: 600; font-size: 0.85rem; }

/* Buttons */
.btn-ghost {
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 9px 20px;
    border-radius: var(--r-pill);
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-sec);
    cursor: pointer;
    transition: all var(--ease);
}

.btn-ghost:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }

.btn-primary {
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: var(--r-pill);
    border: none;
    background: var(--grad);
    color: #fff;
    cursor: pointer;
    transition: opacity var(--ease), box-shadow var(--ease);
    box-shadow: 0 4px 16px rgba(91,45,139,0.3);
}

.btn-primary:hover { opacity: 0.88; }

.btn-primary-full {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 11px 20px;
    border-radius: var(--r);
    border: none;
    background: var(--grad);
    color: #fff;
    cursor: pointer;
    transition: opacity var(--ease);
}

.btn-primary-full:hover { opacity: 0.88; }
.btn-primary-full .material-icons-round { font-size: 18px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--r);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease;
    backdrop-filter: blur(12px);
}

.toast-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #34d399; }
.toast-error   { background: rgba(239,68,68,0.15);  border: 1px solid rgba(239,68,68,0.3);  color: #f87171; }

@keyframes toastIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }

/* ══ RESPONSIVE ════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .app-shell { grid-template-columns: 1fr; }

    .left-panel {
        position: fixed;
        inset-block: 0;
        left: 0;
        width: 300px;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform var(--ease);
        /* Padding superior extra para que el brand quede bajo el panel-toggle (56px) */
        padding-top: 64px;
    }
    .left-panel.panel-open { transform: translateX(0); }
    .panel-toggle { display: flex; }
    .panel-overlay.panel-open { display: block; }

    /* Expand touch target for remove-file button on mobile */
    .btn-remove-file { min-width: 44px; min-height: 44px; }

    /* Brand header centrado en móvil */
    .panel-brand {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
        padding-bottom: 20px;
    }
    .brand-icon { width: 56px; height: 56px; }
    .brand-icon img { width: 56px; height: 56px; }

    /* Mensajes y barra de input */
    .chat-messages { padding: 12px; -webkit-overflow-scrolling: touch; }
    .chat-input-bar {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
        gap: 8px;
        align-items: flex-end;
    }
    /* Evita zoom automático en iOS e incrementa altura para placeholder multilínea */
    #user-input { 
        font-size: 16px; 
        padding: 10px 14px;
        line-height: 1.3;
        min-height: 64px;
    }

    .user-message .message-content,
    .bot-message .bot-answer,
    .bot-message .message-content { max-width: 92vw; }

    /* Ocultar el logo de la esquina en móvil luego de escribir el primer mensaje */
    .chat-logo-corner {
        display: none !important;
    }

    /* Hero más compacto en móvil */
    .hero-logo  { max-width: 100px; max-height: 56px; margin-bottom: 0.6rem; }
    .chat-hero  { padding: 1.2rem 1rem 0.6rem; gap: 0.5rem; }
    .hero-title { font-size: 1.1rem; }
    .hero-sub   { font-size: 0.8rem; }
    .hero-suggestions { gap: 8px; }
    .suggestion-chip  { font-size: 0.78rem; padding: 8px 12px; }

    /* Modal: sube desde abajo, con scroll cuando el teclado virtual aparece */
    #lead-overlay, #cta-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .lead-modal {
        max-height: 92dvh;
        overflow-y: auto;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        padding: 1.8rem 1.4rem max(1.4rem, env(safe-area-inset-bottom, 1.4rem));
    }
}

/* ==========================================================================
   Lead capture modal
   ========================================================================== */

/* Overlay full-screen */
#lead-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
  animation: fadeIn 0.22s ease;
}

/* Modal card */
.lead-modal {
  background: var(--bg-panel, #0d0d24);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
  border-radius: var(--r-lg, 24px);
  padding: 2.4rem 2rem 2rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.04);
  animation: slideUp 0.24s cubic-bezier(.22,1,.36,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* ── Hero logo ────────────────────────────────────────────────────────── */
.hero-logo {
  display: block;
  margin: 0 auto 1.4rem;
  max-width: 180px;
  max-height: 80px;
  object-fit: contain;
}

/* logoReveal: elegant fade-in from above (replaces jarring 800px roll) */
.roll-in-top {
  animation: logoReveal 0.45s cubic-bezier(0.22,1,0.36,1) 0.6s both;
}

@keyframes logoReveal {
  0%   { transform: translateY(-18px) scale(0.9); opacity: 0; }
  100% { transform: translateY(0)     scale(1);   opacity: 1; }
}

/* ── Corner logo (appears after first message) ────────────────────────── */
.chat-logo-corner {
  position: absolute;
  top: 1rem;
  left: 1.2rem;
  width: 48px;
  height: 48px;
  object-fit: contain;
  z-index: 10;
  pointer-events: none;
}

/* fadeSlideIn: smooth slide from right (replaces jarring 800px roll) */
.roll-in-right {
  animation: fadeSlideIn 0.3s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes fadeSlideIn {
  0%   { transform: translateX(18px); opacity: 0; }
  100% { transform: translateX(0);    opacity: 1; }
}

/* Modal logo */
.lead-modal__logo {
  max-width: 160px;
  max-height: 64px;
  object-fit: contain;
  margin-bottom: 0.9rem;
}

/* Textarea dentro del CTA form */
.lead-modal__form textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary, #1e293b);
  background: var(--input-bg, #f8fafc);
  resize: vertical;
  min-height: 72px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.lead-modal__form textarea:focus {
  outline: none;
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* Heading */
.lead-modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  text-align: center;
}

/* Subtitle */
.lead-modal__subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.52);
  text-align: center;
  margin: 0.2rem 0 0.8rem;
  line-height: 1.5;
}

/* Form layout */
.lead-modal__form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Field wrapper */
.lead-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.lead-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.02em;
}
.lead-field input {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-sm, 10px);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  color: #fff;
  outline: none;
  transition: border-color 0.18s, background 0.18s;
  font-family: inherit;
}
.lead-field input::placeholder {
  color: rgba(255,255,255,0.25);
}
.lead-field input:focus {
  border-color: #3F8FD2;
  background: rgba(63,143,210,0.07);
}

/* Inline error */
.lead-modal__error {
  font-size: 0.8rem;
  color: #f87171;
  min-height: 1.1rem;
  margin: 0;
  text-align: center;
}

/* CTA button */
.lead-modal__cta {
  margin-top: 0.2rem;
  width: 100%;
  padding: 0.75rem 1.2rem;
  border: none;
  border-radius: var(--r-pill, 50px);
  background: var(--grad, linear-gradient(135deg,#3F8FD2,#5B2D8B));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.18s, transform 0.12s;
  font-family: inherit;
}
.lead-modal__cta:hover:not(:disabled)  { opacity: 0.88; transform: translateY(-1px); }
.lead-modal__cta:active                { transform: translateY(0); }
.lead-modal__cta:disabled              { opacity: 0.45; cursor: not-allowed; }

/* Success state */
.lead-modal__success {
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0;
  color: rgba(255,255,255,0.75);
  font-size: 0.92rem;
}
.lead-modal__success-icon {
  font-size: 2.6rem;
  color: #10b981;
}

/* Skip link — visible but leads to error message, never unlocks demo */
.lead-modal__skip {
  margin-top: 0.9rem;
  background: none;
  border: none;
  font-size: 12px;
  color: rgba(255,255,255,0.40);
  cursor: pointer;
  letter-spacing: 0.04em;
  font-family: inherit;
  padding: 0.2rem 0.5rem;
  transition: color 0.15s;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.lead-modal__skip:hover { color: rgba(255,255,255,0.65); }

/* Responsive */
@media (max-width: 480px) {
  .lead-modal {
    padding: 2rem 1.4rem 1.6rem;
    border-radius: var(--r, 16px);
  }
}

/* ══ MESSAGE PROGRESS BAR ══════════════════════════════════════ */
.msg-progress-bar {
    display: flex;
    gap: 5px;
    padding: 0 24px 10px;
    align-items: center;
}

.msg-progress-seg {
    flex: 1;
    height: 3px;
    border-radius: 99px;
    background: rgba(255,255,255,0.10);
    transition: background 0.4s ease;
}

.msg-progress-seg.seg-full   { background: var(--cog-blue); }
.msg-progress-seg.seg-warn   { background: #f59e0b; }
.msg-progress-seg.seg-danger { background: #ef4444; }

/* ══ SCROLL-TO-BOTTOM FAB ══════════════════════════════════════ */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 84px;
    right: 20px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    color: var(--text-sec);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: opacity 0.22s ease, transform 0.22s ease, background 0.2s, border-color 0.2s;
    pointer-events: none;
    z-index: 20;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-to-bottom-btn:hover {
    background: var(--glass-hover);
    border-color: rgba(91,45,139,0.5);
    color: var(--text);
}

.scroll-to-bottom-btn .material-icons-round { font-size: 22px; }

/* ══ AMBIENT BACKGROUND ORBS ═══════════════════════════════════ */
.ambient-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-bg span {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    animation: orbFloat var(--orb-dur, 12s) ease-in-out infinite alternate;
}

.ambient-bg span:nth-child(1) {
    width: 520px; height: 520px;
    background: radial-gradient(circle, rgba(63,143,210,0.20), transparent 65%);
    top: -160px; right: -80px;
    --orb-dur: 14s;
}

.ambient-bg span:nth-child(2) {
    width: 360px; height: 360px;
    background: radial-gradient(circle, rgba(91,45,139,0.22), transparent 65%);
    bottom: -100px; left: 10%;
    --orb-dur: 10s;
    animation-delay: -4s;
}

.ambient-bg span:nth-child(3) {
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(110,193,228,0.14), transparent 65%);
    top: 40%; right: 20%;
    --orb-dur: 17s;
    animation-delay: -9s;
}

@keyframes orbFloat {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(22px, 16px) scale(1.07); }
}

/* Stack .chat-panel flow content above ambient bg */
.chat-hero, .chat-messages, .typing-indicator,
.msg-progress-bar, .chat-input-bar, .chat-logo-corner {
    position: relative;
    z-index: 1;
}

/* ══ PREFERS REDUCED MOTION ════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .ambient-bg { display: none; }
}

/* ══ BOTTOM SHEET HANDLE (mobile modals) ═══════════════════════ */
@media (max-width: 768px) {
    .lead-modal::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 99px;
        background: rgba(255,255,255,0.25);
        align-self: center;
        margin-bottom: 1rem;
        flex-shrink: 0;
    }
}