/* ==========================================================================
   Viewdrome Atlas - Dark Theme Styles
   ========================================================================== */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-glass: rgba(26, 26, 26, 0.92);
    
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #666666;
    
    --accent-primary: #00ffcc;
    --accent-secondary: #00cc99;
    --accent-glow: rgba(0, 255, 204, 0.3);
    
    --route-color: #00ffcc;
    --route-hover: #ffffff;
    --marker-fill: #00ffcc;
    --marker-stroke: #ffffff;
    
    --border-color: #333333;
    --border-subtle: #222222;
    
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.7);
    
    --blur-amount: 12px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --font-primary: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Map Container ---------- */
#map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    z-index: 1;
}

/* Force dark background on Leaflet container */
.leaflet-container {
    background-color: var(--bg-primary) !important;
}

/* ---------- Loading Overlay ---------- */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1a2e 100%);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.loading-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 2rem;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

/* ---------- Header ---------- */
#header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, var(--bg-glass) 0%, transparent 100%);
    pointer-events: none;
}

#header > * {
    pointer-events: auto;
}

.logo-link {
    display: block;
    transition: transform var(--transition-fast);
}

.logo-link:hover {
    transform: scale(1.05);
}

.header-logo {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.tour-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ---------- Info Panel ---------- */
#info-panel {
    position: absolute;
    bottom: 2rem;
    left: 1.5rem;
    z-index: 1000;
    width: 320px;
    max-width: calc(100vw - 3rem);
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
    overflow: hidden;
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

#info-panel.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.panel-content {
    padding: 1.25rem;
}

#panel-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-right: 2rem;
    line-height: 1.3;
}

.description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: none;
}

.description:not(:empty) {
    display: block;
}

.stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.tags:empty {
    display: none;
}

.tag {
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-transform: lowercase;
}

.start-tour-btn {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--accent-primary);
    color: var(--bg-primary);
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.start-tour-btn:hover {
    background: var(--text-primary);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

/* ---------- Legend ---------- */
#legend {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-line {
    width: 20px;
    height: 3px;
    background: var(--route-color);
    border-radius: 2px;
}

.legend-marker {
    width: 10px;
    height: 10px;
    background: var(--marker-fill);
    border: 2px solid var(--marker-stroke);
    border-radius: 50%;
}

/* ---------- Leaflet Customizations ---------- */

/* Popup Styling */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-strong);
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
    font-size: 0.875rem;
}

.leaflet-popup-tip {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.leaflet-popup-close-button {
    color: var(--text-muted) !important;
    font-size: 1.25rem !important;
    padding: 0.5rem !important;
}

.leaflet-popup-close-button:hover {
    color: var(--text-primary) !important;
}

/* Zoom Controls */
.leaflet-control-zoom {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
    box-shadow: var(--shadow-soft) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 1rem !important;
}

.leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-tertiary) !important;
    color: var(--accent-primary) !important;
}

/* Attribution */
.leaflet-control-attribution {
    background: var(--bg-glass) !important;
    color: var(--text-muted) !important;
    font-size: 0.625rem !important;
    padding: 0.25rem 0.5rem !important;
    border-radius: var(--radius-sm) 0 0 0 !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    #header {
        padding: 0.75rem 1rem;
    }
    
    .header-logo {
        height: 28px;
    }
    
    .header-title h1 {
        font-size: 1rem;
    }
    
    #info-panel {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        width: auto;
        max-width: none;
    }
    
    #legend {
        bottom: 1rem;
        right: 1rem;
    }
}

@media (max-width: 480px) {
    .header-title {
        display: none;
    }
    
    #legend {
        display: none;
    }
}
