:root {
    /* Color Palette */
    --bg-dark: #121212;
    --text-main: #f0f0f0;
    --text-muted: #a0a0a0;
    --glass-bg: rgba(26, 26, 26, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    /* Earthquake Colors */
    --color-low: #f1c40f;    /* < 4 */
    --color-med: #e67e22;    /* 4 - 6 */
    --color-high: #e74c3c;   /* >= 6 */
    --color-live: #f39c12;   /* Gold for live */
    
    /* Layout */
    --sidebar-width: 35%;
    --z-map: 10;
    --z-overlay: 100;
    --z-sidebar: 200;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

/* Layout */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

#map-section {
    position: relative;
    flex-grow: 1;
    height: 100%;
}

#map {
    height: 100%;
    width: 100%;
    z-index: var(--z-map);
    background-color: #1a1a1a;
}

/* Glassmorphism Components */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Sidebar & Table */
#sidebar {
    width: var(--sidebar-width);
    min-width: 350px;
    max-width: 450px;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform 0.3s ease-in-out;
}

#sidebar header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

#sidebar h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.table-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
}

.table-container::-webkit-scrollbar {
    width: 6px;
}
.table-container::-webkit-scrollbar-thumb {
    background-color: var(--glass-border);
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

th {
    position: sticky;
    top: 0;
    background: rgba(26, 26, 26, 0.95);
    font-weight: 600;
    color: var(--text-muted);
    z-index: 2;
}

tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

tbody tr:hover, tbody tr:focus {
    background-color: rgba(255, 255, 255, 0.1);
    outline: none;
}

.depth-val { color: var(--text-muted); font-size: 0.8rem; }

/* Mobile Toggle */
#mobile-toggle {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-overlay);
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    color: white;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--glass-border);
}

/* Overlays (Loading & Error) */
#loading-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-overlay);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: opacity 0.3s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--text-main);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.toast {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: var(--z-overlay);
    background: #c0392b;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.hidden {
    transform: translateY(150%);
    opacity: 0;
}

/* Live Indicators & Animations */
.pulse-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--color-live);
    font-weight: 700;
    text-transform: uppercase;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-live);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.live-star-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--color-live);
    font-size: 24px;
    filter: drop-shadow(0 0 8px rgba(243, 156, 18, 0.8));
    animation: starPulse 2s infinite ease-in-out;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0.7); } 70% { box-shadow: 0 0 0 6px rgba(243, 156, 18, 0); } 100% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0); } }
@keyframes starPulse { 0% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.4); opacity: 1; } 100% { transform: scale(1); opacity: 0.8; } }

/* Leaflet Dark Theme Overrides */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: rgba(26, 26, 26, 0.95) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-content h3 { margin: 0 0 8px 0; border-bottom: 1px solid #333; padding-bottom: 4px; font-size: 1.1rem; }
.leaflet-popup-content p { margin: 4px 0; font-size: 0.9rem; }
.leaflet-popup-content a { color: #3498db; text-decoration: none; font-weight: bold; }
.leaflet-popup-content a:hover { text-decoration: underline; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-main); }

/* Marker Clusters Overrides */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
    background-color: rgba(255, 255, 255, 0.2);
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
    background-color: rgba(26, 26, 26, 0.9);
    color: white;
    font-family: 'Montserrat', sans-serif;
    font-weight: bold;
}

/* Responsive */
@media (max-width: 768px) {
    #app-container {
        flex-direction: column;
    }

    #map-section {
        height: 50vh; /* Restricts the map to the top half of the screen */
        flex-grow: 0;
        flex-shrink: 0;
    }
    
    #sidebar {
        position: relative; /* Removes the absolute positioning */
        bottom: auto;
        left: auto;
        width: 100%;
        max-width: 100%;
        height: 50vh; /* List takes up the bottom half */
        transform: none !important; /* Prevents the JS from hiding it when a row is clicked */
        border-radius: 0;
        border-top: 1px solid var(--glass-border);
    }
    
    #mobile-toggle {
        display: none !important; /* Hides the button completely */
    }
    
    .leaflet-control-zoom {
        display: none;
    }
}