/* ============================================================
   CRM 12H — Estilos
   ============================================================ */

:root {
    --bg:         #0f172a;
    --bg2:        #1e293b;
    --bg3:        #334155;
    --surface:    #1e293b;
    --border:     #334155;
    --text:       #f1f5f9;
    --text2:      #94a3b8;
    --text3:      #64748b;
    --accent:     #f59e0b;
    --accent2:    #fbbf24;
    --danger:     #ef4444;
    --success:    #10b981;
    --info:       #3b82f6;
    --warning:    #f59e0b;
    --sidebar-w:  220px;
    --radius:     10px;
    --radius-sm:  6px;
    --shadow:     0 2px 12px rgba(0,0,0,.35);
    --font:       'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

svg {
    width: 18px; height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-logo {
    padding: 24px 20px 20px;
    display: flex;
    align-items: baseline;
    gap: 6px;
    border-bottom: 1px solid var(--border);
}

.logo-mark {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -1px;
}

.logo-sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--text3);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text2);
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s;
}

.sidebar-nav li a:hover {
    color: var(--text);
    background: rgba(255,255,255,.04);
    border-left-color: var(--border);
}

.sidebar-nav li a.active {
    color: var(--accent);
    background: rgba(245,158,11,.08);
    border-left-color: var(--accent);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.usuario-nome {
    font-size: 13px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    color: var(--text3);
    display: flex;
    align-items: center;
    transition: color .15s;
}

.btn-logout:hover { color: var(--danger); }

/* ── Layout principal ─────────────────────────────────────── */
.main-wrap {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    height: 56px;
    z-index: 50;
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 4px;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.content {
    flex: 1;
    padding: 24px;
}

/* ── Botões ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary  { background: var(--accent);  color: #000; }
.btn-primary:hover  { background: var(--accent2); color: #000; }
.btn-secondary { background: var(--bg3); color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-ghost    { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-full     { width: 100%; justify-content: center; }
.btn-sm       { padding: 5px 10px; font-size: 13px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    white-space: nowrap;
}

.badge-urgente  { background: rgba(239,68,68,.15);  color: #fca5a5; }
.badge-alta     { background: rgba(249,115,22,.15); color: #fdba74; }
.badge-media    { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-baixa    { background: rgba(148,163,184,.15);color: #94a3b8; }
.badge-ia-ativa   { background: rgba(16,185,129,.15);  color: #6ee7b7; font-size: 10px; }
.badge-ia-pausada { background: rgba(239,68,68,.15);   color: #fca5a5; font-size: 10px; }
.badge-ia-sem     { background: rgba(148,163,184,.12); color: #64748b; font-size: 10px; }

/* ── Cards de alerta (painel) ─────────────────────────────── */
.painel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

.alerta-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color .15s, box-shadow .15s;
    cursor: pointer;
    position: relative;
}

.alerta-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.alerta-card.tipo-ia_pausada       { border-left: 3px solid var(--danger); }
.alerta-card.tipo-aguardando_voce  { border-left: 3px solid var(--warning); }
.alerta-card.tipo-retorno_vencido  { border-left: 3px solid #f97316; }
.alerta-card.tipo-novo_lead        { border-left: 3px solid var(--info); }
.alerta-card.tipo-esfriando        { border-left: 3px solid var(--text3); }

.alerta-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.alerta-nome {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.alerta-titulo {
    font-size: 12px;
    color: var(--text2);
    margin-top: 2px;
}

.alerta-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.alerta-resumo {
    font-size: 13px;
    color: var(--text2);
    line-height: 1.5;
    background: rgba(255,255,255,.03);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    border-left: 2px solid var(--border);
}

.alerta-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.alerta-motivo {
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.alerta-motivo.ia_pausada       { color: var(--danger); }
.alerta-motivo.aguardando_voce  { color: var(--warning); }
.alerta-motivo.retorno_vencido  { color: #f97316; }
.alerta-motivo.novo_lead        { color: var(--info); }
.alerta-motivo.esfriando        { color: var(--text3); }

.alerta-tempo {
    font-size: 11px;
    color: var(--text3);
}

/* ── Estagio pill ─────────────────────────────────────────── */
.estagio-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* ── Painel topo ──────────────────────────────────────────── */
.painel-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    min-width: 130px;
    flex: 1;
}

.stat-num {
    font-size: 26px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text3);
    margin-top: 4px;
}

/* ── Formulários ──────────────────────────────────────────── */
.campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.campo label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
}

.campo input,
.campo select,
.campo textarea {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    padding: 9px 12px;
    font-family: var(--font);
    transition: border-color .15s;
    width: 100%;
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.campo textarea { resize: vertical; min-height: 80px; }

/* ── Login ────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-wrap {
    width: 100%;
    max-width: 380px;
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
}

.login-logo {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
}

.login-desc {
    font-size: 13px;
    color: var(--text3);
    margin-bottom: 24px;
}

.login-hint {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text3);
    text-align: center;
    line-height: 1.8;
}

.login-hint code {
    background: var(--bg3);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--accent);
}

/* ── Alertas ──────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-erro    { background: rgba(239,68,68,.1); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.alert-sucesso { background: rgba(16,185,129,.1); color: #6ee7b7; border: 1px solid rgba(16,185,129,.2); }
.alert-info    { background: rgba(59,130,246,.1); color: #93c5fd; border: 1px solid rgba(59,130,246,.2); }

/* ── Seção título ─────────────────────────────────────────── */
.secao-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.secao-titulo {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.secao-sub {
    font-size: 13px;
    color: var(--text3);
    margin-top: 2px;
}

/* ── Vazio ────────────────────────────────────────────────── */
.vazio {
    text-align: center;
    padding: 60px 20px;
    color: var(--text3);
}

.vazio-icon { font-size: 40px; margin-bottom: 12px; }
.vazio p    { font-size: 14px; }

/* ── Responsivo ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow);
    }

    .main-wrap {
        margin-left: 0;
    }

    .btn-menu {
        display: flex;
    }

    .painel-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 16px;
    }
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    z-index: 999;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
}
.toast.show  { opacity: 1; transform: translateY(0); }
.toast-sucesso { background: rgba(16,185,129,.9);  color: #fff; }
.toast-erro    { background: rgba(239,68,68,.9);   color: #fff; }
.toast-info    { background: rgba(59,130,246,.9);  color: #fff; }
