:root {
    --bg-main: #04080f;
    --bg-panel: rgba(8, 14, 28, 0.85);
    --bg-panel-hover: rgba(12, 22, 42, 0.92);
    --glass-border: rgba(26, 111, 212, 0.2);
    --glass-border-hover: rgba(26, 111, 212, 0.5);
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --accent-primary: #FF0033;
    --accent-blue: #1A6FD4;
    --accent-blue-dark: #0A4FA8;
    --accent-secondary: #CC0029;
    --accent-tertiary: #2A8AFF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --font-main: 'Outfit', 'Inter', sans-serif;
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 1px 1px 0 rgba(255, 255, 255, 0.07);
}

* {
    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 10% 20%, rgba(26, 111, 212, 0.1), transparent 35%),
        radial-gradient(circle at 90% 80%, rgba(255, 0, 51, 0.08), transparent 35%),
        radial-gradient(circle at 50% 50%, rgba(10, 79, 168, 0.05), transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

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

.glass-panel:hover {
    background: var(--bg-panel-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(26, 111, 212, 0.2), inset 0 1px 1px 0 rgba(255, 255, 255, 0.1);
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(4, 10, 22, 0.97);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(26, 111, 212, 0.2);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.6);
}

.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;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 51, 0.25);
    border-radius: 10px;
}

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

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 15px;
    color: rgba(241, 245, 249, 0.65);
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-nav a:hover, .sidebar-nav li.active a {
    background: rgba(26, 111, 212, 0.18);
    color: #ffffff;
    border: 1px solid rgba(26, 111, 212, 0.35);
}

.sidebar-nav li.active a {
    position: relative;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(26, 111, 212, 0.3);
}

.sidebar-nav li.active a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 22px;
    background: linear-gradient(to bottom, #1A6FD4, #FF0033);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 12px rgba(26, 111, 212, 0.7);
}

.user-profile {
    padding: 20px;
    border-top: 1px solid rgba(255, 0, 51, 0.15);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background 0.2s;
}

.user-profile:hover {
    background: rgba(255, 0, 51, 0.08);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1A6FD4, #FF0033);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 16px;
    box-shadow: 0 0 12px rgba(26, 111, 212, 0.5);
}

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

.user-info .role {
    font-size: 12px;
    color: var(--accent-primary);
    font-weight: 500;
}

