/* ============================================================ */
/* RESET E VARIÁVEIS                                            */
/* ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-2: #8b5cf6;
    --accent: #ec4899;
    --bg: #0f0f23;
    --bg-2: #1a1a2e;
    --bg-3: #252540;
    --text: #e5e7eb;
    --text-dim: #9ca3af;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ============================================================ */
/* LOGIN                                                        */
/* ============================================================ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at 50% 0%, #2a1e5c 0%, #0f0f23 60%);
    padding: 20px;
}

.login-card {
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 24px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.15);
}

.login-card .logo { width: 120px; height: 120px; margin-bottom: 20px; }

.login-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #a5b4fc, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle { color: var(--text-dim); margin-bottom: 36px; font-size: 14px; }

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    background: #fff;
    color: #1f2937;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.google-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(255, 255, 255, 0.15); }

.footer { margin-top: 24px; font-size: 12px; color: var(--text-dim); }

/* ============================================================ */
/* CADASTRO / LOGIN MANUAL                                      */
/* ============================================================ */
.erro-box {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    text-align: left;
}

.divisor {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    margin: 20px 0;
    position: relative;
}

.divisor::before,
.divisor::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: rgba(139, 92, 246, 0.2);
}

.divisor::before { left: 0; }
.divisor::after  { right: 0; }

.btn-secondary {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--bg-3);
    border-color: var(--primary-2);
    transform: translateY(-1px);
}

.btn-outline { background: transparent; border-color: rgba(139, 92, 246, 0.5); }

.btn-primary {
    display: block;
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3); }

.form-cadastro { text-align: left; }
.form-row { margin-bottom: 14px; }
.form-row label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-row input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-2);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-row input:focus { border-color: var(--primary-2); background: var(--bg-3); }

.form-row-double {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.form-row-double label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-row-double input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-2);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.form-row-double input:focus { border-color: var(--primary-2); }

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 16px 0 6px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
}

.checkbox-row input { margin-top: 2px; accent-color: var(--primary-2); }

.links-bottom {
    margin-top: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-dim);
}

.links-bottom p { margin-bottom: 6px; }
.links-bottom a {
    color: var(--primary-2);
    text-decoration: none;
    font-weight: 500;
}

.links-bottom a:hover { text-decoration: underline; }

.avatar-inicial {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

@media (max-width: 500px) {
    .form-row-double { grid-template-columns: 1fr; }
}

/* ============================================================ */
/* CHAT - ESTRUTURA PRINCIPAL                                   */
/* ============================================================ */
.chat-body {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: var(--bg-2);
    border-right: 1px solid rgba(139, 92, 246, 0.15);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
}

.sidebar-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.sidebar-header img { width: 42px; height: 42px; }

.sidebar-header h2 {
    font-size: 20px;
    background: linear-gradient(135deg, #a5b4fc, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-chat-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform 0.15s;
    font-family: inherit;
}

.new-chat-btn:hover { transform: translateY(-1px); }

.user-info {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-3);
    border-radius: 12px;
    margin-bottom: 12px;
}

.user-info img { width: 40px; height: 40px; border-radius: 50%; }
.user-name { font-size: 14px; font-weight: 600; }
.user-email { font-size: 11px; color: var(--text-dim); }

.logout-btn {
    text-align: center;
    padding: 10px;
    background: transparent;
    border: 1px solid rgba(236, 72, 153, 0.3);
    color: var(--accent);
    border-radius: 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: block;
}

.logout-btn:hover { background: rgba(236, 72, 153, 0.1); }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at 50% 0%, #1a1a3e 0%, #0f0f23 60%);
    min-width: 0;
}

/* ============================================================ */
/* MENSAGENS                                                    */
/* ============================================================ */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 20px;
}

.welcome-logo {
    width: 110px;
    height: 110px;
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome h1 { font-size: 32px; margin-bottom: 8px; }
.welcome p { color: var(--text-dim); }

.message {
    display: flex;
    gap: 12px;
    max-width: 850px;
    width: 100%;
    align-self: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--bg-3);
    flex-shrink: 0;
}

