/* ============================================
   FloodWatch WebGIS — Main Styles
   Philippine Flood Monitoring System
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
    /* Primary Palette — Ocean/Water Theme */
    --primary: #2196F3;
    --primary-dark: #1565C0;
    --primary-light: #64B5F6;
    --primary-glow: rgba(33, 150, 243, 0.4);
    --accent: #00BCD4;
    --accent-dark: #00838F;

    /* Alert Colors */
    --alert-red: #ef4444;
    --alert-orange: #f97316;
    --alert-yellow: #eab308;
    --alert-green: #22c55e;

    /* Backgrounds — Dark Theme */
    --bg-primary: #0a0e17;
    --bg-secondary: #0f1724;
    --bg-card: #162032;
    --bg-hover: #1e2d45;
    --bg-input: #1a2740;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders */
    --border-color: rgba(33, 150, 243, 0.15);
    --border-strong: rgba(33, 150, 243, 0.3);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(33, 150, 243, 0.2);

    /* Layout */
    --topbar-height: 56px;
    --sidebar-width: 320px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ---------- Loading Screen ---------- */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loading-content {
    text-align: center;
}
.loading-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    font-size: 36px;
    color: #fff;
    animation: loadingPulse 2s ease-in-out infinite;
}
.loading-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.loading-subtitle {
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 14px;
}
.loading-bar-container {
    width: 260px;
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    margin: 28px auto 12px;
    overflow: hidden;
}
.loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    transition: width 0.3s ease;
}
.loading-status {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ---------- Top Navigation Bar ---------- */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 260px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    font-size: 18px;
    color: #fff;
}
.brand-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}
.brand-subtitle {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Alert Ticker */
.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 24px;
}
.alert-ticker {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 20px;
    max-width: 500px;
    overflow: hidden;
}
.ticker-icon {
    color: var(--alert-red);
    font-size: 12px;
    animation: tickerPulse 2s ease-in-out infinite;
}
.ticker-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stat Badges */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.stat-badges {
    display: flex;
    gap: 8px;
}
.stat-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 12px;
    cursor: default;
}
.stat-badge i {
    font-size: 11px;
}
.stat-badge.critical i { color: var(--primary); }
.stat-badge.warning i { color: var(--alert-yellow); }
.stat-badge.danger i { color: var(--alert-red); }
.stat-value {
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}
.stat-label {
    color: var(--text-muted);
    font-size: 10px;
}

/* Action Buttons */
.topbar-actions {
    display: flex;
    gap: 4px;
}
.action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
}
.action-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
    border-color: var(--border-strong);
}

/* ---------- Map Container ---------- */
.map-container {
    position: fixed;
    top: var(--topbar-height);
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    transition: left var(--transition-base);
}
.sidebar-collapsed .map-container,
body.sidebar-collapsed .map-container {
    left: 0;
}

/* Override Mapbox controls */
.mapboxgl-ctrl-group {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-md) !important;
}
.mapboxgl-ctrl-group button {
    background: transparent !important;
    color: var(--text-primary) !important;
}
.mapboxgl-ctrl-group button:hover {
    background: var(--bg-hover) !important;
}
.mapboxgl-ctrl-group button + button {
    border-top: 1px solid var(--border-color) !important;
}
.mapboxgl-ctrl-attrib {
    background: rgba(10, 14, 23, 0.7) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
}
.mapboxgl-ctrl-attrib a {
    color: var(--text-secondary) !important;
}
.mapboxgl-ctrl-scale {
    background: rgba(10, 14, 23, 0.7) !important;
    color: var(--text-secondary) !important;
    border-color: var(--text-secondary) !important;
    font-size: 10px !important;
}

