/* ===== TSRS Application — Modern Glassmorphism Design ===== */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #0F172A;
    --primary-mid: #1E293B;
    --primary-light: #334155;
    --accent: #14B8A6;
    --accent-glow: rgba(20,184,166,0.3);
    --danger: #EF4444;
    --warning: #F97316;
    --caution: #FBBF24;
    --success: #10B981;
    --info: #3B82F6;
    --bg: #0F172A;
    --sidebar-bg: rgba(15,23,42,0.85);
    --card-bg: rgba(30,41,59,0.7);
    --text: #F1F5F9;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    --border: rgba(148,163,184,0.15);
    --border-accent: rgba(20,184,166,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --glass: blur(16px) saturate(180%);
    --font: 'Rubik', 'Assistant', 'Segoe UI', sans-serif;
    --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    height: 100vh;
    overflow: hidden;
}

/* ===== Header ===== */
#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    color: white;
    padding: 0 24px;
    height: 56px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 20px rgba(0,0,0,0.4);
    z-index: 1000;
    position: relative;
}

#app-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon { font-size: 26px; }

.header-titles h1 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(to left, var(--accent), #38BDF8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.header-datetime {
    font-size: 12px;
    color: var(--text-muted);
}

/* Language Selector */
.lang-selector {
    display: flex;
    gap: 3px;
    margin-left: 10px;
}

.lang-btn {
    background: rgba(148,163,184,0.15);
    border: 1px solid rgba(148,163,184,0.2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}

.lang-btn:hover {
    background: rgba(20,184,166,0.2);
    border-color: var(--accent);
    color: var(--text);
}

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

/* ===== Main Container ===== */
#app-container {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 56px);
}

/* ===== Sidebar ===== */
#sidebar {
    width: 310px;
    min-width: 310px;
    background: var(--sidebar-bg);
    -webkit-backdrop-filter: var(--glass);
    backdrop-filter: var(--glass);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 10px;
    z-index: 500;
}

.sidebar-section {
    margin-bottom: 10px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}

.sidebar-section:hover {
    border-color: var(--border-accent);
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Controls ===== */
.control-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    direction: rtl;
    background: var(--primary-mid);
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--transition);
}

.control-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ===== Wave Slider ===== */
.slider-container { padding: 4px 0; }

#wave-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to left, var(--danger), var(--warning), var(--caution), var(--success));
    border-radius: 2px;
    outline: none;
    direction: ltr;
}

#wave-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--primary);
    box-shadow: 0 0 8px var(--accent-glow);
    cursor: pointer;
    transition: transform 0.15s;
}

#wave-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
    direction: ltr;
}

.wave-value {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent);
}

.severity-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
}

