/* ============================================
   Earthquakes Platform - Enhanced Styles
   Features: Dark Mode, Glassmorphism, Animations
   ============================================ */

/* CSS Variables for Theme Support */
:root {
    /* Light Theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --sidebar-bg: rgba(248, 249, 250, 0.85);
    --navbar-bg: #212529;
    --accent-color: #0d6efd;
    --accent-hover: #0b5ed7;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);

    /* Earthquake colors */
    --eq-low: #00ff00;
    --eq-medium: #ffff00;
    --eq-high: #ff9900;
    --eq-extreme: #ff0000;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #e4e4e4;
    --text-secondary: #a0a0a0;
    --text-muted: #6c6c6c;
    --border-color: #2d2d44;
    --card-bg: #1f1f38;
    --sidebar-bg: rgba(22, 33, 62, 0.9);
    --navbar-bg: #0f0f1a;
    --accent-color: #4dabf7;
    --accent-hover: #339af0;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --glass-bg: rgba(30, 30, 60, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* Global Styles */
* {
    transition: background-color var(--transition-normal),
                color var(--transition-normal),
                border-color var(--transition-normal);
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* ============================================
   Navbar Styles
   ============================================ */
.navbar {
    background-color: var(--navbar-bg) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px var(--shadow-color);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
    transition: transform var(--transition-fast);
}

.navbar-brand:hover {
    transform: scale(1.02);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.2rem;
}

.theme-toggle:hover {
    border-color: var(--accent-color);
    transform: rotate(15deg) scale(1.1);
    box-shadow: 0 0 15px var(--accent-color);
}

/* ============================================
   Sidebar with Glassmorphism
   ============================================ */
.sidebar {
    height: calc(100vh - 56px);
    overflow-y: auto;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    box-shadow: 4px 0 30px var(--shadow-color);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   Map Container
   ============================================ */
#map {
    height: calc(100vh - 56px);
    width: 100%;
    position: relative;
}

/* Dark mode map tiles adjustment */
[data-theme="dark"] #map {
    filter: brightness(0.8) contrast(1.1);
}

/* ============================================
   Loading Overlay with Better Animation
   ============================================ */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

.loading-text {
    color: white;
    margin-top: 1rem;
    font-weight: 500;
}

/* ============================================
   Cards with Glassmorphism
   ============================================ */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow-color);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px var(--shadow-color);
}

.card.bg-light {
    background: var(--glass-bg) !important;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    color: var(--text-primary);
}

/* ============================================
   Legend Styles
   ============================================ */
.legend {
    font-size: 0.875rem;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background var(--transition-fast);
}

.legend-item:hover {
    background: var(--bg-tertiary);
}

.legend-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

/* ============================================
   Statistics with Animation
   ============================================ */
#statistics p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

#statistics strong {
    color: var(--accent-color);
}

/* Animated Counter */
.stat-number {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color), #667eea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Popup Styles
   ============================================ */
.leaflet-popup-content-wrapper {
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-color);
}

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

.leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.6;
}

.popup-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.popup-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.popup-info strong {
    color: var(--text-primary);
}

.popup-magnitude {
    font-size: 1.75rem;
    font-weight: bold;
    margin: 8px 0;
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    animation: magnitudePulse 2s infinite;
}

.popup-magnitude.mag-low { background: rgba(0, 255, 0, 0.2); color: #00cc00; }
.popup-magnitude.mag-medium { background: rgba(255, 255, 0, 0.2); color: #cc9900; }
.popup-magnitude.mag-high { background: rgba(255, 153, 0, 0.2); color: #ff6600; }
.popup-magnitude.mag-extreme { background: rgba(255, 0, 0, 0.2); color: #ff0000; }

@keyframes magnitudePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ============================================
   Pulsing Markers for Recent Earthquakes
   ============================================ */
.pulse-marker {
    position: relative;
}

.pulse-marker::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: pulse 2s ease-out infinite;
    z-index: -1;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* Custom pulsing circle for Leaflet */
.leaflet-pulsing-marker {
    animation: markerPulse 1.5s ease-in-out infinite;
}

@keyframes markerPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(255, 0, 0, 0);
    }
}

/* ============================================
   Button Styles with Micro-interactions
   ============================================ */
.btn {
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), #667eea);
    border: none;
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.4);
    background: linear-gradient(135deg, var(--accent-hover), #5a67d8);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

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

/* ============================================
   Form Controls
   ============================================ */
.form-control, .form-select {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-primary);
    border-color: var(--accent-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

/* ============================================
   Modal Enhancements
   ============================================ */
.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 25px 50px var(--shadow-color);
}

.modal-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 16px 16px 0 0;
}

.modal-title {
    color: var(--text-primary);
}

.modal-body {
    max-height: 500px;
    overflow-y: auto;
    color: var(--text-primary);
}

.btn-close {
    filter: var(--text-primary);
}

[data-theme="dark"] .btn-close {
    filter: invert(1);
}

/* Earthquake Details in Modal */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.detail-row:hover {
    background: var(--bg-tertiary);
    margin: 0 -16px;
    padding: 12px 16px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.detail-value {
    color: var(--text-primary);
}

/* ============================================
   Magnitude Badge
   ============================================ */
.magnitude-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    animation: badgePop 0.3s ease-out;
}

@keyframes badgePop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.magnitude-low {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
}

.magnitude-medium {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
}

.magnitude-high {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
}

.magnitude-extreme {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #fff;
    animation: extremePulse 1s infinite;
}

@keyframes extremePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
}

