/**
 * Earthquake Tracker - Main Stylesheet
 * Modern Dark Theme with Responsive Design
 */

/* CSS Variables */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #3b82f6;
    --accent-secondary: #06b6d4;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --radius: 8px;
    --radius-lg: 12px;
    
    /* Magnitude Colors */
    --mag-minor: #22c55e;
    --mag-light: #eab308;
    --mag-moderate: #f97316;
    --mag-strong: #ef4444;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* RTL Support */
[dir="rtl"] {
    direction: rtl;
}

[dir="rtl"] .lang-selector {
    direction: ltr;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-secondary);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Language Selector */
.lang-selector {
    position: relative;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.lang-current:hover {
    background-color: var(--border-color);
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    display: none;
    z-index: 1001;
}

.lang-dropdown.active {
    display: block;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.lang-option:hover {
    background-color: var(--bg-tertiary);
}

.lang-option:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.lang-option:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Main Content */
.main {
    padding: 2rem 0;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.filter-select {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Map Container */
.map-section {
    margin-bottom: 2rem;
}

.map-container {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.map-title {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.map-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.map-btn {
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.map-btn:hover {
    background-color: var(--border-color);
}

.map-btn.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

#world-map, #detail-map {
    height: 500px;
    width: 100%;
}

#detail-map {
    height: 400px;
}

/* Map Legend */
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    justify-content: center;
}

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

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

/* Earthquake Table */
.table-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-container {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.earthquake-table {
    width: 100%;
    border-collapse: collapse;
}

.earthquake-table th,
.earthquake-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.earthquake-table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
}

.earthquake-table tr:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

.earthquake-table a {
    color: var(--text-primary);
}

.earthquake-table a:hover {
    color: var(--accent-primary);
}

/* Magnitude Badge */
.mag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
}

.mag-minor { background-color: var(--mag-minor); }
.mag-light { background-color: var(--mag-light); color: #000; }
.mag-moderate { background-color: var(--mag-moderate); }
.mag-strong { background-color: var(--mag-strong); }

/* Time Badge */
.time-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Depth Indicator */
.depth-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.depth-bar {
    width: 60px;
    height: 6px;
    background-color: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.depth-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
}

/* Detail Page */
.detail-header {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.detail-magnitude {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.detail-location {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.detail-card h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.detail-card .value {
    font-size: 1.5rem;
    font-weight: 600;
}

.detail-card .unit {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Subscription Form */
.subscribe-section {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.subscribe-section h2 {
    margin-bottom: 0.5rem;
}

.subscribe-section p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.subscribe-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
}

.subscribe-form input {
    flex: 1;
    min-width: 250px;
    padding: 0.75rem 1rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

.subscribe-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn-primary {
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Alert Messages */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background-color: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--mag-minor);
    color: var(--mag-minor);
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--mag-strong);
    color: var(--mag-strong);
}

/* Ad Placements */
.ad-container {
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
    overflow: hidden;
}

.ad-leaderboard {
    width: 100%;
    max-width: 728px;
    height: 90px;
    margin: 1.5rem auto;
}

.ad-rectangle {
    width: 100%;
    max-width: 300px;
    height: 250px;
    margin: 1.5rem auto;
}

.ad-skyscraper {
    width: 300px;
    height: 600px;
}

.ad-label {
    font-size: 0.625rem;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.25rem;
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-links a:hover {
    color: var(--text-primary);
}

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

/* Breadcrumb */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--accent-primary);
}

.breadcrumb-separator {
    color: var(--text-muted);
}

.breadcrumb-current {
    color: var(--text-primary);
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
}

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

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

/* Error State */
.error-message {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.error-message i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

/* No Data */
.no-data {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-select {
        width: 100%;
    }
    
    #world-map, #detail-map {
        height: 350px;
    }
    
    .earthquake-table th,
    .earthquake-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
    
    .detail-magnitude {
        font-size: 3rem;
    }
    
    .detail-location {
        font-size: 1.25rem;
    }
    
    .subscribe-form {
        flex-direction: column;
    }
    
    .subscribe-form input {
        min-width: 100%;
    }
    
    .ad-leaderboard {
        height: auto;
        min-height: 50px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .main {
        padding: 1rem 0;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 1.25rem;
    }
    
    .detail-magnitude {
        font-size: 2.5rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .ad-container,
    .subscribe-section,
    .map-controls {
        display: none !important;
    }
    
    .main {
        padding: 0;
    }
    
    .detail-card {
        break-inside: avoid;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Styles */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background-color: var(--accent-primary);
    color: white;
}
