/* =========================================
   1. BASE STYLES & MAIN LAYOUT
   ========================================= */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: Arial, sans-serif;
}

#map {
    height: 100vh;
    width: 100vw;
    z-index: 1; /* Keep map beneath the controls */
}

:root {
    --bg-dark: rgba(25, 28, 36, 0.90);
    --bg-panel: rgba(25, 28, 36, 0.80);
    --text-primary: #ecf0f1;
    --text-secondary: #a4b0be;
    --accent-red: #ff6b81;
    --border-subtle: rgba(255, 255, 255, 0.15);
}

/* Example implementation */
.nav-btn {
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    /* ... */
}

/* Custom webkit scrollbars for standard overflow areas */
.volcano-summary::-webkit-scrollbar,
#modal-list::-webkit-scrollbar {
    width: 6px;
}

.volcano-summary::-webkit-scrollbar-track,
#modal-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2); 
}

.volcano-summary::-webkit-scrollbar-thumb,
#modal-list::-webkit-scrollbar-thumb {
    background: #576574; 
    border-radius: 3px;
}

/* =========================================
   2. TOP NAVIGATION CONTROLS
   ========================================= */
/* Center the buttons at the top of the map */
#top-nav-buttons {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 10px;
}

/* Compact, scalable button design */
.nav-btn {
    background: rgba(25, 28, 36, 0.90);
    color: #ecf0f1;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    
    /* Target scale constraints */
    min-width: 60px; 
    min-height: 50px;
    transition: all 0.2s ease;
}

.nav-btn i {
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: #a4b0be;
}

.nav-btn span {
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
}

.nav-btn:hover {
    background: #2f3640;
    border-color: #ff6b81;
}

.nav-btn:hover i, .nav-btn:hover span {
    color: #ff6b81; /* Accent color on hover */
}

/* =========================================
   3. MAP UI: TIME MACHINE & SLIDERS
   ========================================= */
#time-machine-panel {
    position: absolute;
    bottom: 30px;
    left: 10px;
    z-index: 1000;
    margin-bottom: 30px; /* Push the panel up to make room for MousePosition coordinates */

    /* Dark, semi-transparent dashboard background */
    background: rgba(25, 28, 36, 0.80); 
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.6); 
    border: 1px solid rgba(255, 255, 255, 0.1);
    
    width: 33vw; 
    min-width: 380px; 
    max-width: 600px;
    color: #ecf0f1; 
}

#time-machine-panel h4 {
    margin: 0 0 10px 0;
    color: #ff6b81; /* Brighter accent red for dark mode */
    font-size: 1.2rem;
}

.slider-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Boundary Input Boxes */
.bound-group {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.4); /* Dark inset look */
    border: 1px solid #4b4b4b;
    border-radius: 4px;
    overflow: hidden;
}

.year-input {
    width: 45px;
    padding: 4px 2px 4px 6px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #f1f2f6; 
    border: none;
    background: transparent;
    text-align: right;
}

.year-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.1);
}

.era-select {
    border: none;
    border-left: 1px solid #4b4b4b;
    background: #2f3640; 
    padding: 5px 2px;
    font-size: 0.75rem;
    font-weight: bold;
    color: #f1f2f6;
    cursor: pointer;
    outline: none;
}

/* Hide up/down arrows natively */
.year-input::-webkit-inner-spin-button, 
.year-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.year-input { -moz-appearance: textfield; }

/* Dual-Handle Range Slider */
.dual-slider-wrapper {
    position: relative;
    flex-grow: 1;
    margin: 0 15px;
    height: 30px;
    display: flex;
    align-items: center;
}

.slider-track {
    position: absolute;
    width: 100%;
    height: 6px;
    background: #576574; /* Darker track */
    border-radius: 3px;
    z-index: 1;
}

.dual-slider-wrapper input[type="range"] {
    position: absolute;
    width: 100%;
    -webkit-appearance: none;
    background: transparent;
    pointer-events: none; 
    z-index: 2;
}

/* Custom Thumbs for Dark Mode */
.dual-slider-wrapper input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #ff4757; /* Vibrant red thumb */
    border: 2px solid #2f3640; /* Dark outline */
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.dual-slider-wrapper input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 18px;
    height: 18px;
    background: #ff4757;
    border: 2px solid #2f3640;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

/* =========================================
   4. LEAFLET OVERRIDES: POPUPS & LEGENDS
   ========================================= */

