/* ============================================================
   RESET & BASE
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #eee;
    overflow: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(79,195,247,0.5); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(79,195,247,0.7); }

/* ============================================================
   MAP (full viewport)
   ============================================================ */
#map {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
}

#logo-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1100;
}

#logo-container img {
    height: 50px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* ============================================================
   ICON BAR  (top-right)
   z-index > Leaflet controls (Leaflet uses up to ~1000)
   ============================================================ */
#icon-bar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.icon-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(26, 26, 46, 0.95);
    color: #ccc;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}

.icon-btn .icon-glyph {
    font-size: 18px;
    line-height: 1;
}

.icon-btn:hover {
    background: rgba(79, 195, 247, 0.2);
    border-color: #4fc3f7;
    color: #4fc3f7;
}

.icon-btn.is-active {
    background: rgba(79, 195, 247, 0.25);
    border-color: #4fc3f7;
    color: #4fc3f7;
}

/* Module badge (small pill above/beside icon) */
.icon-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #4fc3f7;
    color: #1a1a2e;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    line-height: 1;
}

/* Snapshot button – loading state */
#btn-snapshot.is-capturing {
    background: rgba(255, 193, 7, 0.2);
    border-color: #ffc107;
    color: #ffc107;
    animation: pulse 0.8s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.7; }
    to   { opacity: 1.0; }
}

/* ============================================================
   FLOATING PANELS  (shared base)
   Panels open to the left of the icon bar.
   z-index must be > Leaflet (1000) but ≤ icon bar (1100).
   ============================================================ */
.floating-panel {
    position: absolute;
    top: 10px;
    right: 64px;            /* icon-bar width (44px) + 10px gap + 10px page margin */
    z-index: 1050;
    width: 260px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: rgba(26, 26, 46, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    /* Entrance animation */
    animation: panelFadeIn 0.2s ease;
}

@keyframes panelFadeIn {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0);   }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    font-weight: 600;
    color: #4fc3f7;
    position: sticky;
    top: 0;
    background: rgba(26, 26, 46, 0.97);
    border-radius: 10px 10px 0 0;
    z-index: 1;
}

.panel-close {
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    transition: color 0.2s;
    line-height: 1;
}

.panel-close:hover { color: #ef5350; }

.panel-body {
    padding: 12px;
}

/* ============================================================
   CONTROL GROUP (shared label + control layout)
   ============================================================ */
.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: block;
    font-size: 11px;
    color: #aaa;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

.control-group select:focus {
    outline: none;
    border-color: #4fc3f7;
}

.control-group select option {
    background: #1a1a2e;
    color: #fff;
}

/* ============================================================
   CSS TOGGLE SWITCH  (Changes 1 & 2)
   Pill-shaped sliding toggle, consistent with dark theme.
   ============================================================ */
.toggle-row {
    margin-bottom: 10px;
}

.toggle-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

/* .control-group label sets display:block which would break the flex layout;
   this rule restores flex for any toggle wrapper that lives inside a control-group. */
.control-group .toggle-switch-wrapper {
    display: flex;
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: inherit;
    color: inherit;
}

/* The visible switch track */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #4a4a5e;   /* clearly-visible dark-indigo track; contrast with thumb */
    border-radius: 20px;
    transition: background 0.25s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: #ccc;
    border-radius: 50%;
    transition: transform 0.25s ease, background 0.25s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: #4fc3f7;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: #fff;
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid #4fc3f7;
    outline-offset: 2px;
}

.toggle-label {
    font-size: 12px;
    color: #ccc;
    white-space: nowrap;
}

/* ── Filter info tooltip (the "?" badge next to "Filtered" label) ── */
.filter-info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 5px;
    border-radius: 50%;
    background: #555;
    color: #ddd;
    font-size: 10px;
    font-weight: bold;
    cursor: default;
    position: relative;
    vertical-align: middle;
    line-height: 1;
    user-select: none;
}

.filter-info-tip:hover {
    background: #888;
}