/* 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: 18px 40px;
    background: rgba(6, 9, 14, 0.88);
    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: rgba(13, 18, 27, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px 20px;
    width: 320px;
    transition: all 0.3s;
}

.search-bar:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.3);
}

.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: rgba(13, 18, 27, 0.9);
    padding: 6px 14px;
    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;
}

.btn-primary {
    background: linear-gradient(135deg, #FF0033, #1A6FD4);
    color: #ffffff;
    border: none;
    padding: 10px 22px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(26, 111, 212, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26, 111, 212, 0.5), 0 4px 10px rgba(255, 0, 51, 0.3);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(30, 58, 95, 0.07);
    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(30, 58, 95, 0.14);
}

.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;
    min-height: 80vh;
}

.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(255, 0, 51, 0.15); color: #FF0033; box-shadow: 0 0 15px rgba(255, 0, 51, 0.25); }
.kpi-icon.revenue { background: rgba(255, 51, 85, 0.15); color: #FF3355; box-shadow: 0 0 15px rgba(255, 51, 85, 0.25); }
.kpi-icon.sessions { background: rgba(168, 85, 247, 0.15); color: #C084FC; box-shadow: 0 0 15px rgba(168, 85, 247, 0.25); }
.kpi-icon.stations { background: rgba(16, 185, 129, 0.15); color: #34D399; box-shadow: 0 0 15px rgba(16, 185, 129, 0.25); }

.kpi-details h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.kpi-details h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(180deg, #FFFFFF 0%, #CBD5E1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.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;
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    padding: 24px;
    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: 24px;
}

.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: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 700;
    background: rgba(13, 18, 27, 0.4);
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: rgba(26, 111, 212, 0.07);
}

.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(238, 244, 251, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 0, 50, 0.2);
    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: #EEF4FB;
    background-image: radial-gradient(circle at center, rgba(0, 102, 204, 0.08), transparent 55%);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border: 1px solid rgba(0,102,204,0.2);
    box-shadow: 0 10px 40px rgba(30,58,95,0.15), 0 0 20px rgba(0,102,204,0.08);
}
.login-card .glass-input {
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(0,102,204,0.2);
    transition: border-color 0.3s;
    border-radius: 8px;
    padding: 10px;
    width: 100%;
}
.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: #EEF4FB;
    }
    
    .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(238, 244, 251, 0.97);
        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 -4px 20px rgba(30,58,95,0.12);
    }
    
    .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-csms-reports.active, #view-csms-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, #csmsReportDocument {
        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;
    }
    
}

/* =========================================
   WX SOLUTIONS 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(26, 111, 212, 0.4))
            drop-shadow(0 0 20px rgba(255, 0, 51, 0.2));
}

.brand-logo-img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 18px rgba(26, 111, 212, 0.7))
            drop-shadow(0 0 30px rgba(255, 0, 51, 0.4));
}

/* Status Dot Pulse Animations */
@keyframes pulse-green {
    0% { box-shadow: 0 0 4px #10b981, 0 0 8px #10b981; }
    50% { box-shadow: 0 0 8px #10b981, 0 0 16px #10b981, 0 0 24px rgba(16, 185, 129, 0.3); }
    100% { box-shadow: 0 0 4px #10b981, 0 0 8px #10b981; }
}

@keyframes pulse-orange {
    0% { box-shadow: 0 0 4px #f59e0b, 0 0 8px #f59e0b; }
    50% { box-shadow: 0 0 8px #f59e0b, 0 0 16px #f59e0b, 0 0 24px rgba(245, 158, 11, 0.3); }
    100% { box-shadow: 0 0 4px #f59e0b, 0 0 8px #f59e0b; }
}



/* =========================================
   PTZ CAMERA MONITORING STYLES
   ========================================= */

.ptz-live-dot {
    width: 10px;
    height: 10px;
    background-color: #FF0033;
    border-radius: 50%;
    box-shadow: 0 0 10px #FF0033;
    display: inline-block;
    animation: blink-dot 1s infinite alternate;
}

@keyframes blink-dot {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.4; transform: scale(0.8); }
}

.ptz-canvas-box {
    position: relative;
    width: 100%;
    height: 260px;
    background: #04080f;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
}

.ptz-hud-top-left {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 11px;
    color: #00FF88;
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.ptz-hud-top-right {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 11px;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ptz-hud-bot-left {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 11px;
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ptz-expand-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: linear-gradient(135deg, #FF0033, #1A6FD4);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 0, 51, 0.4);
    transition: all 0.2s ease;
}

.ptz-expand-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.2);
}

.ptz-quick-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ptz-btn-group {
    display: flex;
    gap: 6px;
}

.active-ptz-mode {
    background: linear-gradient(135deg, #FF0033, #1A6FD4) !important;
    color: white !important;
    border: none !important;
}

/* D-PAD Joystick Styling */
.ptz-dpad-wrapper {
    position: relative;
    width: 170px;
    height: 170px;
    margin: 0 auto;
}

.dpad-btn {
    position: absolute;
    width: 48px;
    height: 48px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.dpad-btn:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.6);
}

.dpad-up { top: 0; left: 61px; }
.dpad-down { bottom: 0; left: 61px; }
.dpad-left { top: 61px; left: 0; }
.dpad-right { top: 61px; right: 0; }
.dpad-center { top: 61px; left: 61px; border-radius: 50%; background: rgba(26, 111, 212, 0.8); border-color: #38BDF8; }

/* Camera Reticle Overlay */
.ptz-reticle-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reticle-center {
    width: 80px;
    height: 80px;
    border: 1px dashed rgba(255, 0, 51, 0.4);
    border-radius: 50%;
}

.reticle-crosshair-v {
    position: absolute;
    width: 1px;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
}

.reticle-crosshair-h {
    position: absolute;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}
