/* =========================================================
   ESTRUTURA PRINCIPAL (LAYOUT SAAS)
   ========================================================= */
body { 
    margin: 0; 
    background-color: var(--bg-color); 
    overflow-x: hidden; 
}

.dashboard-layout { 
    display: flex; 
    min-height: 100vh; 
}

.main-wrapper { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-width: 0; 
}

.painel-content { 
    padding: 30px; 
    max-width: 1400px; 
    margin: 0 auto; 
    width: 100%; 
}

/* =========================================================
   SIDEBAR (MENU LATERAL PREMIUM)
   ========================================================= */
.sidebar { 
    width: 260px; 
    background: var(--surface-color); 
    border-right: 1px solid var(--border-color); 
    display: flex; 
    flex-direction: column; 
    position: sticky; 
    top: 0; 
    height: 100vh; 
    z-index: 100; 
}

.sidebar-header { 
    padding: 25px 20px; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}

.brand-logo {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 10px rgba(43, 108, 176, 0.2);
}

.brand-name {
    font-size: 1.3rem;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.brand-name strong {
    color: var(--primary-color);
    font-weight: 800;
}

.sidebar-nav { 
    padding: 10px 0 20px 0; 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden; 
}

.nav-category { 
    padding: 20px 20px 5px 20px; 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    font-weight: 700; 
    color: var(--text-muted); 
    opacity: 0.7; 
}

.nav-item { 
    padding: 12px 20px; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    color: var(--text-muted); 
    text-decoration: none; 
    font-weight: 500; 
    transition: all 0.2s; 
    border-left: 3px solid transparent; 
    position: relative;
}

.nav-item:hover { 
    background: #F7FAFC; 
    color: var(--primary-color); 
}

.nav-item.active { 
    background: #EBF8FF; 
    color: var(--primary-color); 
    border-left-color: var(--primary-color); 
    font-weight: 600; 
}

.nav-item i { 
    font-size: 1.4rem; 
}

/* Badges e Ícones Extras no Menu */
.nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
}

.nav-badge.danger { 
    background: #FED7D7; 
    color: #C53030; 
}

.external-icon { 
    margin-left: auto; 
    font-size: 1rem; 
    opacity: 0.5; 
}

/* Rodapé do Menu (Perfil Mini) */
.sidebar-footer { 
    padding: 15px 20px; 
    border-top: 1px solid var(--border-color); 
    background: #F7FAFC;
}

.user-mini-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-mini {
    width: 38px;
    height: 38px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name { 
    font-weight: 700; 
    color: var(--text-main); 
    font-size: 0.9rem; 
}

.user-role { 
    font-size: 0.75rem; 
    color: var(--text-muted); 
}

/* =========================================================
   HEADER EXECUTIVO (TOPO)
   ========================================================= */
.top-header { 
    background: var(--surface-color); 
    padding: 15px 30px; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    position: sticky; 
    top: 0; 
    z-index: 90; 
}

.header-search { 
    display: flex; 
    align-items: center; 
    background: var(--bg-color); 
    padding: 8px 15px; 
    border-radius: var(--radius-md); 
    width: 300px; 
    border: 1px solid var(--border-color); 
}

.header-search input { 
    border: none; 
    background: transparent; 
    outline: none; 
    width: 100%; 
    margin-left: 10px; 
    font-family: inherit; 
}

.header-actions { 
    display: flex; 
    align-items: center; 
    gap: 20px; 
}

.user-profile { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-weight: 600; 
    color: var(--text-main); 
}

.avatar { 
    width: 35px; 
    height: 35px; 
    background: var(--primary-color); 
    color: white; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 0.9rem; 
}

/* =========================================================
   CONTEÚDO E WIDGETS
   ========================================================= */
.page-title { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 25px; 
}

.page-title h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-main);
}

/* --- KPIs (Indicadores) --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    margin-top: 0;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.stat-card.warning .stat-number { color: var(--warning); }
.stat-card.success .stat-number { color: var(--accent-color); }

/* --- Gráficos --- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.canvas-wrapper {
    position: relative;
    height: 320px;
    width: 100%;
    margin-top: 15px;
}

/* --- Tabela --- */
.table-section {
    padding: 20px;
}

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

.table-header h3 {
    margin: 0;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-color);
    font-weight: 600;
    color: var(--text-muted);
}

.data-table tbody tr:hover {
    background-color: #F7FAFC;
}

/* =========================================================
   RESPONSIVIDADE (MOBILE-FRIENDLY)
   ========================================================= */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -300px; /* Hide by default on mobile */
        top: 0;
        bottom: 0;
        z-index: 9999;
        transition: left 0.3s ease;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
    }
    .sidebar-overlay.active {
        display: block;
    }

    .main-wrapper {
        width: 100%;
    }

    .top-header {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .header-search {
        width: 100%;
        order: 2; /* Move a busca para baixo no header */
    }

    .painel-content {
        padding: 15px;
    }

    .page-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .kpi-grid, .charts-grid {
        grid-template-columns: 1fr; /* Tudo 1 coluna no mobile */
    }

    .chart-container .canvas-wrapper {
        height: 250px; /* Gráficos menores */
    }

    /* Mostrar botão hamburguer */
    .btn-mobile-menu {
        display: block !important;
        background: none;
        border: none;
        font-size: 1.8rem;
        color: var(--primary-color);
        cursor: pointer;
    }
}