.severity-low { background: rgba(16,185,129,0.15); color: #34D399; border: 1px solid rgba(16,185,129,0.3); }
.severity-medium { background: rgba(251,191,36,0.15); color: #FBBF24; border: 1px solid rgba(251,191,36,0.3); }
.severity-high { background: rgba(249,115,22,0.15); color: #FB923C; border: 1px solid rgba(249,115,22,0.3); }
.severity-extreme { background: rgba(239,68,68,0.15); color: #F87171; border: 1px solid rgba(239,68,68,0.3); }

/* ===== Weight Sliders ===== */
.weight-preset-btns {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.weight-preset {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--primary-mid);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.weight-preset:hover, .weight-preset.active {
    background: var(--accent);
    color: var(--primary);
    border-color: var(--accent);
}

.weight-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.weight-label {
    width: 70px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    flex-shrink: 0;
}

.weight-slider {
    flex: 1;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(148,163,184,0.2);
    border-radius: 2px;
    outline: none;
}

.weight-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--primary);
    cursor: pointer;
}

.weight-val {
    width: 30px;
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    flex-shrink: 0;
}

.weight-formula {
    margin-top: 8px;
    padding: 6px 8px;
    background: rgba(20,184,166,0.06);
    border: 1px solid var(--border-accent);
    border-radius: 6px;
    font-size: 9px;
    font-family: 'Courier New', monospace;
    color: var(--accent);
    text-align: center;
    direction: ltr;
}

/* ===== Layer Toggles ===== */
.layer-toggles {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background var(--transition);
    color: var(--text);
}

.toggle-label:hover {
    background: rgba(148,163,184,0.08);
}

.toggle-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
}

.toggle-label.layer-disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.toggle-label.layer-disabled input[type="checkbox"] {
    cursor: not-allowed;
    pointer-events: none;
}

.zoom-hint {
    font-size: 9px;
    color: var(--text-dim);
    margin-right: 4px;
}

.layer-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

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

/* ===== Legend ===== */
.legend {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

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

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

/* ===== Map ===== */
#map-wrapper {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Fix Leaflet popups */
.leaflet-popup-content {
    direction: rtl;
    text-align: right;
    font-family: var(--font);
    margin: 10px 14px;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    background: #1E293B;
    color: var(--text);
}

.leaflet-popup-tip {
    background: #1E293B;
}

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

/* ===== TSRS Popup (dark theme) ===== */
.tsrs-popup {
    min-width: 280px;
    font-family: var(--font);
}

.tsrs-popup h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

.tsrs-popup .tsrs-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.tsrs-popup .component-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    font-size: 11px;
}

.tsrs-popup .bar-label-group {
    width: 85px;
    text-align: right;
}

.tsrs-popup .bar-label {
    font-weight: 600;
    font-size: 11px;
    display: block;
    color: var(--text);
}

.tsrs-popup .bar-desc {
    font-size: 9px;
    color: var(--text-dim);
    display: block;
}

.tsrs-popup .bar-track {
    flex: 1;
    height: 8px;
    background: rgba(148,163,184,0.15);
    border-radius: 4px;
    overflow: hidden;
}

.tsrs-popup .bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.tsrs-popup .bar-score-group {
    width: 55px;
    text-align: left;
}

.tsrs-popup .bar-value {
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
}

.tsrs-popup .bar-verbal {
    font-size: 8px;
    font-weight: 600;
    display: block;
}

.verbal-critical { color: #F87171; }
.verbal-high { color: #FB923C; }
.verbal-medium { color: #FBBF24; }
.verbal-low { color: #34D399; }
.verbal-minimal { color: #60A5FA; }

.tsrs-popup .popup-actions {
    margin-top: 10px;
    display: flex;
    gap: 6px;
}

.popup-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.popup-btn-primary {
    background: var(--accent);
    color: var(--primary);
}

.popup-btn-primary:hover {
    background: #2DD4BF;
    box-shadow: 0 0 12px var(--accent-glow);
}

.popup-btn-secondary {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.popup-btn-secondary:hover {
    background: var(--primary-light);
    border-color: var(--accent);
}

/* ===== Station Summary (sidebar) ===== */
#station-summary-content {
    font-size: 12px;
}

.summary-stat {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.summary-stat:last-child { border-bottom: none; }
.summary-label { color: var(--text-muted); }
.summary-value { font-weight: 700; color: var(--text); }

/* ===== Operational Panel ===== */
.op-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 280px;
    background: rgba(15,23,42,0.95);
    -webkit-backdrop-filter: var(--glass);
    backdrop-filter: var(--glass);
    border-top: 2px solid var(--accent);
    box-shadow: 0 -4px 30px rgba(0,0,0,0.4);
    z-index: 800;
    overflow-y: auto;
}

.op-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--primary-mid);
    color: var(--text);
    position: sticky;
    top: 0;
}

.op-panel-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.op-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition);
}

.op-close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text);
}

.op-panel-body {
    padding: 12px 16px;
}

.op-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.op-card {
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    border: 1px solid var(--border);
}

.op-card h4 {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.op-card .op-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent);
}

.op-guidelines {
    list-style: none;
    padding: 0;
}

.op-guidelines li {
    padding: 6px 12px;
    margin-bottom: 4px;
    background: rgba(249,115,22,0.08);
    border-right: 3px solid var(--warning);
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: var(--text);
}

/* ===== Leaflet controls fix ===== */
.leaflet-control-layers {
    direction: ltr;
    background: rgba(15,23,42,0.9) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    backdrop-filter: var(--glass);
}

.leaflet-control-layers label {
    color: var(--text) !important;
}

.leaflet-control-zoom a {
    background: rgba(15,23,42,0.9) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--primary-mid) !important;
    color: var(--accent) !important;
}

/* ===== Station Tooltip ===== */
.leaflet-tooltip {
    background: rgba(15,23,42,0.92) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    font-family: var(--font) !important;
    font-size: 12px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
}

.leaflet-tooltip-top::before {
    border-top-color: rgba(15,23,42,0.92) !important;
}

/* ===== Scrollbar ===== */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb {
    background: var(--text-dim);
    border-radius: 2px;
}
#sidebar::-webkit-scrollbar-track { background: transparent; }

