@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap');

:root {
    --bg-light: #f8fafc;
    --bg-lighter: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --accent: #dc2626; /* Red matching logo */
    --accent-hover: #b91c1c;
    
    --alarm-high: #ef4444; /* Keep red for high alarm */
    --alarm-low: #0ea5e9;  /* Sky blue for low alarm */
    --normal: #10b981;     /* Green */
    --offline: #94a3b8;    /* Slate */
}

html.dark-theme {
    --bg-light: #0b0f19;
    --bg-lighter: #111827;
    --glass-bg: rgba(17, 24, 39, 0.82);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
}

html.dark-theme body {
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(220, 38, 38, 0.12), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(14, 165, 233, 0.08), transparent 25%);
}

html.dark-theme .form-input {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

html.dark-theme .form-input:focus {
    background: rgba(255, 255, 255, 0.08);
}

/* Override login page */
html.dark-theme .login-box {
    background: rgba(17, 24, 39, 0.82);
    border-color: rgba(255, 255, 255, 0.08);
}

/* Override nav hover which uses hardcoded white */
html.dark-theme .nav-item:hover,
html.dark-theme .nav-item.active {
    background-color: rgba(255, 255, 255, 0.06);
}

/* Override .report-card and similar component cards */
html.dark-theme .report-card {
    background: rgba(17, 24, 39, 0.5);
    border-color: rgba(255, 255, 255, 0.06);
}

html.dark-theme .report-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Override accordion items in Informes */
html.dark-theme .accordion-year {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(220, 38, 38, 0.12);
}

html.dark-theme .accordion-year[open] {
    background: rgba(220, 38, 38, 0.04);
}

html.dark-theme .accordion-month {
    background: rgba(255, 255, 255, 0.02);
}

html.dark-theme .accordion-month[open] {
    background: rgba(220, 38, 38, 0.02);
}

/* WiFi form container */
html.dark-theme .wifi-container {
    background: var(--glass-bg);
    border-color: var(--glass-border);
}

html.dark-theme .input-wrapper .input-icon {
    color: var(--text-muted);
}



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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(220, 38, 38, 0.06), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(14, 165, 233, 0.04), transparent 25%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
    color: var(--text-main);
}

/* Login Page Specifics */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    text-align: center;
}

.login-logo {
    width: 80px;
    margin-bottom: 20px;
    filter: drop-shadow(0px 0px 10px rgba(0,0,0,0.1));
}

.login-box h1 {
    margin-bottom: 30px;
    font-size: 1.8rem;
    letter-spacing: 1px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.1s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.error-msg {
    color: var(--alarm-high);
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
}

/* ============================================
   SKELETON LOADERS
   ============================================ */
.skeleton-card {
    position: relative;
    padding: 15px;
    aspect-ratio: 1/1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.skeleton-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.04) 40%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 60%,
        transparent 100%
    );
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-ring {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 20px solid rgba(255, 255, 255, 0.05);
}

@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================
   CASCADE ENTRANCE ANIMATION
   ============================================ */
.sensor-card {
    opacity: 0;
    transform: translateY(24px);
    animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   HERO STATUS SUMMARY PANEL
   ============================================ */
.hero-status {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.hero-status-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 160px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hero-status-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.hero-status-item .status-count {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.hero-status-item.status-ok {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--normal);
}

.hero-status-item.status-alarm {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--alarm-high);
}

.hero-status-item.status-low {
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.25);
    color: var(--alarm-low);
}

.hero-status-item.status-offline {
    background: rgba(100, 116, 139, 0.12);
    border: 1px solid rgba(100, 116, 139, 0.25);
    color: var(--offline);
}

/* ============================================
   SPARKLINE (MICRO-TREND CHART)
   ============================================ */
.sparkline-container {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 30px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.sensor-card:hover .sparkline-container {
    opacity: 1;
}

.sparkline-line {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.sparkline-area {
    opacity: 0.15;
}

/* ============================================
   ROLLING NUMBER ANIMATION
   ============================================ */
.rolling-number {
    transition: opacity 0.15s ease;
}

.rolling-number.updating {
    opacity: 0.5;
}

/* ============================================
   CHART DASHBOARD & FILTERS
   ============================================ */
.chart-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.filters-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 200px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Ubicaciones a la izquierda + grafico/filtros a la derecha (PC/tablet ancha).
   En pantallas angostas (celular, tablet en vertical) se apila arriba. */
.chart-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.locations-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px;
}

.locations-sidebar > label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.locations-sidebar .checkbox-list-container {
    max-height: none;
    overflow-y: visible;
    border: none;
    background: transparent;
    padding: 0;
    min-width: 0;
}

.sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.export-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px;
}

.export-panel > label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.export-actions {
    display: flex;
    gap: 8px;
}

.chart-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

@media (min-width: 900px) {
    .chart-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    .sidebar-column {
        flex: 0 0 240px;
    }
    .chart-main {
        flex: 1 1 0%;
    }
}

.chart-container {
    position: relative;
    height: 60vh;
    padding: 24px;
    min-height: 400px;
    background: var(--bg-lighter);
}

.no-data-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 8px;
    border: 1px dashed var(--glass-border);
    max-width: 80%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

/* ============================================
   CHART MODAL (Popup from Sensor Card)
   ============================================ */
.chart-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chart-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.chart-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    width: 90vw;
    max-width: 960px;
    height: 75vh;
    max-height: 620px;
    z-index: 2001;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.3s ease;
    overflow: hidden;
}

.chart-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.chart-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.chart-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-modal-title .modal-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(220, 38, 38, 0.1);
    color: var(--accent);
}

.chart-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chart-modal-close:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--accent);
}

.chart-modal-filters {
    display: flex;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--glass-border);
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.chart-modal-filters label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}

.chart-modal-filters input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--text-main);
    background: var(--bg-lighter);
    transition: border-color 0.2s ease;
}

.chart-modal-filters input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.chart-modal-body {
    flex: 1;
    position: relative;
    padding: 16px 24px 24px;
    min-height: 0;
}

.chart-modal-body canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-modal-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    z-index: 5;
    transition: opacity 0.3s ease;
}

.chart-modal-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.chart-modal-nodata {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.chart-modal-nodata.visible {
    display: flex;
}

@media (max-width: 600px) {
    .chart-modal {
        width: 96vw;
        height: 85vh;
        max-height: none;
    }
    .chart-modal-header { padding: 12px 16px; }
    .chart-modal-filters { padding: 8px 16px; }
    .chart-modal-body { padding: 12px 16px 16px; }
}

/* Modal action buttons for PDF/Excel export */
.modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-main);
}

.modal-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

/* Location checklist inside Filters Panel */
.checkbox-list-container {
    max-height: 130px;
    overflow-y: auto;
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Grid adjustment for filters panel on desktop to fit checkboxes */
@media (min-width: 900px) {
    .filters-panel {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        align-items: end;
    }
}




