:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #38bdf8;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --font-main: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #0f172a;
}

#globe {
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #0f172a;
    display: none;
}

#globe.active {
    display: block;
}

#map.hidden {
    display: none;
}

/* Shake Animation for Big Earthquakes */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

#app.shaking {
    animation: shake 0.5s ease-in-out;
}

/* View Toggle Button */
.view-toggle {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1001;
    pointer-events: auto;
}

.view-toggle-btn {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-color);
    padding: 0.75rem 1rem;
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.view-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.view-toggle-btn svg {
    width: 18px;
    height: 18px;
}

.view-toggle-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
}

/* UI Overlay */
.overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    pointer-events: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    width: fit-content;
    margin-bottom: 1rem;
    min-width: 300px;
}

header h1 {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--success-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.version-badge {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: monospace;
    letter-spacing: 0.05em;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Sidebar */
.sidebar {
    width: 360px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 200px);
    margin-bottom: 1rem;
}

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

.sidebar-header h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.filters {
    display: flex;
    gap: 0.5rem;
}

select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 0.875rem;
    outline: none;
    cursor: pointer;
    flex: 1;
}

select:hover {
    background: rgba(255, 255, 255, 0.1);
}

select option {
    background: var(--bg-color);
    color: var(--text-color);
}

.quake-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.quake-item {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.quake-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mag-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.quake-info {
    flex: 1;
    min-width: 0;
}

.quake-place {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.quake-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Scrollbar */
.quake-list::-webkit-scrollbar {
    width: 6px;
}

.quake-list::-webkit-scrollbar-track {
    background: transparent;
}

.quake-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.quake-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Firefox Scrollbar */
.quake-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Playback Controls */
.playback-controls {
    margin-top: auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    max-width: 800px;
    align-self: center;
}

.play-btn {
    background: var(--accent-color);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: #0f172a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.play-btn:hover {
    transform: scale(1.05);
    background: #7dd3fc;
}

.play-btn svg {
    width: 24px;
    height: 24px;
}

.timeline-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.date-display {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--accent-color);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--text-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.audio-toggle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.audio-toggle input {
    margin-right: 0.5rem;
}

/* Leaflet Customization */
.leaflet-popup-content-wrapper {
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.leaflet-popup-tip {
    background: var(--bg-color);
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-muted);
}

.custom-popup .place {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

.custom-popup .detail {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.25rem;
}

.custom-popup .mag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* Custom Div Icon Styles */
.custom-div-icon {
    background: transparent;
    border: none;
}

.quake-dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.quake-dot:hover {
    transform: scale(1.2);
    cursor: pointer;
    border-color: #fff;
}

/* Marker Animations & Glow */
.marker-glow-low {
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.marker-glow-med {
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.7);
}

.marker-pulse-high {
    position: relative;
}

.marker-pulse-high::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    transform: translate(-50%, -50%);
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    z-index: -1;
}

.marker-pulse-extreme {
    position: relative;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.9);
}

.marker-pulse-extreme::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    transform: translate(-50%, -50%);
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    z-index: -1;
}

@keyframes pulse-ring {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.8;
    }

    100% {
        width: 300%;
        height: 300%;
        opacity: 0;
    }
}

.leaflet-interactive {
    transition: r 0.3s ease-out;
    transform-box: fill-box;
}

/* Statistics Dashboard */
.stats-dashboard {
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
}

.dashboard-toggle {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.dashboard-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.toggle-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.dashboard-toggle.active .toggle-icon {
    transform: rotate(180deg);
}

.dashboard-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.dashboard-content.open {
    max-height: 500px;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0 1rem 1rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 0.75rem;
    text-align: center;
    border: 1px solid var(--glass-border);
}

.stat-card .stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
}

.chart-section {
    padding: 0 1rem 1rem;
}

.chart-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 60px;
    padding: 0 4px;
}

.bar-chart .bar {
    flex: 1;
    min-width: 0;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s ease;
    position: relative;
}

.bar-chart .bar:hover {
    filter: brightness(1.2);
}

.bar-chart .bar::after {
    content: attr(data-count);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
    padding-bottom: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.bar-chart .bar:hover::after {
    opacity: 1;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.legend-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.regions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.region-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.region-rank {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    color: var(--bg-color);
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.region-name {
    flex: 1;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.region-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Marker Cluster Styling */
.marker-cluster {
    background: rgba(15, 23, 42, 0.8) !important;
    border: 2px solid var(--accent-color) !important;
}

.marker-cluster div {
    background: transparent !important;
    color: var(--text-color) !important;
    font-family: var(--font-main) !important;
    font-weight: 600 !important;
}

.marker-cluster-small {
    background: rgba(16, 185, 129, 0.3) !important;
    border-color: #10b981 !important;
}

.marker-cluster-small div {
    background: rgba(16, 185, 129, 0.7) !important;
}

.marker-cluster-medium {
    background: rgba(234, 179, 8, 0.3) !important;
    border-color: #eab308 !important;
}

.marker-cluster-medium div {
    background: rgba(234, 179, 8, 0.7) !important;
}

.marker-cluster-large {
    background: rgba(239, 68, 68, 0.3) !important;
    border-color: #ef4444 !important;
}

.marker-cluster-large div {
    background: rgba(239, 68, 68, 0.7) !important;
}

.stats-footer {
    display: none;
}