/* ===== Info Button (Header) ===== */
.info-btn {
    background: rgba(20,184,166,0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.info-btn:hover {
    background: var(--accent);
    color: var(--primary);
}

/* ===== Info Modal ===== */
.info-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.3s ease;
}

.info-modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.info-modal-content {
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
    border: 1px solid var(--border-accent);
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(20,184,166,0.1);
    color: var(--text);
}

.info-close {
    position: absolute;
    top: 12px;
    left: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
}

[dir="ltr"] .info-close {
    left: auto;
    right: 12px;
}

.info-close:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text);
}

.info-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.info-header h2 {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(to left, var(--accent), #38BDF8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.info-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.info-section {
    margin-bottom: 18px;
}

.info-section h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.info-section p {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
}

.info-section ul {
    padding-right: 20px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text);
}

[dir="ltr"] .info-section ul {
    padding-right: 0;
    padding-left: 20px;
}

.info-formula {
    background: rgba(20,184,166,0.08);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin: 10px 0;
    direction: ltr;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

@media (max-width: 600px) {
    .info-grid { grid-template-columns: 1fr; }
}

.info-metric {
    background: rgba(148,163,184,0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
}

.info-weight {
    display: inline-block;
    background: var(--accent);
    color: var(--primary);
    font-weight: 800;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

[dir="ltr"] .info-weight {
    margin-left: 0;
    margin-right: 6px;
}

.info-tier {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: white;
}

.info-start-btn {
    background: var(--accent);
    color: var(--primary);
    border: none;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
    padding: 10px 28px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.info-start-btn:hover {
    background: #2DD4BF;
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

.info-footer {
    text-align: center;
    font-size: 13px;
    font-style: italic;
    color: var(--accent);
    margin-top: 16px;
    opacity: 0.8;
}

/* Scrollbar for modal */
.info-modal-content::-webkit-scrollbar { width: 4px; }
.info-modal-content::-webkit-scrollbar-thumb {
    background: var(--text-dim);
    border-radius: 2px;
}

/* ===== LTR Overrides (for non-Hebrew languages) ===== */
[dir="ltr"] #sidebar {
    border-left: none;
    border-right: 1px solid var(--border);
}

[dir="ltr"] .control-select {
    direction: ltr;
}

[dir="ltr"] .leaflet-popup-content {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .tsrs-popup .bar-label-group {
    text-align: left;
}

[dir="ltr"] .op-guidelines li {
    border-right: none;
    border-left: 3px solid var(--warning);
    border-radius: 6px 0 0 6px;
}

[dir="ltr"] .summary-stat {
    flex-direction: row;
}

/* ===== Mobile Sidebar Toggle (hidden on desktop) ===== */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(20,184,166,0.2);
    border-color: var(--accent);
}

/* ===== TABLET (768px - 1023px) ===== */
@media (max-width: 1023px) {
    #sidebar {
        width: 270px;
        min-width: 270px;
    }
    .sidebar-section { padding: 10px; }
    .section-title { font-size: 12px; }
    #app-header { padding: 0 16px; }
    .header-titles h1 { font-size: 15px; }
    .lang-btn { font-size: 10px; padding: 2px 6px; }
    .info-modal-content { max-width: 600px; padding: 22px 24px; }
}

/* ===== SMALL TABLET / LARGE PHONE (481px - 767px) ===== */
@media (max-width: 767px) {
    .sidebar-toggle { display: block; }

    #app-container { flex-direction: column; position: relative; }

    #sidebar {
        position: fixed;
        top: 56px;
        right: 0;
        left: 0;
        width: 100%;
        min-width: 100%;
        max-height: 65vh;
        z-index: 600;
        border-left: none;
        border-bottom: 2px solid var(--accent);
        transform: translateY(-120%);
        transition: transform 0.3s ease;
        box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    }

    [dir="ltr"] #sidebar {
        border-right: none;
    }

    #sidebar.sidebar-open {
        transform: translateY(0);
    }

    #map-wrapper { height: calc(100vh - 56px); }

    .op-panel {
        max-height: 220px;
        border-radius: 12px 12px 0 0;
    }

    .op-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .op-card .op-value { font-size: 16px; }

    .header-subtitle { display: none; }
    .header-datetime { display: none; }
    .info-btn { font-size: 11px; padding: 3px 8px; }

    /* Weight sliders tablet */
    .weight-label { width: 65px; font-size: 9px; }
    .weight-formula { font-size: 9px; }

    .info-modal-content {
        max-width: 95vw;
        padding: 18px 20px;
        max-height: 90vh;
    }
    .info-header h2 { font-size: 17px; }
    .info-section h3 { font-size: 13px; }
    .info-section p, .info-section ul { font-size: 12px; }
    .info-formula { font-size: 12px; padding: 8px 10px; }
    .info-start-btn { font-size: 14px; padding: 8px 22px; }
}

