/* UNITY Eleitoral — Design System (Azul Protagonista, Verde Claro para Destaques Numéricos, Laranja Avante Complementar) */
:root {
    /* Cores Principais da Identidade Visual */
    --color-navy-main: #0F2A4A;
    --color-navy-secondary: #123B6D;
    --color-navy-hover: #1E40AF;
    
    --color-green-highlight: #10B981;
    --color-green-success: #059669;
    --color-green-light-bg: #ECFDF5;
    
    --color-orange-main: #F58220;
    --color-orange-hover: #D97706;
    
    /* Palette Semântica */
    --color-blue-accent: #2563EB;
    --color-red-danger: #EF4444;
    --color-yellow-warning: #F59E0B;
    --color-purple-accent: #8B5CF6;
    
    /* Backgrounds & Text */
    --color-bg-general: #F1F5F9;
    --color-card-bg: #FFFFFF;
    --color-text-main: #0F172A;
    --color-text-muted: #475569;
    --color-border-subtle: #E2E8F0;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 64px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--color-bg-general);
    color: var(--color-text-main);
    line-height: 1.5;
    min-height: 100vh;
}

/* Sidebar Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--color-navy-main);
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 15px rgba(0,0,0,0.15);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    position: sticky;
    top: 0;
    background-color: var(--color-navy-main);
    z-index: 10;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #FFFFFF;
    font-weight: 800;
    font-size: 1rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-brand-badge {
    background-color: var(--color-orange-main);
    color: #FFFFFF;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 800;
    flex-shrink: 0;
}

.sidebar-toggle-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #FFFFFF;
    font-size: 0.95rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.sidebar-toggle-btn:hover {
    background: var(--color-orange-main);
    border-color: var(--color-orange-main);
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-brand-badge,
.sidebar.collapsed .sidebar-text {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0 0.5rem;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

.sidebar.collapsed .sidebar-toggle-btn {
    margin-left: 0;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    background: var(--color-orange-main);
    border-color: var(--color-orange-main);
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.sidebar-item {
    padding: 0 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sidebar-link:hover {
    background-color: var(--color-navy-hover);
    color: #FFFFFF;
}

/* ITEM ATIVO EM LARANJA VIVO (#FF6500) */
.sidebar-link.active {
    background-color: var(--color-orange-main) !important;
    color: #FFFFFF !important;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(255, 101, 0, 0.3);
}

.sidebar-icon {
    font-size: 1.25rem;
    min-width: 24px;
    text-align: center;
    color: #D7DCFF;
}

.sidebar-link.active .sidebar-icon {
    color: #FFFFFF !important;
}

/* BOTAO SAIR EM LARANJA */
.sidebar-link.logout-link {
    color: var(--color-orange-main) !important;
    font-weight: 600;
}
.sidebar-link.logout-link .sidebar-icon {
    color: var(--color-orange-main) !important;
}
.sidebar-link.logout-link:hover {
    background-color: rgba(255, 101, 0, 0.15) !important;
}

.sidebar-divider {
    height: 1px;
    background-color: rgba(255,255,255,0.08);
    margin: 0.75rem 1rem;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background-color: var(--color-card-bg);
    border-bottom: 1px solid var(--color-border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.topbar-toggle-btn {
    background: var(--color-navy-main);
    color: #FFFFFF;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 2px 6px rgba(11, 11, 92, 0.2);
}

.topbar-toggle-btn:hover {
    background: var(--color-orange-main);
}

.topbar-title h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-navy-main);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: #E8EEF5;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
}

/* Page Body */
.page-body {
    padding: 2rem;
    flex: 1;
}

/* Custom Cards */
.content-card {
    background: var(--color-card-bg);
    border-radius: 12px;
    padding: 1.75rem;
    border: 1px solid var(--color-border-subtle);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.5rem;
}