.message.assistant .avatar { background: linear-gradient(135deg, var(--primary), var(--accent)); }

.bubble {
    background: var(--bg-2);
    padding: 14px 18px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 15px;
    border: 1px solid rgba(139, 92, 246, 0.1);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.message.user .bubble {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border: none;
}

.bubble code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 13px;
}

/* Badge de fonte */
.fonte-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

.fonte-banco { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.fonte-ia    { background: rgba(236, 72, 153, 0.2); color: #ec4899; }

/* Animação de digitação */
.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary-2);
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* Botão de ouvir em cada resposta */
.speak-msg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    padding: 4px 6px;
    background: transparent;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    vertical-align: middle;
}

.speak-msg-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    color: var(--text);
    border-color: var(--primary-2);
}

/* ============================================================ */
/* FORMULÁRIO DE ENVIO                                          */
/* ============================================================ */
.chat-form {
    display: flex;
    gap: 10px;
    padding: 20px 32px 28px;
    max-width: 950px;
    width: 100%;
    margin: 0 auto;
    align-items: flex-end;
}

#input {
    flex: 1;
    background: var(--bg-2);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 14px;
    padding: 14px 18px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 200px;
    transition: border-color 0.2s;
    min-width: 0;
}

#input:focus { border-color: var(--primary-2); }

#send-btn {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
    flex-shrink: 0;
}

#send-btn:hover:not(:disabled) { transform: scale(1.05); }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Botões de ícone (mic, speak) */
.icon-btn {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: var(--bg-2);
    border: 1px solid rgba(139, 92, 246, 0.25);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover { background: var(--bg-3); border-color: var(--primary-2); }

.icon-btn.recording {
    background: linear-gradient(135deg, #ef4444, #ec4899);
    border-color: #ef4444;
    color: white;
    animation: pulse-mic 1.2s infinite;
}

@keyframes pulse-mic {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.icon-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-color: var(--primary-2);
    color: white;
}

.voice-hint {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-dim);
    background: rgba(99, 102, 241, 0.1);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    max-width: 600px;
    line-height: 1.5;
}

/* ============================================================ */
/* SCROLLBAR                                                    */
/* ============================================================ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #383860; }

/* ============================================================ */
/* 📱 MENU MOBILE - Botão e Overlay                             */
/* ============================================================ */

/* Escondidos por padrão (desktop) */
.menu-toggle { display: none; }
.sidebar-overlay { display: none; }

/* ============================================================ */
/* 📱 RESPONSIVO - MOBILE (até 768px)                           */
/* ============================================================ */
@media (max-width: 768px) {

    /* Layout vira coluna */
    .chat-body {
        flex-direction: column;
        position: relative;
        overflow: hidden;
    }

    /* Sidebar vira gaveta deslizante */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 82%;
        max-width: 320px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
        overflow-y: auto;
        padding: 20px 18px;
    }

    .sidebar.aberta {
        transform: translateX(0);
    }

    /* Overlay escuro */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.65);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.ativo {
        display: block;
    }

    /* Botão hamburguer - FORÇADO a aparecer */
    .menu-toggle {
        display: flex !important;
        position: fixed !important;
        top: 14px !important;
        left: 14px !important;
        z-index: 998 !important;
        width: 44px !important;
        height: 44px !important;
        background: var(--bg-2) !important;
        border: 1px solid rgba(139, 92, 246, 0.5) !important;
        border-radius: 12px !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        color: var(--text) !important;
        transition: all 0.2s !important;
    }

    .menu-toggle:active {
        transform: scale(0.95);
        background: var(--bg-3) !important;
    }

    .menu-toggle svg {
        display: block !important;
        width: 22px !important;
        height: 22px !important;
    }

    /* Área principal */
    .chat-main {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    /* Área das mensagens com espaço pro botão */
    .messages {
        padding: 72px 12px 12px 12px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
    }

    /* Mensagens mais compactas */
    .message {
        max-width: 100%;
        gap: 8px;
    }

    .avatar {
        width: 30px;
        height: 30px;
        font-size: 15px;
    }

    .bubble {
        padding: 10px 14px;
        font-size: 14.5px;
        border-radius: 14px;
        line-height: 1.5;
    }

    /* Formulário de envio */
    .chat-form {
        padding: 10px 10px 14px 10px;
        gap: 6px;
        position: sticky;
        bottom: 0;
        background: var(--bg);
        border-top: 1px solid rgba(139, 92, 246, 0.15);
        align-items: flex-end;
        flex-wrap: nowrap;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
        max-width: 100%;
    }

    /* Botões menores */
    .icon-btn,
    #send-btn {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        flex-shrink: 0;
        min-width: 42px;
    }

    .icon-btn svg,
    #send-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Input */
    #input {
        font-size: 16px; /* evita zoom no iOS */
        padding: 11px 14px;
        border-radius: 12px;
        max-height: 120px;
        flex: 1;
        min-width: 0;
    }

    /* Boas-vindas */
    .welcome h1 { font-size: 22px; }
    .welcome-logo { width: 80px; height: 80px; }
    .welcome p { font-size: 14px; }
    .voice-hint {
        font-size: 11px;
        padding: 6px 10px;
        margin-top: 12px;
    }

    /* Badge menor */
    .fonte-badge {
        font-size: 10px;
        padding: 2px 6px;
        margin-left: 6px;
    }

    /* Botão de ouvir em cada resposta */
    .speak-msg-btn {
        padding: 3px 5px;
        margin-left: 4px;
    }

    .speak-msg-btn svg {
        width: 12px;
        height: 12px;
    }

    /* Sidebar elementos */
    .sidebar-header img { width: 38px; height: 38px; }
    .sidebar-header h2 { font-size: 18px; }
    .new-chat-btn { font-size: 13px; padding: 11px; }

    .user-info { padding: 10px; }
    .user-info img,
    .user-info .avatar-inicial {
        width: 36px;
        height: 36px;
    }

    .user-name { font-size: 13px; }
    .user-email { font-size: 10px; }
    .logout-btn { font-size: 12px; padding: 9px; }
}

