:root {
    --bg-main: #0B0E14;
    --bg-panel: rgba(22, 27, 34, 0.6);
    --bg-panel-hover: rgba(32, 38, 48, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #F0F6FC;
    --text-muted: #8B949E;
    --accent-primary: #00FF88;
    --accent-secondary: #00B8FF;
    --accent-tertiary: #FF007F;
    --success: #2EA043;
    --warning: #D29922;
    --danger: #F85149;
    --font-main: 'Outfit', sans-serif;
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(0, 255, 136, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(0, 184, 255, 0.05), transparent 25%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-glass);
    transition: transform 0.3s ease, background 0.3s ease;
}

.glass-panel:hover {
    background: var(--bg-panel-hover);
    transform: translateY(-2px);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(11, 14, 20, 0.95);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.sidebar-header {
    padding: 30px 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 24px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px var(--accent-primary));
}

.logo h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logo h2 span {
    color: var(--accent-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 0 15px;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sidebar-nav a:hover, .sidebar-nav li.active a {
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent-primary);
}

.sidebar-nav li.active a {
    position: relative;
}

.sidebar-nav li.active a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 10px var(--accent-primary);
}

.user-profile {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-main);
}

.user-info .name {
    font-weight: 600;
    font-size: 14px;
}

.user-info .role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: rgba(11, 14, 20, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px 20px;
    width: 300px;
}

.search-bar i {
    color: var(--text-muted);
    margin-right: 10px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 100%;
    font-family: var(--font-main);
}

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

.date-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-panel);
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.glass-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-main);
    padding: 5px;
    outline: none;
    color-scheme: dark;
}

.glass-input option {
    color: #1a1a1a;
    background: #ffffff;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #00d672);
    color: var(--bg-main);
    border: none;
    padding: 8px 20px;
    border-radius: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: var(--font-main);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 136, 0.4);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 8px 15px;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dashboard Content */
.dashboard-content {
    padding: 40px;
}

.welcome-section {
    margin-bottom: 30px;
}

.welcome-section h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 5px;
}

.welcome-section p {
    color: var(--text-muted);
}

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

.kpi-card {
    padding: 25px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.kpi-icon.energy { background: rgba(0, 255, 136, 0.15); color: var(--accent-primary); }
.kpi-icon.revenue { background: rgba(0, 184, 255, 0.15); color: var(--accent-secondary); }
.kpi-icon.sessions { background: rgba(255, 0, 127, 0.15); color: var(--accent-tertiary); }
.kpi-icon.stations { background: rgba(210, 153, 34, 0.15); color: var(--warning); }

.kpi-details h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.kpi-details h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.trend {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.trend.positive { color: var(--success); }
.trend.neutral { color: var(--text-muted); }

/* Charts */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.chart-body {
    flex: 1;
    position: relative;
    min-height: 250px;
}

/* Table */
.table-container {
    padding: 20px;
}

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

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

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

th, td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.status-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
}

.status-completed { background: rgba(46, 160, 67, 0.2); color: var(--success); }

/* Loader */
.loader-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11, 14, 20, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
.hide-on-desktop {
    display: none;
}

@media (max-width: 1024px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-main);
    background-image: radial-gradient(circle at center, rgba(0, 255, 136, 0.05), transparent 50%);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border: 1px solid rgba(0, 255, 136, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 255, 136, 0.1);
}
.login-card .glass-input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    transition: border-color 0.3s;
}
.login-card .glass-input:focus {
    border-color: var(--accent-primary);
}

.mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    
    .main-content { 
        margin-left: 0; 
        padding-bottom: 80px; /* Espaço para não esconder nada atrás da barra */
    }
    
    /* Grid de KPIs empilhado */
    .kpi-grid { grid-template-columns: 1fr; }
    
    .topbar {
        padding: 15px;
        flex-direction: column;
        gap: 15px;
        padding-top: 25px; /* Mais espaço pro topo */
    }
    
    .hide-on-desktop {
        display: flex;
        justify-content: center;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .topbar-mobile-logo .brand-logo-img {
        max-width: 100%;
        width: 100%;
        height: 80px;
        border-radius: 8px;
        object-fit: contain;
        background: #0B0E14;
    }
    
    .search-bar { width: 100%; }
    
    /* Filtros Organizados e Profissionais no Celular */
    .topbar-actions {
        width: 100%;
    }
    
    .date-filter { 
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
        background: transparent;
        padding: 0;
    }
    
    .date-filter select {
        grid-column: 1 / -1;
        width: 100%;
        margin: 0 !important;
    }
    
    .date-filter span {
        display: none; /* Remove o 'até' para economizar espaço em tela pequena */
    }
    
    .date-filter input {
        width: 100%;
        margin: 0 !important;
    }
    
    .date-filter button {
        grid-column: 1 / -1;
        width: 100%;
        padding: 15px;
        font-size: 16px;
        margin-top: 5px;
    }
    
    .dashboard-content {
        padding: 15px;
    }
    
    #stationsMap {
        height: 350px !important;
    }

    /* Barra de Navegação Inferior estilo App */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(11, 14, 20, 0.95);
        backdrop-filter: blur(15px);
        border-top: 1px solid var(--glass-border);
        z-index: 1000;
        justify-content: space-around;
        padding: 12px 0;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 10px));
        box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    }
    
    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 11px;
        font-weight: 500;
        gap: 5px;
        transition: all 0.3s ease;
    }
    
    .mobile-nav a i {
        font-size: 20px;
    }
    
    .mobile-nav a.active {
        color: var(--accent-primary);
        transform: translateY(-3px);
    }
}

/* Print optimizations */
@media print {
    /* Esconde absolutamente tudo na tela exceto a div de impressão */
    body * {
        visibility: hidden;
    }
    
    #view-reports.active, #view-reports.active * {
        visibility: visible;
    }
    
    #view-users.active, #view-users.active * {
        visibility: visible;
    }
    
    .print-only-header {
        display: block !important;
    }
    
    .hide-on-print, .welcome-section {
        display: none !important;
        visibility: hidden !important;
    }

    #reportDocument, #reportDocumentUsers {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    body, .app-container, .main-content {
        background: #fff !important;
        background-image: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
}

/* =========================================
   POWERHUB LOGOTYPE (IMAGEM OFICIAL)
   ========================================= */
.brand-logo-img {
    width: 100%;
    max-width: 200px;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 0 12px rgba(0, 184, 255, 0.6))
            drop-shadow(0 0 25px rgba(0, 184, 255, 0.3));
}

.brand-logo-img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 18px rgba(0, 184, 255, 0.9))
            drop-shadow(0 0 35px rgba(0, 184, 255, 0.5));
}