/* Geocoder Override */
.mapboxgl-ctrl-geocoder {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-md) !important;
    font-family: 'Inter', sans-serif !important;
    min-width: 280px !important;
}
.mapboxgl-ctrl-geocoder input {
    color: var(--text-primary) !important;
    font-size: 13px !important;
}
.mapboxgl-ctrl-geocoder input::placeholder {
    color: var(--text-muted) !important;
}
.mapboxgl-ctrl-geocoder .suggestions {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
}
.mapboxgl-ctrl-geocoder .suggestions > li > a {
    color: var(--text-primary) !important;
    font-size: 13px !important;
}
.mapboxgl-ctrl-geocoder .suggestions > .active > a,
.mapboxgl-ctrl-geocoder .suggestions > li > a:hover {
    background: var(--bg-hover) !important;
}
.mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--icon-search {
    fill: var(--text-muted) !important;
}

/* ---------- Map Tools ---------- */
.map-tools {
    position: fixed;
    top: calc(var(--topbar-height) + 60px);
    right: 16px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: var(--shadow-lg);
}
.tool-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
}
.tool-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
}
.tool-btn.active {
    background: var(--primary);
    color: #fff;
}
.tool-divider {
    height: 1px;
    background: var(--border-color);
    margin: 2px 6px;
}

/* ---------- Basemap Switcher ---------- */
.basemap-switcher {
    position: fixed;
    bottom: 40px;
    right: 16px;
    z-index: 500;
    display: flex;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-lg);
}
.basemap-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.basemap-option:hover {
    background: var(--bg-hover);
}
.basemap-option.active {
    background: var(--bg-hover);
}
.basemap-option.active .basemap-preview {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}
.basemap-preview {
    width: 48px;
    height: 32px;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    transition: all var(--transition-fast);
}
.basemap-preview.dark { background: #1a1a2e; }
.basemap-preview.satellite { background: linear-gradient(135deg, #2d5a27, #1a3a1a); }
.basemap-preview.terrain { background: linear-gradient(135deg, #b8c6a7, #8fa87f); }
.basemap-preview.light { background: #e8e8e8; }
.basemap-option span {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- Coordinate Display ---------- */
.coord-display {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    padding: 4px 14px;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.coord-sep {
    color: var(--text-muted);
    margin: 0 6px;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}
.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}
.modal-container {
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform var(--transition-base);
}
.modal-overlay.visible .modal-container {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-header h3 i {
    color: var(--primary);
}
.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.modal-close:hover {
    background: var(--bg-hover);
    color: var(--alert-red);
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

/* About Modal Specific */
.about-content {
    text-align: center;
}
.about-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    font-size: 28px;
    color: #fff;
}
.about-content h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}
.about-desc {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    max-width: 440px;
    margin: 0 auto 24px;
}
.about-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    text-align: left;
}
.about-feature {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.about-feature i {
    font-size: 20px;
    color: var(--primary);
    margin-top: 2px;
}
.about-feature strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}
.about-feature p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.about-sources {
    text-align: left;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.about-sources h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--primary-light);
}
.about-sources ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.about-sources li {
    font-size: 12px;
    color: var(--text-secondary);
    padding-left: 16px;
    position: relative;
}
.about-sources li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
}

/* ---------- Flood Detail Modal ---------- */
.flood-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.flood-detail-item {
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.flood-detail-item .label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.flood-detail-item .value {
    font-size: 14px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}
.flood-detail-item.full-width {
    grid-column: span 2;
}

/* Alert level indicators in modal */
.alert-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.alert-indicator.red { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.alert-indicator.orange { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.alert-indicator.yellow { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.alert-indicator.green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

/* ---------- Mapbox Popup Override ---------- */
.mapboxgl-popup-content {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    padding: 14px 16px !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 13px !important;
    min-width: 220px !important;
}
.mapboxgl-popup-tip {
    border-top-color: var(--bg-card) !important;
}
.mapboxgl-popup-close-button {
    color: var(--text-secondary) !important;
    font-size: 18px !important;
    right: 6px !important;
    top: 4px !important;
}
.mapboxgl-popup-close-button:hover {
    color: var(--text-primary) !important;
    background: transparent !important;
}
.popup-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.popup-title i { color: var(--primary); }
.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 12px;
}
.popup-row:last-child { border: none; }
.popup-row .label { color: var(--text-muted); }
.popup-row .value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}