/* ============================================
   Charts Tab Styles
   ============================================ */
#chartsTab {
    background-color: var(--bg-secondary);
    min-height: calc(100vh - 56px);
}

#chartsTab .card-header {
    background: transparent;
}

#chartsTab .card-header h5 {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ============================================
   Statistics Cards with Animation
   ============================================ */
#overallStats .stat-card {
    text-align: center;
    padding: 1rem;
    border-radius: 12px;
    background: var(--bg-tertiary);
    transition: transform var(--transition-fast);
}

#overallStats .stat-card:hover {
    transform: scale(1.05);
}

#overallStats h3 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

#overallStats small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Table Styles
   ============================================ */
.table {
    color: var(--text-primary);
}

.table thead th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--bg-secondary);
}

.table-hover tbody tr {
    transition: all var(--transition-fast);
    cursor: pointer;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.1);
    transform: scale(1.01);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-toast {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 40px var(--shadow-color);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    animation: toastSlideIn 0.4s ease-out;
    backdrop-filter: blur(10px);
}

.custom-toast.toast-exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-content {
    flex-grow: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

/* Toast Types */
.custom-toast.success { border-left: 4px solid #28a745; }
.custom-toast.warning { border-left: 4px solid #ffc107; }
.custom-toast.error { border-left: 4px solid #dc3545; }
.custom-toast.info { border-left: 4px solid #17a2b8; }
.custom-toast.earthquake { border-left: 4px solid #ff6600; }

/* ============================================
   Heatmap Toggle
   ============================================ */
.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 8px;
}

.map-control-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.map-control-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

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

/* ============================================
   Live Indicator
   ============================================ */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ============================================
   Skeleton Loading
   ============================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

/* ============================================
   Dropdown Styles
   ============================================ */
.dropdown-menu {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-color);
    padding: 8px;
    min-width: 180px;
}

.dropdown-item {
    color: var(--text-primary);
    border-radius: 8px;
    padding: 10px 16px;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--accent-color);
}

.dropdown-item:active {
    background: var(--accent-color);
    color: white;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        height: auto;
        max-height: 400px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    #map {
        height: calc(100vh - 456px);
        min-height: 400px;
    }

    .map-controls {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
        justify-content: center;
    }

    .toast-container {
        left: 20px;
        right: 20px;
    }

    .custom-toast {
        min-width: auto;
        max-width: none;
    }
}

/* ============================================
   Chart Container
   ============================================ */
canvas {
    max-width: 100%;
}

/* ⚠️ ...but NOT inside the map. Leaflet's panes are zero-width positioning
   contexts, so "max-width: 100%" resolves to 100% of 0 and collapses the
   canvas to 0x0. The heatmap layer drew its pixels correctly into a 960x764
   buffer and rendered as nothing at all — the button worked, the layer existed,
   the map stayed empty (ГРАБЛИ.md 2026-08-14). Inside .leaflet-container the
   library sizes its own canvases; CSS must keep its hands off. */
.leaflet-container canvas {
    max-width: none;
}

/* ============================================
   Badge Styles
   ============================================ */
.badge {
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
}

.badge.bg-danger {
    background: linear-gradient(135deg, #dc3545, #c82333) !important;
}

/* ============================================
   Nav Link Animations
   ============================================ */
.nav-link {
    position: relative;
    transition: color var(--transition-fast);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: all var(--transition-fast);
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 80%;
}

/* ============================================
   Title Animation
   ============================================ */
.card-title, h5, h6 {
    color: var(--text-primary);
}

/* ============================================
   Scrollbar for Dark Mode
   ============================================ */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
}

/* ============================================
   Storefront Hero + Site Report Modal (Этап C$)
   ============================================ */
.storefront-hero {
    background: linear-gradient(135deg, var(--accent-color), #667eea);
    color: #fff;
    padding: 0.5rem 0;
    font-size: 0.95rem;
}

.storefront-hero-price strong {
    font-size: 1.1rem;
}

#reportPreviewResult .d-flex + .d-flex {
    margin-top: 0.25rem;
}

#reportBuyBtn {
    font-weight: 600;
}