/* Override Leaflet's default white bubble */
.leaflet-popup-content-wrapper {
    background: rgba(25, 28, 36, 0.90) !important; /* Dark, semi-transparent */
    color: #ecf0f1 !important;
    padding: 0; 
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Color the little pointer arrow to match the dark wrapper */
.leaflet-popup-tip {
    background: rgba(25, 28, 36, 0.90) !important;
    box-shadow: none !important;
}

/* Make the default 'X' close button white and visible */
.leaflet-popup-close-button {
    color: #ffffff !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    padding: 4px 10px 0 0 !important;
}
.leaflet-popup-close-button:hover {
    color: #ff6b81 !important; /* Accent red on hover */
}

.leaflet-popup-content {
    margin: 0;
    width: 280px !important; 
}

/* The Volcano static header */
.volcano-popup-header {
    background-color: rgba(179, 57, 57, 0.95); /* Deep transparent red */
    color: white;
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.volcano-popup-header h3 { margin: 0; font-size: 1.3rem; font-weight: bold; }
.volcano-popup-header p { margin: 3px 0 0 0; font-size: 0.85rem; font-style: italic; opacity: 0.9; }

/* The dark transparent popup body */
.volcano-popup-body {
    padding: 15px;
    background-color: transparent; 
}

.volcano-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

/* Dark inset grid boxes matching Time Machine inputs */
.stat-box {
    background: rgba(0, 0, 0, 0.4); 
    padding: 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.stat-label {
    display: block;
    font-weight: bold;
    color: #a4b0be; 
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.stat-value {
    color: #ecf0f1; 
    font-weight: bold;
}

/* Summary text specific to volcanoes */
.volcano-summary {
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.85rem;
    color: #dcdde1; 
    line-height: 1.4;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Native Leaflet Legend */
.volcano-legend {
    background: rgba(25, 28, 36, 0.80); 
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ecf0f1; 
    font-size: 0.85rem;
    line-height: 1.5;
}

.volcano-legend h4 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    color: #ff6b81; 
    text-transform: uppercase;
    border-bottom: 1px solid #4b4b4b; 
    padding-bottom: 5px;
}

.legend-item { display: flex; align-items: center; margin-bottom: 6px; }
.legend-item:last-child { margin-bottom: 0; }
.legend-item i {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(255,255,255,0.2); 
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Leaflet Panel Layers Override */
.leaflet-control.leaflet-panel-layers {
    background: rgba(25, 28, 36, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 8px !important;
    box-shadow: 0 6px 12px rgba(0,0,0,0.6) !important;
    color: #ecf0f1 !important;
}

.leaflet-panel-layers-base, .leaflet-panel-layers-overlays { background: transparent !important; }
.leaflet-panel-layers-title { color: #ecf0f1 !important; border-bottom: 1px solid #4b4b4b !important; }

.leaflet-panel-layers-grouplabel {
    background: #2f3640 !important; 
    color: #ff6b81 !important;
    border-top: 1px solid #4b4b4b !important;
    border-bottom: 1px solid #4b4b4b !important;
}

.leaflet-panel-layers-group { background: #191c24 !important; }
.leaflet-panel-layers-item {
    background: #191c24 !important; 
    color: #ecf0f1 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}
.leaflet-panel-layers-item:last-child { border-bottom: none !important; }
.leaflet-panel-layers-item:hover { background: #2f3640 !important; }
.leaflet-panel-layers-icon { filter: invert(1) brightness(0.9) !important; }

/* =========================================
   5. OVERLAYS & MODALS
   ========================================= */

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(25, 28, 36, 0.80); 
    padding: 15px 25px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1); 
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 2000; 
    transition: opacity 0.4s ease;
}

.loading-text { font-family: Arial, sans-serif; color: #ecf0f1; }
.loading-text strong { font-size: 1rem; color: #ff6b81; }
.loading-text span { font-size: 0.8rem; color: #a4b0be; }
.fade-out { opacity: 0; pointer-events: none; }

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #4b4b4b; 
    border-top: 3px solid #ff6b81; 
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Document Modal Styling */
#doc-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: rgba(25, 28, 36, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
    width: 320px;
    max-width: 90vw;
    padding: 20px;
    color: #ecf0f1;
    display: none; 
}

#doc-modal.modal-visible { display: block; }

.close-modal {
    float: right;
    cursor: pointer;
    font-size: 1.5rem;
    color: #a4b0be;
    line-height: 1;
}
.close-modal:hover { color: #ff6b81; }

#modal-title {
    margin: 0 0 15px 0;
    border-bottom: 1px solid #4b4b4b;
    padding-bottom: 10px;
    color: #ff6b81;
    font-size: 1.2rem;
    text-align: center; 
}

#modal-list {
    padding-left: 0; /* Removes default browser indentation for lists */
    list-style: none;
}

#modal-list li {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Changed from center to left-justify */
}

#modal-list i { margin-right: 10px; color: #74b9ff; }
#modal-list a {
    color: #ecf0f1;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
#modal-list a:hover { color: #74b9ff; text-decoration: underline; }

.modal-section-header {
    color: #a4b0be;
    font-size: 1rem;
    text-transform: uppercase;
    margin: 15px 0 5px 0;
    display: block;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    width: 100%;
    padding-bottom: 3px;
    text-align: left; /* Keeps the header aligned with your newly left-justified links */
}

.modal-doc-link {
    color: #ecf0f1; 
    text-decoration: none; 
    font-size: 0.9rem; 
    transition: color 0.2s; 
}

.modal-doc-link:hover { 
    color: #74b9ff;
}


/* Photo Viewer Modal & Icons */
.volcano-photo-icon {
    margin-left: 10px; 
    cursor: pointer;
    color: #f1f2f6;
    font-size: 1.1rem;
    vertical-align: baseline;
    transition: color 0.2s ease, transform 0.2s ease;
}

.volcano-photo-icon:hover {
    color: #fdcb6e; 
    transform: scale(1.15);
}

#photo-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2500; 
    background: rgba(25, 28, 36, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.9);
    width: 90vw;
    max-width: 650px;
    padding: 20px 20px 25px 20px;
    color: #ecf0f1;
    display: none;
}

#photo-modal.modal-visible { display: block; }

.close-photo-modal {
    position: absolute;
    top: -15px;
    right: -15px;
    background: #e84118;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.6);
    border: 2px solid #191c24;
    transition: background 0.2s;
}

.close-photo-modal:hover { background: #c23616; }

.photo-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#modal-photo {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
    background: #000; 
    margin-bottom: 12px;
}

.photo-info { text-align: center; width: 100%; }
#modal-photo-credit { font-size: 0.75rem; color: #a4b0be; margin: 0 0 10px 0; font-style: italic; }
#modal-photo-caption { font-size: 0.95rem; color: #ecf0f1; line-height: 1.5; margin: 0; }