:root {
    /* Cores Corporativas */
    --primary: #0A1128; /* Deep Navy Blue */
    --primary-hover: #162040;
    --primary-light: #F0F4F8;
    
    --bg-color: #F4F7F9; /* Fundo mais claro */
    --surface-color: #FFFFFF; /* Fundo de cards/sidebar */
    
    --text-main: #111827;
    --text-muted: #6B7280;
    
    --border-light: #E5E7EB;
    
    /* Cores de Status */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #3B82F6;
    
    /* Sombras Corporativas (Cloud Shadow) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.03), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.03), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    
    /* Arredondamento */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 9999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', system-ui, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); -webkit-font-smoothing: antialiased; }

/* Tipografia */
h1, h2, h3, h4 { font-weight: 600; color: var(--text-main); letter-spacing: -0.01em; }
p { color: var(--text-muted); line-height: 1.5; }

/* Cards Globais (Substituindo o antigo Glass) */
.glass-card {
    background: var(--surface-color);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* Forms e Inputs */
input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: #FFFFFF;
    transition: all 0.2s ease-in-out;
    font-size: 0.95rem;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
label { font-size: 0.85rem; font-weight: 600; display: block; margin-bottom: 0.5rem; color: #374151; text-transform: uppercase; letter-spacing: 0.05em; }

/* Buttons Corporate */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm); font-weight: 600; font-size: 0.95rem;
    cursor: pointer; transition: all 0.2s; border: none; gap: 0.5rem;
    letter-spacing: 0.02em;
}
.btn-primary { 
    background: var(--primary); 
    color: white; 
    box-shadow: var(--shadow-md); 
}
.btn-primary:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px); 
    box-shadow: var(--shadow-lg); 
}
.btn-glass { 
    background: white; 
    color: var(--text-main); 
    border: 1px solid var(--border-light); 
    box-shadow: var(--shadow-sm);
}
.btn-glass:hover { 
    background: var(--bg-color); 
    border-color: #D1D5DB;
}

/* Status Buttons */
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }

/* App Layout */
.app-container { display: flex; min-height: 100vh; overflow: hidden; }

/* Sidebar Desktop Corporate */
.sidebar {
    width: 260px; 
    background: var(--surface-color); 
    border-right: 1px solid var(--border-light); 
    display: flex; flex-direction: column;
    z-index: 10;
}
.sidebar-logo { 
    padding: 1.5rem 2rem; 
    font-size: 1.25rem; 
    font-weight: 700; 
    color: var(--text-main);
    display: flex; align-items: center; gap: 10px; 
}
.sidebar-menu { padding: 1.5rem 1.5rem; list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 0.85rem; padding: 0.75rem 1rem;
    text-decoration: none; color: var(--text-muted); border-radius: var(--radius-sm);
    transition: all 0.2s; font-weight: 500; font-size: 0.95rem;
}
.sidebar-menu a:hover {
    background: var(--bg-color); color: var(--text-main);
}
.sidebar-menu a.active {
    background: var(--primary-light); color: var(--primary); font-weight: 600;
}

.main-content { flex: 1; display: flex; flex-direction: column; position: relative; max-height: 100vh; }
.content-area { flex: 1; padding: 2.5rem 3rem; overflow-y: auto; background-color: var(--bg-color); }

/* Utilities Desktop vs Mobile */
.mobile-header { display: none; }
.mobile-nav { display: none; }

/* Modais */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(17, 24, 39, 0.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 100000;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 20px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: var(--border-light);
}
.timeline-item {
    position: relative;
    margin-bottom: 1rem;
}
.timeline-item::after {
    content: '';
    position: absolute;
    left: -17px;
    top: 5px;
    width: 10px;
    height: 10px;
    background: var(--surface-color);
    border: 3px solid var(--info);
    border-radius: 50%;
}


/* Tabelas */
.table-responsive { overflow-x: auto; }
table th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--text-muted);
}
table td {
    padding: 1rem 0.75rem;
}

/* --- COMPONENTES GLOBAIS (Leads, Cards, Grids) --- */

/* Grid de Leads (Inspirado no Dashboard) */
.leads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

.lead-card {
    padding: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 1rem;
    position: relative;
    overflow: visible;
}

.lead-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 1.25rem;
}