/* ============================================================ */
/* 📱 TELAS MUITO PEQUENAS (< 380px)                            */
/* ============================================================ */
@media (max-width: 380px) {
    .chat-form {
        gap: 4px;
        padding: 8px 6px 12px 6px;
    }

    .icon-btn,
    #send-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }

    #input {
        font-size: 15px;
        padding: 10px 12px;
    }

    .bubble {
        font-size: 14px;
        padding: 9px 12px;
    }

    .menu-toggle {
        top: 10px !important;
        left: 10px !important;
        width: 40px !important;
        height: 40px !important;
    }
}

/* ============================================================ */
/* CARD DE LIMITE ATINGIDO                                      */
/* ============================================================ */
.bubble.limite-atingido {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 20px;
    max-width: 500px;
}

.limite-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.limite-icon {
    font-size: 24px;
}

.limite-header h3 {
    font-size: 18px;
    color: #fca5a5;
    margin: 0;
}

.bubble.limite-atingido p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 12px;
}

.bubble.limite-atingido strong {
    color: #fbbf24;
}

.limite-info {
    background: rgba(139, 92, 246, 0.1);
    padding: 10px 14px;
    border-radius: 10px;
    border-left: 3px solid var(--primary-2);
    color: var(--text-dim) !important;
    font-size: 13px !important;
}

.limite-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin: 16px 0;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    color: white;
    text-decoration: none;
    text-align: center;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.limite-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.limite-planos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.mini-plano {
    background: var(--bg-3);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    font-size: 12px;
}

.mini-plano.destaque {
    border-color: rgba(236, 72, 153, 0.4);
    background: rgba(236, 72, 153, 0.05);
}