/* KPI Cards com Ícones em Quadrados Coloridos Suaves */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--color-card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--color-border-subtle);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.kpi-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.icon-box-blue { background: rgba(37, 99, 235, 0.12); color: var(--color-blue-accent); }
.icon-box-orange { background: rgba(255, 101, 0, 0.12); color: var(--color-orange-main); }
.icon-box-green { background: rgba(0, 184, 132, 0.12); color: var(--color-green-success); }
.icon-box-yellow { background: rgba(245, 183, 0, 0.12); color: var(--color-yellow-warning); }
.icon-box-purple { background: rgba(139, 92, 246, 0.12); color: var(--color-purple-accent); }
.icon-box-red { background: rgba(244, 63, 94, 0.12); color: var(--color-red-danger); }

.kpi-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--color-green-success);
    line-height: 1.2;
}

.kpi-value-blue {
    color: var(--color-navy-main);
}

.kpi-value-green {
    color: var(--color-green-success);
}

.kpi-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Botões de Ação */
.btn-primary-orange, .btn-primary-blue {
    background-color: var(--color-navy-secondary);
    color: #FFFFFF;
    border: none;
    padding: 0.7rem 1.35rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 4px 12px rgba(15, 42, 74, 0.25);
}

.btn-primary-orange:hover, .btn-primary-blue:hover {
    background-color: var(--color-navy-hover);
}

.btn-blue {
    background-color: var(--color-navy-secondary);
    color: #FFFFFF;
    border: none;
    padding: 0.65rem 1.25rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-blue:hover {
    background-color: var(--color-navy-hover);
}

/* Títulos de Seção Numerados */
.section-title-navy {
    color: var(--color-navy-main);
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.3px;
    margin-bottom: 0.75rem;
}

/* Alerts & Badges */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.alert-success { background-color: #E6F8F3; color: var(--color-green-success); border: 1px solid #A3E9D5; }
.alert-danger { background-color: #FFEBEF; color: var(--color-red-danger); border: 1px solid #FFCCD5; }
.alert-info { background-color: #EFF6FF; color: var(--color-blue-accent); border: 1px solid #BFDBFE; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-success { background-color: #E6F8F3; color: var(--color-green-success); }
.badge-warning { background-color: #FFFBEB; color: #D97706; }

/* Tables */
.custom-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.custom-table th,
.custom-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
}

.custom-table th {
    background-color: #F8FAFC;
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Progress bar */
.progress-bar-container {
    background-color: #E2E8F0;
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--color-orange-main);
    border-radius: 10px;
    transition: width 0.4s ease;
}

/* Container de Tabela Responsiva com Scroll Horizontal Suave no Celular */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
}

/* Overlay Escuro para Menu Mobile Drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 42, 74, 0.6);
    backdrop-filter: blur(3px);
    z-index: 999;
}

.sidebar-backdrop.active {
    display: block;
}

/* ==========================================================================
   Responsividade Multi-Dispositivo (Smartphones, Tablets, Notebooks, Desktops)
   ========================================================================== */

/* 1. Smartphones e Celulares (< 768px) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0) !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    
    .topbar {
        padding: 0 1rem;
    }
    
    .topbar-title h1 {
        font-size: 1rem;
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .page-body {
        padding: 1rem 0.75rem;
    }
    
    .content-card {
        padding: 1rem;
        border-radius: 10px;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .kpi-card {
        padding: 1rem;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    /* Converte grids em coluna única no celular */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Otimização de toque em telas de celular (Inputs e Botões com altura mínima de 48px) */
    input[type="text"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
        font-size: 16px !important; /* Evita zoom automático no iOS Safari */
        padding: 0.85rem !important;
        min-height: 48px;
    }
    
    .btn-primary-orange, .btn-primary-blue, .btn-blue {
        min-height: 46px;
        font-size: 0.95rem;
        padding: 0.75rem 1rem;
    }
}

/* 2. Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }
    .sidebar .sidebar-brand-text,
    .sidebar .sidebar-brand-badge,
    .sidebar .sidebar-text {
        display: none;
    }
}
