/* public/assets/css/style.css */

/* ============================
   1. VARIÁVEIS E RESET
   ============================ */
:root {
    --primary-900: #2E1065;
    --primary-800: #3B0764;
    --primary-100: #F3E8FF;
    --secondary-500: #F97316;
    --text-dark: #1F2937;
    --text-gray: #6B7280;
    --bg-main: #F4F6F9;
    --white: #ffffff;
    --sidebar-width: 280px;
    --header-height: 70px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-main); color: var(--text-dark); height: 100vh; overflow: hidden; display: flex; font-size: 14px; }
a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }
button { cursor: pointer; border: none; font-family: inherit; }

/* Utilitários */
.hidden { display: none !important; }
.flex { display: flex !important; }
.w-full { width: 100%; }
.text-danger { color: #DC2626; }
.text-success { color: #059669; }

/* ============================
   2. LAYOUT PRINCIPAL
   ============================ */
.layout-wrapper { display: flex; width: 100%; height: 100vh; position: relative; }

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-900);
    color: white;
    display: flex; flex-direction: column;
    height: 100vh;
    position: fixed; left: 0; top: 0; z-index: 60;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
}

.sidebar-header {
    height: 90px; display: flex; align-items: center; justify-content: center;
    padding: 0 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); background: var(--primary-800);
}

.logo-container {
    
    padding: 8px 12px; border-radius: 8px;
    width: 100%; height: 50px; display: flex; align-items: center; justify-content: center;
}
.logo-img { max-height: 100%; max-width: 100%; object-fit: contain; }

.sidebar-nav { flex: 1; padding: 1.5rem 1rem; overflow-y: auto; }

.nav-section-title {
    font-size: 0.7rem; text-transform: uppercase; color: rgba(255,255,255,0.5);
    font-weight: 700; margin: 1.5rem 0 0.5rem 0.8rem;
}

.nav-item {
    display: flex; align-items: center; padding: 12px 16px; margin-bottom: 5px;
    border-radius: 8px; font-size: 0.95rem; color: rgba(255,255,255,0.8);
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; transform: translateX(5px); }
.nav-item i { margin-right: 12px; width: 20px; opacity: 0.8; }
.nav-item.active { background: var(--secondary-500); color: white; font-weight: 700; box-shadow: 0 4px 6px rgba(0,0,0,0.2); }

.sidebar-footer { padding: 1rem; background: rgba(0,0,0,0.2); border-top: 1px solid rgba(255,255,255,0.1); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 8px; margin-bottom: 10px; }
.user-avatar { width: 36px; height: 36px; background: #EAB308; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--primary-900); }
.btn-logout { width: 100%; padding: 10px; border: 1px solid rgba(239, 68, 68, 0.4); color: #FCA5A5; background: transparent; border-radius: 6px; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* --- CONTEÚDO --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Calcula margem baseada na variável CSS, alterada via JS */
    margin-left: var(--sidebar-width); 
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    min-height: 100vh;
}

.top-header {
    height: var(--header-height); background: var(--primary-900);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; color: white; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: sticky; top: 0; z-index: 40;
}

.page-title { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.menu-btn-mobile { display: none; background: rgba(255,255,255,0.1); border-radius: 6px; padding: 8px; color: white; }

.header-filter {
    background: rgba(0,0,0,0.25); padding: 6px 14px; border-radius: 50px;
    display: flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,0.15);
}
.header-filter select { background: transparent; border: none; color: white; font-weight: 600; outline: none; }
.header-filter option { color: #333; }

.content-scroll { flex: 1; padding: 2rem; overflow-y: auto; background: var(--bg-main); }

/* ============================
   3. COMPONENTES DO DASHBOARD
   ============================ */

/* KPI Grid (5 Colunas) */
.kpi-grid-5 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2.5rem; }

.kpi-card {
    background: white; border-radius: 12px; padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02); border: 1px solid #E5E7EB;
    position: relative; overflow: hidden; transition: transform 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 10px 15px rgba(0,0,0,0.05); }

.kpi-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.icon-box { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.kpi-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: #9CA3AF; letter-spacing: 0.05em; }
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--text-dark); line-height: 1; }
.kpi-sub { font-size: 0.75rem; color: #9CA3AF; margin-top: 5px; }

/* Cores KPI */
.blue { background: #DBEAFE; color: #2563EB; }
.green { background: #D1FAE5; color: #059669; }
.purple { background: #F3E8FF; color: var(--primary-900); }
.orange { background: #FFEDD5; color: var(--secondary-500); }
.red { background: #FEE2E2; color: #DC2626; }

/* Seções e Gráficos */
.section-title {
    font-size: 0.9rem; color: #6B7280; margin: 30px 0 15px 0;
    border-bottom: 1px solid #E5E7EB; padding-bottom: 5px;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}

.charts-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }

.card {
    background: white; border-radius: 12px; padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02); border: 1px solid #E5E7EB;
    display: flex; flex-direction: column;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card h3 { font-size: 1rem; font-weight: 700; color: var(--text-dark); margin: 0; }
.chart-container { position: relative; height: 280px; width: 100%; }

/* Botões Pequenos */
.btn-small {
    padding: 6px 12px; border-radius: 6px; font-size: 0.8rem; font-weight: 600;
    border: 1px solid #E5E7EB; background: white; color: var(--text-dark);
}
.btn-small:hover { border-color: var(--primary-900); color: var(--primary-900); background: #F9FAFB; }

/* Tabelas e Listas */
.table-preview { height: 200px; overflow-y: auto; }
.simple-list li {
    padding: 10px 0; border-bottom: 1px solid #F3F4F6; color: #4B5563; font-size: 0.85rem;
    display: flex; justify-content: space-between;
}
.badge { padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; font-weight: 600; background: #E5E7EB; }

.full-table { width: 100%; border-collapse: collapse; min-width: 600px; font-size: 0.9rem; }
.full-table th { background: #F8FAFC; padding: 12px; text-align: left; color: #64748B; font-weight: 600; border-bottom: 1px solid #E5E7EB; }
.full-table td { padding: 12px; border-bottom: 1px solid #F1F5F9; color: #334155; }

/* Modais */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); }
.modal-content {
    background: white; margin: 4vh auto; width: 90%; max-width: 900px; max-height: 90vh;
    border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    display: flex; flex-direction: column; animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 1.5rem; border-bottom: 1px solid #E5E7EB; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.5rem; overflow-y: auto; background: #F9FAFB; flex: 1; }
.close { font-size: 2rem; color: #9CA3AF; cursor: pointer; line-height: 0.8; }

/* ============================
   4. RESPONSIVIDADE (CORREÇÃO DE MENU)
   ============================ */
/* Overlay do Menu */
#mobile-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 50; /* Abaixo da sidebar (60) */
    opacity: 0; visibility: hidden; /* Oculto e não clicável */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
#mobile-overlay.active { opacity: 1; visibility: visible; }

body.sidebar-is-collapsed .main-content {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .content-scroll {
        padding: 1rem; /* Padding menor no mobile */
    }
    
    /* Ajuste de Grids para Mobile */
    .kpi-grid-5 { grid-template-columns: 1fr; gap: 1rem; }
    .charts-grid-2 { grid-template-columns: 1fr; }
    
    /* Garante que tabelas tenham scroll horizontal se estourarem */
    .table-container {
        overflow-x: auto;
    }
    
    .fale-table {
        min-width: 600px; /* Força largura mínima para scrollar */
    }
}
@media (max-width: 480px) {
    .kpi-grid-5 { grid-template-columns: 1fr; }
}