.lead-name-row {
    font-size: 1.15rem;
    font-weight: 700;
    color: #000;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lead-phone-sub {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 600;
}

/* Botões de Ação - Desktop Padrão */
.lead-actions-primary, .lead-actions-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
    width: 100%;
}

.lead-actions-secondary {
    border-top: 1px solid var(--glass-border);
    padding-top: 12px;
}

.btn-wa, .btn-call, .btn-note, .btn-transfer, .btn-archive {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-wa { background: #25D366; color: white; }
.btn-wa:hover { background: #1eb956; transform: translateY(-1px); }
.btn-call { background: var(--primary); color: white; }
.btn-call:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-note { border: 1px solid var(--glass-border); color: var(--text-main); background: rgba(255,255,255,0.5); }
.btn-transfer { border: 1px solid var(--info); color: var(--info); background: rgba(59, 130, 246, 0.05); }
.btn-archive { border: 1px solid var(--danger-light); color: var(--danger); background: rgba(239, 68, 68, 0.05); }

/* --- RESPONSIVIDADE (OVERRIDES) --- */

@media (max-width: 768px) {
    .sidebar { display: none; }
    .content-area { padding: 1rem; padding-bottom: 100px; }
    
    .mobile-header {
        display: flex; align-items: center; justify-content: space-between;
        padding: 1rem 1.5rem; background: var(--surface-color); 
        position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--border-light);
    }
    
    .mobile-header .logo { font-weight: 700; color: var(--text-main); font-size: 1.25rem; }
    
    .mobile-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0;
        background: var(--surface-color);
        border-top: 1px solid var(--border-light); padding: 0.5rem; justify-content: space-around;
        z-index: 40; box-shadow: 0 -4px 6px rgba(0,0,0,0.02); padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
    .mobile-nav a {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        text-decoration: none; color: var(--text-muted); font-size: 0.70rem; gap: 0.25rem;
        padding: 0.5rem; border-radius: var(--radius-sm); flex: 1; font-weight: 500;
    }
    .mobile-nav a.active { color: var(--primary); }
    .mobile-nav a i { font-size: 1.25rem; margin-bottom: 2px;}
    
    .mobile-nav a.nav-cta {
        background: var(--primary); color: white;
        border-radius: var(--radius-lg); margin-top: -20px;
        box-shadow: var(--shadow-lg);
        padding: 0.75rem 0.5rem; align-self: flex-end;
    }

    .responsive-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1.25rem;
    }
    
    .btn-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* Overrides Mobile para Leads - TRAVAMENTO TOTAL */
    .leads-grid {
        grid-template-columns: 1fr !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 4px !important;
        overflow-x: hidden !important;
    }

    .lead-card {
        padding: 0.75rem !important;
        width: 100% !important;
        max-width: calc(100vw - 24px) !important; /* Trava o card na tela */
        box-sizing: border-box !important;
        overflow: hidden !important; /* Nada sai do card */
    }

    /* Cabeçalho horizontal com proteção */
    .lead-header {
        display: grid !important;
        grid-template-columns: 1fr 100px !important; /* Etapa fixa em 100px */
        gap: 8px !important;
        width: 100% !important;
        align-items: center !important;
    }

    .lead-name-row {
        width: 100% !important;
        min-width: 0 !important; /* Permite encolher */
    }
    
    .lead-name-row span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }

    .lead-header-actions {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    .lead-header-actions select {
        width: 100% !important;
        font-size: 0.75rem !important;
        padding: 4px !important;
    }

    /* Botões Lado a Lado - FORÇADOS */
    .lead-actions-primary, .lead-actions-secondary {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important; /* Força 50% cada */
        gap: 6px !important;
        width: 100% !important;
    }

    .btn-wa, .btn-call, .btn-note, .btn-transfer, .btn-archive {
        padding: 0.6rem 0.25rem !important;
        font-size: 0.78rem !important;
        gap: 4px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .hide-mobile { display: none; }

    /* Bolsão (admin) tem um layout de 2 colunas fixo inline - empilha em vez de estourar a tela */
    .bolsao-layout {
        grid-template-columns: 1fr !important;
    }
    .bolsao-layout > div {
        position: static !important;
    }
}

/* Tablet / Desktop Overrides Específicos */
@media (min-width: 769px) {
    .btn-group { flex-direction: row; width: auto; }
}
