/* Charts Styles — Dashboard + Camera Detail */

/* Collapsible charts section (dashboard) */
.charts-section {
    margin: 0 24px 16px;
}

.charts-toggle {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1a56db;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.charts-toggle:hover {
    background: #f9fafb;
}

.charts-toggle::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    transition: transform 0.2s;
}

.charts-section.open .charts-toggle::before {
    transform: rotate(90deg);
}

.charts-content {
    display: none;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 12px 16px;
}

.charts-section.open .charts-content {
    display: block;
}

.charts-section.open .charts-toggle {
    border-radius: 8px 8px 0 0;
}

/* Individual chart container */
.chart-container {
    background: #ffffff;
    border-radius: 4px;
}

.chart-wrapper {
    position: relative;
    height: 260px;
}

/* Camera detail charts — full width stacked */
.camera-charts-container {
    padding: 16px 24px 24px;
}

.camera-chart-block {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.camera-chart-block:last-child {
    margin-bottom: 0;
}

.camera-chart-block h3 {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 12px 0;
}

.camera-chart-wrapper {
    position: relative;
    height: 280px;
}

/* Chart loading/empty states */
.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    font-size: 13px;
}

/* =============================================
   MAP SECTION (dashboard)
   ============================================= */
.map-section {
    margin: 0 24px 16px;
}

.map-toggle {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1a56db;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.map-toggle:hover {
    background: #f9fafb;
}

.map-toggle::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    transition: transform 0.2s;
}

.map-section.open .map-toggle::before {
    transform: rotate(90deg);
}

.map-content {
    display: none;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 12px 16px;
}

.map-section.open .map-content {
    display: block;
}

.map-section.open .map-toggle {
    border-radius: 8px 8px 0 0;
}

#camera-map {
    height: 400px;
    border-radius: 8px;
    z-index: 1;
}

/* Map popup styles */
.map-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 12px;
    line-height: 1.4;
}

.map-popup-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.map-popup-name a {
    color: #1a56db;
    text-decoration: none;
}

.map-popup-name a:hover {
    text-decoration: underline;
}

.map-popup-client {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
}

.map-popup-status {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 6px;
}

.map-popup-status.online {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
}

.map-popup-status.offline {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.map-popup-metrics {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
    font-size: 11px;
    color: #374151;
}

.map-popup-health {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #374151;
}

.map-popup-health .health-badge {
    width: 24px;
    height: 24px;
    font-size: 9px;
}

/* Responsive — tablet */
@media (max-width: 768px) {
    .charts-section {
        margin: 0 12px 10px;
    }

    .charts-toggle {
        font-size: 12px;
        padding: 10px 12px;
    }

    .charts-content {
        padding: 12px;
    }

    .chart-wrapper {
        height: 220px;
    }

    .camera-charts-container {
        padding: 12px 16px 16px;
    }

    .camera-chart-wrapper {
        height: 220px;
    }

    .camera-chart-block {
        padding: 12px;
        margin-bottom: 12px;
    }

    .map-section {
        margin: 0 12px 10px;
    }

    .map-toggle {
        font-size: 12px;
        padding: 10px 12px;
    }

    .map-content {
        padding: 12px;
    }

    #camera-map {
        height: 300px;
    }
}

/* Responsive — phone */
@media (max-width: 480px) {
    .charts-section {
        margin: 0 10px 8px;
    }

    .chart-wrapper {
        height: 200px;
    }

    .chart-container {
        padding: 4px;
    }

    .camera-charts-container {
        padding: 8px 10px 10px;
    }

    .camera-chart-wrapper {
        height: 180px;
    }

    .camera-chart-block {
        padding: 10px;
        margin-bottom: 8px;
    }

    .camera-chart-block h3 {
        font-size: 12px;
    }

    .map-section {
        margin: 0 10px 8px;
    }

    #camera-map {
        height: 250px;
    }
}

/* =============================================
   DARK MODE
   ============================================= */
[data-theme="dark"] .chart-container,
[data-theme="dark"] .camera-chart-block {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .chart-card h3 {
    color: #e2e8f0;
}

[data-theme="dark"] .charts-toggle {
    background: #1e293b;
    color: #60a5fa;
    border-color: #334155;
}

[data-theme="dark"] .charts-toggle:hover {
    background: #334155;
}

[data-theme="dark"] .chart-legend {
    color: #94a3b8;
}

/* Dark Mode: Map Section */
[data-theme="dark"] .map-toggle {
    background: #1e293b;
    color: #60a5fa;
    border-color: #334155;
}

[data-theme="dark"] .map-toggle:hover {
    background: #334155;
}

[data-theme="dark"] .map-content {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .map-popup-name a {
    color: #60a5fa;
}

[data-theme="dark"] .map-popup-metrics {
    color: #cbd5e1;
}

[data-theme="dark"] .map-popup-health {
    color: #cbd5e1;
}

/* Dark mode Leaflet popup overrides */
[data-theme="dark"] .leaflet-popup-content-wrapper {
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 3px 14px rgba(0,0,0,0.5);
}

[data-theme="dark"] .leaflet-popup-tip {
    background: #1e293b;
}

[data-theme="dark"] .leaflet-popup-close-button {
    color: #94a3b8;
}

[data-theme="dark"] .map-popup-client {
    color: #94a3b8;
}

[data-theme="dark"] .map-popup-status.online {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

[data-theme="dark"] .map-popup-status.offline {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}