/* ===== MOBILE PHONE (max-width: 480px) ===== */
@media (max-width: 480px) {
    #app-header {
        height: 50px;
        padding: 0 10px;
    }

    .logo-icon { font-size: 20px; }
    .header-titles h1 { font-size: 13px; }
    .header-subtitle { display: none; }
    .header-datetime { display: none; }

    .lang-selector { gap: 2px; }
    .lang-btn { font-size: 9px; padding: 2px 5px; }
    .info-btn { font-size: 10px; padding: 2px 6px; }

    #sidebar {
        top: 50px;
        max-height: 70vh;
    }

    #map-wrapper { height: calc(100vh - 50px); }

    .sidebar-section { padding: 8px; margin-bottom: 6px; }
    .section-title { font-size: 11px; margin-bottom: 6px; }
    .control-select { padding: 6px 10px; font-size: 12px; }

    /* Larger touch targets */
    #wave-slider { height: 6px; }
    #wave-slider::-webkit-slider-thumb { width: 22px; height: 22px; }
    .toggle-label { padding: 6px; font-size: 13px; }
    .toggle-label input[type="checkbox"] { width: 18px; height: 18px; }

    /* Weight sliders mobile */
    .weight-row { gap: 4px; margin-bottom: 6px; }
    .weight-label { width: 60px; font-size: 9px; }
    .weight-val { width: 28px; font-size: 9px; }
    .weight-slider { height: 4px; }
    .weight-slider::-webkit-slider-thumb { width: 18px; height: 18px; }
    .weight-formula { font-size: 8px; padding: 4px 6px; }
    .weight-preset { font-size: 10px; padding: 3px 6px; }

    .legend-item { font-size: 10px; }
    .legend-color { width: 16px; height: 10px; }

    .op-panel { max-height: 200px; }
    .op-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .op-card { padding: 6px; }
    .op-card h4 { font-size: 9px; }
    .op-card .op-value { font-size: 14px; }
    .op-guidelines li { font-size: 11px; padding: 4px 8px; }

    /* Popup */
    .leaflet-popup-content { margin: 8px 10px; }
    .tsrs-popup { min-width: 220px; }
    .tsrs-popup h3 { font-size: 14px; }
    .tsrs-popup .bar-label-group { width: 70px; }
    .tsrs-popup .bar-label { font-size: 10px; }
    .tsrs-popup .bar-desc { font-size: 8px; }

    /* Info modal */
    .info-modal-content {
        max-width: 98vw;
        padding: 14px 16px;
        border-radius: 12px;
    }
    .info-header { flex-direction: column; text-align: center; gap: 8px; }
    .info-header h2 { font-size: 15px; }
    .info-header p { font-size: 11px; }
    .info-header div:first-child { font-size: 30px; }
    .info-section { margin-bottom: 12px; }
    .info-section h3 { font-size: 13px; }
    .info-section p, .info-section ul { font-size: 11px; line-height: 1.6; }
    .info-formula { font-size: 11px; padding: 6px 8px; }
    .info-grid { grid-template-columns: 1fr; gap: 6px; }
    .info-metric { font-size: 11px; padding: 6px 8px; }
    .info-tier { font-size: 10px; padding: 3px 8px; }
    .info-start-btn { font-size: 13px; padding: 8px 20px; }
    .info-footer { font-size: 11px; }
}

/* ===== VERY SMALL PHONE (max-width: 360px) ===== */
@media (max-width: 360px) {
    .header-titles h1 { font-size: 11px; }
    .lang-selector { gap: 1px; }
    .lang-btn { font-size: 8px; padding: 1px 4px; }
    .info-btn { font-size: 9px; padding: 2px 5px; }
    .op-grid { grid-template-columns: 1fr; }
    .weight-label { width: 50px; font-size: 8px; }
    .weight-val { width: 26px; font-size: 8px; }
    .weight-formula { font-size: 7px; padding: 3px 4px; }
}