.filter-info-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    padding: 10px 12px;
    background: #1e2a38;
    color: #dce4ef;
    font-size: 11px;
    line-height: 1.55;
    border: 1px solid #3a4f64;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    pointer-events: none;
    white-space: normal;
    z-index: 1200;
    font-weight: normal;
}

/* Arrow pointing down */
.filter-info-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #3a4f64;
}

.filter-info-tip:hover .filter-info-popup {
    display: block;
}

/* ============================================================
   MODULE A – RADAR CHECKBOXES
   ============================================================ */
.checkbox-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.checkbox-container {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    padding: 8px;
    max-height: 220px;
    overflow-y: auto;
}

#radar-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.radar-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: 3px;
    transition: background 0.2s;
}

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

.radar-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.radar-checkbox-item label {
    flex: 1;
    margin: 0;
    font-size: 12px;
    color: #eee;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
}

/* Radar status dot */
.radar-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.radar-status-active   { background-color: #66bb6a; box-shadow: 0 0 4px rgba(102,187,106,0.6); }
.radar-status-inactive { background-color: #ef5350; }

/* Dim inactive radar rows */
.radar-inactive { opacity: 0.5; }

/* ============================================================
   MODULE C – TIME WINDOW BUTTONS
   ============================================================ */
.time-window-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.time-window-btn {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: #eee;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.time-window-btn:hover {
    background: rgba(79,195,247,0.2);
    border-color: #4fc3f7;
    color: #fff;
}

.time-window-btn.active {
    background: rgba(79,195,247,0.25);
    border-color: #4fc3f7;
    color: #4fc3f7;
    font-weight: 600;
}

/* "Custom range..." link-style button */
.custom-range-toggle {
    text-align: center;
    margin-bottom: 10px;
}

.link-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px;
    transition: color 0.2s;
}

.link-btn:hover { color: #4fc3f7; }

/* Custom time range inputs */
.timerange-container {
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
}

.timerange-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-label {
    font-size: 10px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.datetime-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}

.datetime-input:focus {
    outline: none;
    border-color: #4fc3f7;
    background: rgba(79,195,247,0.1);
}

.datetime-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* ── Custom range: date input + iOS-style time wheel ── */
.dt-hidden { display: none !important; }

.dt-date {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}
.dt-date:focus {
    outline: none;
    border-color: #4fc3f7;
    background: rgba(79,195,247,0.1);
}
.dt-date::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

.time-wheel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 108px;            /* 3 rows × 36px */
    margin-top: 4px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    user-select: none;
    overflow: hidden;
}
.tw-col {
    height: 108px;
    width: 52px;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;
    /* fade top/bottom rows for a wheel feel */
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
            mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}
.tw-col::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.tw-list { padding: 36px 0; }       /* allow first/last item to center */
.tw-item {
    height: 36px;
    line-height: 36px;
    text-align: center;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    color: #8a8a99;
    scroll-snap-align: center;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
}
.tw-item.tw-active { color: #fff; font-weight: 700; transform: scale(1.12); }
.tw-sep { font-size: 20px; font-weight: 700; color: #fff; padding-bottom: 2px; }
.tw-selection {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 36px;
    height: 36px;
    border-top: 1px solid rgba(79,195,247,0.45);
    border-bottom: 1px solid rgba(79,195,247,0.45);
    background: rgba(79,195,247,0.08);
    border-radius: 4px;
    pointer-events: none;
}

/* ============================================================
   Fix 6: COVERAGE CONTROLS GROUP (inside settings panel)
   ============================================================ */
.coverage-controls {
    border-top: 1px solid rgba(255,255,255,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 8px 0;
    margin-bottom: 10px;
}

/* ============================================================
   Fix 7: COG BROWSER CONTROL PANEL
   Restores positioning lost during frontend restructuring.
   ============================================================ */
#control-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1050;
    width: 280px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: rgba(26, 26, 46, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 12px;
}

/* ============================================================
   SETTINGS PANEL (floating, same base as .floating-panel)
   ============================================================ */
.settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 12px;
}

.settings-row label {
    color: #aaa;
    flex: 1;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
    margin-bottom: 0;
    display: inline;
}

.settings-row input[type="number"] {
    width: 56px;
    padding: 4px 6px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 12px;
}

.settings-row input[type="number"]:focus {
    outline: none;
    border-color: #4fc3f7;
}

/* Settings section header: section title + small icon-only refresh button side by side */
.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    margin-top: 8px;
    font-size: 12px;
    color: #aaa;
}

.settings-section-header span {
    cursor: default;
}

/* Sub-row: number input + "min" label + Save button */
.settings-row-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
}

.settings-row-sub input[type="number"] {
    width: 52px;
    padding: 4px 6px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 12px;
}

.settings-row-sub input[type="number"]:focus {
    outline: none;
    border-color: #4fc3f7;
}

.settings-unit {
    font-size: 11px;
    color: #888;
    flex-shrink: 0;
}

/* Small icon-only refresh button used in settings section headers */
.icon-refresh-btn {
    width: 22px;
    height: 22px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: #ccc;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.2s;
}

.icon-refresh-btn:hover { background: rgba(79,195,247,0.3); border-color: #4fc3f7; color: #fff; }

.settings-info {
    font-size: 11px;
    color: #777;
    flex-wrap: wrap;
}

.settings-info span {
    line-height: 1.4;
}

code {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    padding: 1px 4px;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #81d4fa;
}

/* ============================================================
   SNAPSHOT ERROR  (shown near icon bar)
   ============================================================ */
.snapshot-error {
    position: absolute;
    top: 60px;
    right: 64px;
    z-index: 1200;
    background: rgba(244, 67, 54, 0.9);
    color: #fff;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    max-width: 200px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    animation: panelFadeIn 0.2s ease;
}

/* ============================================================
   MESSAGE AREA — inside animation controls, centered at bottom.
   ============================================================ */

#message-area {
    position: relative;
    margin-top: 8px;
    width: 100%;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    background: rgba(26,26,46,0.92);
    color: #cfd8dc;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#message-area.visible  { opacity: 1; }
#message-area.loading  { color: #ffa726; background: rgba(255,167,38,0.08); border-radius: 4px; }
#message-area.error    { color: #ef5350; background: rgba(244,67,54,0.12); border-radius: 4px; }
#message-area.success  { color: #66bb6a; }

/* ============================================================
   STATUS NOTIFICATION (legacy element; now hidden)
   ============================================================ */
.status-notification {
    position: absolute;
    top: auto;
    bottom: auto;
    right: 64px;
    top: 10px;
    z-index: 1080;
    max-width: 280px;
    font-size: 11px;
    color: #888;
    text-align: right;
    padding: 0;
    pointer-events: none;
    /* Positioned just below the icon bar panels */
    top: calc(5 * 44px + 5 * 6px + 10px + 10px);
}

.status-notification.loading { color: #ffa726; }
.status-notification.error   { color: #ef5350; }
.status-notification.success { color: #66bb6a; }

.status-notification.loading::before {
    content: '⟳ ';
    animation: spin 1s linear infinite;
    display: inline-block;
}

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

/* ============================================================
   SHARED BUTTONS
   ============================================================ */
.small-btn {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.small-btn:hover {
    background: rgba(79,195,247,0.3);
    border-color: #4fc3f7;
}

.action-btn {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(79,195,247,0.5);
    border-radius: 4px;
    background: rgba(79,195,247,0.2);
    color: #4fc3f7;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn.secondary {
    border-color: rgba(156,39,176,0.5);
    background: rgba(156,39,176,0.2);
    color: #ba68c8;
}

.action-btn:hover:not(:disabled) {
    background: rgba(79,195,247,0.3);
    border-color: #4fc3f7;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(79,195,247,0.3);
}

.action-btn.secondary:hover:not(:disabled) {
    background: rgba(156,39,176,0.3);
    border-color: #ba68c8;
}

.action-btn:active:not(:disabled) { transform: translateY(0); }

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: #888;
}

/* ============================================================
   COLORMAP & RANGE CONTROLS  (Module B)
   ============================================================ */
.range-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.range-label {
    font-size: 11px;
    color: #aaa;
    width: 28px;
    flex-shrink: 0;
}

.range-input {
    /* Capped width so the box isn't full-panel-wide; sits left next to its label. */
    flex: 0 1 96px;
    max-width: 96px;
    padding: 5px 7px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    min-width: 0;
}

/* Colormap picker only — narrower than the full-width product/basemap selects. */
#colormap-select {
    width: auto;
    max-width: 100%;
}

/* ============================================================
   FIELD-MENU COLLAPSIBLE SECTIONS (accordion, Module B)
   ============================================================ */
.field-section {
    border-top: 1px solid rgba(255,255,255,0.08);
}
.field-section-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 2px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
}
.field-section-header:hover { color: #4fc3f7; }
.field-section-title { display: inline-flex; align-items: center; gap: 6px; }
/* Right-pointing triangle; rotates to point down when the section is open. */
.field-section-chevron {
    width: 0; height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}
.field-section.open .field-section-chevron { transform: rotate(90deg); }
.field-section-body { display: none; padding-bottom: 6px; }
.field-section.open .field-section-body { display: block; }
/* Unavailable for the selected field: grayed + non-interactive. */
.field-section.disabled .field-section-header { color: #666; cursor: not-allowed; }
.field-section.disabled .field-section-header:hover { color: #666; }

.range-input:focus {
    outline: none;
    border-color: #4fc3f7;
    background: rgba(79,195,247,0.1);
}

.range-input::-webkit-inner-spin-button,
.range-input::-webkit-outer-spin-button { opacity: 0.5; }

.apply-btn {
    align-self: flex-end;
    padding: 5px 14px;
    background: rgba(79,195,247,0.2);
    border: 1px solid #4fc3f7;
    border-radius: 4px;
    color: #4fc3f7;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apply-btn:hover { background: rgba(79,195,247,0.35); }

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================================
   OPACITY CONTROL  (Settings panel)
   ============================================================ */
.opacity-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

#opacity-slider {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

#opacity-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #4fc3f7;
    border-radius: 50%;
    cursor: pointer;
}

#opacity-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #4fc3f7;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#opacity-value {
    min-width: 40px;
    font-size: 12px;
    color: #4fc3f7;
    text-align: right;
}

/* ============================================================
   KEYBOARD SHORTCUTS INFO
   ============================================================ */
.shortcuts-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.shortcuts-info details { cursor: pointer; }

.shortcuts-info summary {
    font-size: 11px;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 0;
    list-style: none;
    user-select: none;
}

.shortcuts-info summary::-webkit-details-marker { display: none; }
.shortcuts-info summary:hover { color: #4fc3f7; }

.shortcuts-list {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.shortcuts-list > div {
    font-size: 11px;
    color: #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shortcuts-list kbd {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #4fc3f7;
    margin: 0 2px;
    display: inline-block;
    min-width: 20px;
    text-align: center;
}

/* ============================================================
   NAV LINK  (COG Browser, settings)
   ============================================================ */
.nav-link {
    display: block;
    text-align: center;
    font-size: 12px;
    color: #4fc3f7;
    text-decoration: none;
    padding: 6px 8px;
    border: 1px solid rgba(79,195,247,0.3);
    border-radius: 4px;
    background: rgba(79,195,247,0.1);
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: rgba(79,195,247,0.2);
    border-color: #4fc3f7;
}

/* ============================================================
   LEGEND  (Bottom Left)
   ============================================================ */
#legend-container {
    position: absolute;
    bottom: 70px;
    left: 10px;
    z-index: 1000;
    background: rgba(26,26,46,0.95);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    min-width: 80px;
    max-height: 400px;
    overflow-y: auto;
}

.legend-title {
    font-size: 12px;
    font-weight: bold;
    color: #4fc3f7;
    text-align: center;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Continuous gradient legend ── */
.legend-gradient-wrapper {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    height: 180px;
    margin: 4px 0;
}

.legend-gradient-bar {
    width: 18px;
    flex-shrink: 0;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.15);
}

.legend-ticks {
    position: relative;
    flex: 1;
    margin-left: 4px;
}

.legend-tick {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    transform: translateY(50%);  /* centre tick on its value line */
}

.legend-tick-line {
    width: 6px;
    height: 1px;
    background: rgba(255,255,255,0.45);
    flex-shrink: 0;
    margin-right: 4px;
}

.legend-tick-label {
    font-size: 10px;
    color: #ddd;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    line-height: 1;
}

/* ── Legacy discrete-block legend (backward compat) ── */
.legend-scale {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}

.legend-value {
    font-size: 11px;
    color: #eee;
    font-family: 'Courier New', monospace;
}

.legend-unit {
    font-size: 10px;
    color: #888;
    text-align: center;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ============================================================
   ANIMATION CONTROLS  (Bottom Center)
   ============================================================ */
#animation-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(26,26,46,0.95);
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    min-width: 420px;
    max-width: 640px;
}

/* Top info row: time window label + current frame time */
.animation-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 5px;
    cursor: grab;
    user-select: none;
}
.animation-info-row.dragging {
    cursor: grabbing;
}

.time-window-label {
    font-size: 13px;
    color: #4fc3f7;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.frame-time-display {
    font-size: 13px;
    color: #81d4fa;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    text-align: right;
}

/* Slider */
.animation-slider-container { margin-bottom: 5px; }

#animation-slider {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#animation-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4fc3f7;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#animation-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #4fc3f7;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Control buttons row */
.animation-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* Navigation buttons (prev/next/latest/first/refresh) in animation bar */
#btn-first, #btn-prev, #btn-next, #btn-latest {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-first:hover, #btn-prev:hover, #btn-next:hover, #btn-latest:hover {
    opacity: 0.75;
    color: #4fc3f7;
    background: transparent;
}

#btn-first:disabled, #btn-prev:disabled, #btn-next:disabled, #btn-latest:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Play/pause */
#btn-play-pause {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: opacity 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-play-pause:hover  { opacity: 0.75; color: #4fc3f7; background: transparent; }
#btn-play-pause:active { opacity: 0.6; }
#btn-play-pause:disabled { opacity: 0.35; cursor: not-allowed; }

/* Fixed-geometry play/pause icon: both shapes share one SVG; .playing swaps
   which is shown, so size/aspect/baseline stay identical in both states. */
#btn-play-pause .play-pause-icon { display: block; fill: currentColor; pointer-events: none; width: 36px; height: 36px; }
#btn-play-pause .icon-pause { display: none; }
#btn-play-pause.playing .icon-play { display: none; }
#btn-play-pause.playing .icon-pause { display: inline; }

/* Speed slider (item 4: replaces discrete speed button) */
.speed-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.speed-label {
    font-size: 10px;
    color: #aaa;
    white-space: nowrap;
}

#speed-slider {
    width: 72px;
    height: 4px;
    cursor: pointer;
    accent-color: #4fc3f7;
}

#speed-value {
    font-size: 11px;
    color: #fff;
    min-width: 32px;
    text-align: left;
    font-family: 'Courier New', monospace;
}

/* COG refresh now button (item 10) */
#btn-cog-refresh-now {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-cog-refresh-now:hover:not(:disabled) { opacity: 0.75; color: #4fc3f7; background: transparent; }
#btn-cog-refresh-now:disabled { opacity: 0.35; cursor: not-allowed; }

/* Live mode indicator (item 8) */
.live-indicator {
    font-size: 10px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    padding: 2px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

.live-indicator.live-on {
    color: #66bb6a;
    background: rgba(102,187,106,0.15);
    border: 1px solid rgba(102,187,106,0.3);
}

.live-indicator.live-off {
    color: #888;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Frame counter */
#frame-counter {
    font-size: 11px;
    color: #aaa;
    font-family: 'Courier New', monospace;
    min-width: 56px;
    text-align: center;
}

/* Field loading indicator — appears in bottom-left during
   field switch preload so it does not hide behind open panels. */
#field-loading-badge {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1100;
    background: rgba(30, 30, 60, 0.85);
    color: #a0c4ff;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(160, 196, 255, 0.3);
    pointer-events: none;
    letter-spacing: 0.03em;
}
#field-loading-badge.visible {
    display: block;
}

/* ============================================================
   COG BROWSER STYLES  (separate page, not main viewer)
   ============================================================ */
.nav-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-header h3 {
    margin: 0;
    font-size: 16px;
    color: #4fc3f7;
    text-align: center;
}

.status-message {
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    min-height: 20px;
    display: none;
}

.status-message.show { display: block; }
.status-message.info    { background: rgba(33,150,243,0.2);  color: #64b5f6; border: 1px solid rgba(33,150,243,0.3); }
.status-message.success { background: rgba(76,175,80,0.2);   color: #81c784; border: 1px solid rgba(76,175,80,0.3); }
.status-message.error   { background: rgba(244,67,54,0.2);   color: #ef5350; border: 1px solid rgba(244,67,54,0.3); }
.status-message.loading { background: rgba(255,152,0,0.2);   color: #ffb74d; border: 1px solid rgba(255,152,0,0.3); }

.colormap-range {
    margin-top: 6px;
    padding: 6px 8px;
    background: rgba(79,195,247,0.1);
    border: 1px solid rgba(79,195,247,0.2);
    border-radius: 3px;
    font-size: 11px;
}

.colormap-range small {
    color: #81d4fa;
    font-family: 'Courier New', monospace;
    display: block;
}

.cog-list {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}

.cog-list-empty { color: #999; text-align: center; padding: 20px 10px; font-style: italic; }

.cog-item {
    padding: 8px;
    margin-bottom: 6px;
    background: rgba(79,195,247,0.1);
    border: 1px solid rgba(79,195,247,0.2);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cog-item:hover  { background: rgba(79,195,247,0.2); border-color: #4fc3f7; transform: translateX(2px); }
.cog-item.active { background: rgba(79,195,247,0.3); border-color: #4fc3f7; font-weight: bold; }

.cog-item-time { font-family: 'Courier New', monospace; color: #aaa; font-size: 10px; }
.cog-item-info { color: #ccc; margin-top: 2px; }

.cog-date-node {
    padding: 5px 8px;
    margin-bottom: 2px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    color: #81d4fa;
    user-select: none;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cog-date-node:hover { background: rgba(79,195,247,0.15); }
.cog-date-arrow { font-size: 10px; width: 12px; flex-shrink: 0; }

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4fc3f7;
    cursor: pointer;
    transition: background 0.2s;
}

.slider::-webkit-slider-thumb:hover { background: #81d4fa; }

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4fc3f7;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.slider::-moz-range-thumb:hover { background: #81d4fa; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    #icon-bar { top: 5px; right: 5px; }

    .icon-btn { width: 38px; height: 38px; font-size: 16px; }

    .floating-panel {
        right: 53px;
        width: 220px;
        max-height: 80vh;
    }

    #animation-controls {
        min-width: 300px;
        max-width: 90vw;
        padding: 8px 12px;
    }

    #btn-play-pause { width: 40px; height: 40px; font-size: 20px; }

    #legend-container {
        bottom: 80px;
        left: 5px;
        padding: 8px;
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .floating-panel { width: 190px; right: 50px; }

    #animation-controls { min-width: 260px; }

    #btn-speed { padding: 6px 10px; font-size: 11px; }
}

/* Radar image overlays — nearest-neighbor scaling preserves discrete
   measurement cells. Applied to L.imageOverlay elements in v2.
   Bilinear (browser default) produces misleading blur at high zoom. */
.radar-image-overlay {
    image-rendering: crisp-edges;  /* Firefox < 93 fallback */
    image-rendering: pixelated;    /* Chrome, Edge, Safari, Firefox 93+ */
}

/* Coverage mode toggle button */
.coverage-mode-btn {
    padding: 4px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid #555;
    border-radius: 4px;
    background: #333;
    color: #eee;
    min-width: 48px;
}

.coverage-mode-btn:hover {
    background: #444;
}

/* Coverage mode legend — small label below the mode toggle button */
.coverage-mode-legend {
    font-size: 0.7rem;
    color: #888;
    margin-top: 4px;
    line-height: 1.3;
}
