:root {
    --bg-main: #0B0E14;
    --bg-glass: rgba(22, 27, 34, 0.65);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    
    /* Niveles de prioridad */
    --color-caliente: #E24B4A;
    --color-tibio: #EF9F27;
    --color-frio: #378ADD;
    --color-descartar: #888780;
    
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    /* Optional: una imagen sutil de fondo para el glassmorphism */
    background-image: radial-gradient(circle at top right, rgba(88, 166, 255, 0.1), transparent 400px),
                      radial-gradient(circle at bottom left, rgba(226, 75, 74, 0.05), transparent 400px);
}

.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
}

.app-container {
    display: flex;
    height: 100vh;
    padding: 16px;
    gap: 16px;
}

/* Sidebar */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-glass);
}

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

.logo-icon {
    font-size: 28px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #fff, #8b949e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-content {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Stats */
.stats-container h3, .legend-container h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.stat-card:hover {
    background: rgba(255,255,255,0.05);
    transform: translateY(-1px);
}

.caliente { border-left: 4px solid var(--color-caliente); }
.tibio { border-left: 4px solid var(--color-tibio); }
.frio { border-left: 4px solid var(--color-frio); }
.descartar { border-left: 4px solid var(--color-descartar); }

.stat-label {
    font-size: 13px;
    font-weight: 500;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
}

/* Legend */
.legend-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-list li {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 12px;
    display: inline-block;
}

.bg-caliente { background-color: var(--color-caliente); box-shadow: 0 0 8px rgba(226,75,74,0.5); }
.bg-tibio { background-color: var(--color-tibio); box-shadow: 0 0 8px rgba(239,159,39,0.5); }
.bg-frio { background-color: var(--color-frio); box-shadow: 0 0 8px rgba(55,138,221,0.5); }
.bg-descartar { background-color: var(--color-descartar); }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    height: 72px;
    box-shadow: var(--shadow-sm);
}

.topbar h2 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 4px rgba(88, 166, 255, 0.2);
}

.btn-primary:hover {
    background-color: #3182ce;
    transform: translateY(-1px);
}

.map-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    background-color: #1a1e27; /* Fallback antes de cargar */
}

/* Leaflet Customizations for Dark Mode */
.leaflet-container {
    background: #1a1e27 !important;
    font-family: 'Inter', sans-serif;
}

.leaflet-popup-content-wrapper {
    background: rgba(22, 27, 34, 0.95) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary) !important;
    border-radius: 12px;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-popup-tip {
    background: rgba(22, 27, 34, 0.95) !important;
}

.popup-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.popup-header h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #fff;
}

.popup-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.popup-level.caliente { background: rgba(226,75,74,0.1); color: var(--color-caliente); }
.popup-level.tibio { background: rgba(239,159,39,0.1); color: var(--color-tibio); }
.popup-level.frio { background: rgba(55,138,221,0.1); color: var(--color-frio); }
.popup-level.descartar { background: rgba(136,135,128,0.1); color: var(--color-descartar); }

.popup-score {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.popup-action {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    background: rgba(255,255,255,0.03);
    padding: 8px;
    border-radius: 6px;
}

.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11, 14, 20, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 15px;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Leaflet Tile dark filter (cheap Dark mode map) */
.leaflet-layer,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-control-attribution {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}