.mini-plano strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text);
}

.mini-plano span {
    display: block;
    color: #a5b4fc;
    font-weight: 600;
    margin-bottom: 2px;
}

.mini-plano small {
    color: var(--text-dim);
    font-size: 11px;
}

.mini-plano.destaque span {
    color: #f472b6;
}

@media (max-width: 500px) {
    .limite-planos {
        grid-template-columns: 1fr;
    }
    .bubble.limite-atingido {
        padding: 16px;
    }
    .limite-btn {
        font-size: 14px;
        padding: 12px;
    }
}

/* ============================================================ */
/* HISTORICO DE CONVERSAS (SIDEBAR)                             */
/* ============================================================ */
.historico-section {
    margin-top: 16px;
    margin-bottom: 12px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.historico-titulo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 10px;
    padding: 0 4px;
}

.historico-titulo button {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #a5b4fc;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1;
}

.historico-titulo button:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: var(--primary-2);
}

.historico-lista {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 300px;
    padding-right: 4px;
}

.historico-lista::-webkit-scrollbar {
    width: 4px;
}

.historico-lista::-webkit-scrollbar-thumb {
    background: var(--bg-3);
    border-radius: 2px;
}

.historico-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: var(--text-dim);
    position: relative;
}

.historico-item:hover {
    background: var(--bg-3);
    color: var(--text);
}

.historico-item.ativo {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: var(--text);
}

.historico-titulo-item {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.historico-del {
    opacity: 0;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.15);
    border: none;
    color: #fca5a5;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
    font-family: inherit;
    flex-shrink: 0;
}

.historico-item:hover .historico-del {
    opacity: 1;
}

.historico-del:hover {
    background: rgba(239, 68, 68, 0.4);
    color: white;
}

.historico-vazio {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    padding: 16px 8px;
    font-style: italic;
}

/* Mobile */
@media (max-width: 768px) {
    .historico-lista {
        max-height: 200px;
    }
}

/* ============================================================ */
/* SIDEBAR — LAYOUT FIXO COM ÁREA DE ROLAGEM                    */
/* ============================================================ */

.sidebar {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; /* o scroll só na área de conversas */
    padding: 20px 20px 12px 20px;
}

/* Área do histórico cresce e tem scroll próprio */
.historico-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(139, 92, 246, 0.15);
    margin-bottom: 12px;
}

.historico-lista {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

.historico-lista::-webkit-scrollbar {
    width: 6px;
}

.historico-lista::-webkit-scrollbar-track {
    background: transparent;
}

.historico-lista::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

.historico-lista::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.6);
}

/* ============================================================ */
/* MENU ADMIN COLAPSÁVEL                                        */
/* ============================================================ */
.admin-section {
    margin-bottom: 8px;
}

.admin-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.admin-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.5);
}

.admin-arrow {
    font-size: 10px;
    transition: transform 0.25s ease;
    color: #a5b4fc;
}

.admin-toggle.aberto .admin-arrow {
    transform: rotate(180deg);
}

.admin-menu {
    display: none;
    margin-top: 8px;
    padding-left: 0;
    animation: slideDown 0.25s ease;
}

.admin-menu.aberto {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================ */
/* USER-INFO FIXO NO RODAPÉ                                     */
/* ============================================================ */
.sidebar .user-info {
    margin-top: 0;
    flex-shrink: 0;
}

.sidebar > .logout-btn {
    flex-shrink: 0;
}

/* Botões principais e links ficam fixos no topo */
.sidebar > .new-chat-btn,
.sidebar > .logout-btn,
.sidebar > a.logout-btn,
.sidebar > .admin-section,
.sidebar > .historico-section {
    flex-shrink: 0;
}

/* ============================================================ */
/* MOBILE                                                       */
/* ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        padding: 20px 18px 14px 18px;
    }

    .historico-lista {
        max-height: none;
    }

    .historico-section {
        margin-top: 10px;
    }
}
