/* GewässerMonitor - Gewässerbewertung und Hochwasseranalyse */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

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

:root {
    --primary: #1b4f72;
    --primary-light: #2874a6;
    --primary-dark: #0e2f44;
    --accent: #2e86c1;
    --bg: #f4f6f8;
    --card: #fff;
    --text: #1a1a1a;
    --text-light: #555;
    --text-muted: #888;
    --border: #e3e3e1;
    --kl1: #1a8a4a; --kl2: #4caf50; --kl3: #ffc107;
    --kl4: #ff9800; --kl5: #f44336; --kl6: #c62828; --kl7: #4a148c;
    --header-height: 50px;
    --panel-width: 380px;
}

html, body {
    width: 100%; height: 100%;
    font-family: Roboto, 'Segoe UI', sans-serif;
    font-size: 14px; line-height: 1.5;
    color: var(--text); background: var(--bg);
    overflow: hidden;
}

body { display: flex; flex-direction: column; }

/* --- Header --- */
header {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--header-height); padding: 0 16px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff; z-index: 1000;
}

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

header h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.5px; }
.header-subtitle { font-size: 0.8rem; opacity: 0.75; }

.header-btn {
    padding: 6px 14px; font-size: 0.8rem; font-weight: 600;
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
    color: #fff; border-radius: 16px; cursor: pointer;
}
.header-btn:hover { background: rgba(255,255,255,0.25); }

.legend-bar {
    display: flex; gap: 2px; align-items: center;
}
.legend-item {
    display: flex; align-items: center; gap: 3px;
    font-size: 0.68rem; opacity: 0.85;
}
.legend-dot {
    width: 10px; height: 10px; border-radius: 2px;
}

/* --- Layout --- */
#app-container {
    display: flex; flex: 1; min-height: 0;
}

#map-container { flex: 1; position: relative; min-width: 0; }
#map { width: 100%; height: 100%; }

/* --- Panel --- */
.panel {
    width: var(--panel-width); min-width: var(--panel-width);
    background: var(--card); border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow-y: auto;
    transition: width 0.2s;
}

.panel-welcome {
    padding: 40px 24px; text-align: center; color: var(--text-light);
}
.panel-welcome h3 { font-size: 1.1rem; margin: 12px 0 8px; color: var(--text); }
.panel-welcome p { font-size: 0.85rem; line-height: 1.6; }
.welcome-hint {
    margin-top: 16px; padding: 10px 14px;
    background: var(--bg); border-radius: 6px;
    border-left: 3px solid var(--accent);
    font-size: 0.8rem; text-align: left; line-height: 1.5;
}

/* --- Segment Info --- */
.segment-info {
    padding: 16px 18px; border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.segment-name { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.segment-meta { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.segment-class {
    display: inline-block; margin-top: 8px;
    padding: 3px 12px; border-radius: 12px;
    font-size: 0.8rem; font-weight: 700; color: #fff;
}

/* --- Assessment --- */
.assessment-section { padding: 16px 18px; }
.assessment-section h3 {
    font-size: 0.9rem; font-weight: 700; color: var(--primary);
    margin-bottom: 12px; padding-bottom: 6px;
    border-bottom: 2px solid var(--primary);
}

.param-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.param-row {
    display: flex; align-items: center; gap: 8px;
}
.param-label {
    flex: 1; font-size: 0.82rem; font-weight: 500;
}
.param-select {
    width: 180px; padding: 5px 8px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 0.8rem; font-family: inherit;
    cursor: pointer; transition: background 0.15s;
}

/* --- Button --- */
.btn { border: none; cursor: pointer; font-family: inherit; border-radius: 6px; transition: background 0.15s; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; padding: 10px 18px; font-size: 0.85rem; }
.btn-primary:hover { background: var(--primary); }
.btn-block { display: block; width: 100%; }

/* --- Results --- */
.result-section { padding: 16px 18px; border-top: 1px solid var(--border); }
.result-header { text-align: center; margin-bottom: 12px; }
.result-class { font-size: 2.5rem; font-weight: 800; }
.result-label { font-size: 0.9rem; font-weight: 600; margin-top: 2px; }

.radar-container { display: flex; justify-content: center; margin: 12px 0; }
.radar-svg { width: 200px; height: 200px; }

.radar-grid { fill: none; stroke: #ddd; stroke-width: 0.5; }
.radar-axis { stroke: #ccc; stroke-width: 0.5; }
.radar-area { fill: rgba(46,134,193,0.25); stroke: var(--accent); stroke-width: 2; }
.radar-dot { r: 4; fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.radar-label { font-size: 8px; fill: var(--text-light); text-anchor: middle; dominant-baseline: middle; }

.recommendations {
    background: var(--bg); border-radius: 6px; padding: 12px 14px;
}
.recommendations h4 {
    font-size: 0.8rem; font-weight: 700; color: var(--primary);
    margin-bottom: 6px;
}
.recommendations ul {
    list-style: none; padding: 0;
}
.recommendations li {
    padding: 4px 0; font-size: 0.8rem; color: var(--text-light);
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}
.recommendations li:last-child { border-bottom: none; }
.recommendations li::before { content: '\25B6'; margin-right: 6px; font-size: 0.6rem; color: var(--accent); }

/* --- Stats Modal --- */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--card); border-radius: 10px;
    padding: 24px; max-width: 700px; width: 90%;
    max-height: 80vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h2 { font-size: 1.1rem; color: var(--primary); }
.modal-close {
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--text-muted);
}

.stacked-bar {
    display: flex; height: 32px; border-radius: 6px; overflow: hidden;
    margin-bottom: 16px;
}
.stacked-bar > div {
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #fff;
    min-width: 20px;
}

.stats-summary { font-size: 0.85rem; color: var(--text-light); }
.stats-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.stats-table th, .stats-table td {
    padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}
.stats-table th { font-weight: 600; color: var(--primary); background: var(--bg); }

/* --- MapLibre Tooltip --- */
.maplibregl-popup-content {
    padding: 6px 10px; font-size: 0.82rem;
    font-family: Roboto, sans-serif;
    border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* --- Panel Tabs --- */
.panel-tabs {
    display: flex; border-bottom: 2px solid var(--border);
}
.panel-tab {
    flex: 1; padding: 10px 8px; font-size: 0.8rem; font-weight: 600;
    background: none; border: none; border-bottom: 2px solid transparent;
    margin-bottom: -2px; cursor: pointer; color: var(--text-light);
    font-family: inherit; transition: all 0.15s;
}
.panel-tab.active {
    color: var(--primary); border-bottom-color: var(--primary);
}
.panel-tab:hover:not(.active) { color: var(--text); background: var(--bg); }

.tab-content { flex: 1; overflow-y: auto; }

/* --- HQ Formular --- */
.hq-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.hq-row {
    display: flex; align-items: center; gap: 8px;
}
.hq-label {
    width: 50px; font-size: 0.82rem; font-weight: 600; color: var(--primary);
}
.hq-label.hq-highlight { color: var(--kl5); }
.hq-input {
    flex: 1; padding: 5px 8px; border: 1px solid var(--border);
    border-radius: 4px; font-size: 0.82rem; font-family: inherit;
    max-width: 120px;
}
.hq-input.wide { max-width: 200px; }
.hq-unit { font-size: 0.75rem; color: var(--text-muted); width: 35px; }
.hq-info { margin-top: 8px; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* --- Pegel Card --- */
.pegel-card {
    background: var(--bg); border-radius: 8px; padding: 14px;
    margin-bottom: 10px;
}
.pegel-card-name { font-weight: 700; color: var(--primary); font-size: 1rem; }
.pegel-card-meta { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.pegel-card-link {
    display: inline-block; margin-top: 8px; padding: 6px 14px;
    background: var(--accent); color: #fff; border-radius: 4px;
    font-size: 0.8rem; font-weight: 600; text-decoration: none;
}
.pegel-card-link:hover { background: var(--primary); }
.pegel-distance { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.pegel-list-header {
    font-size: 0.8rem; font-weight: 600; color: var(--primary);
    padding: 0 0 8px; margin-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

/* --- Suche --- */
.search-wrapper {
    position: relative; flex: 1 1 200px; min-width: 150px; max-width: 500px;
}
.search-icon-input {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: rgba(255,255,255,0.5); pointer-events: none;
}
.search-wrapper input {
    width: 100%; padding: 7px 12px 7px 32px;
    border: 1px solid rgba(255,255,255,0.3); border-radius: 20px;
    background: rgba(255,255,255,0.15); color: #fff;
    font-family: inherit; font-size: 0.82rem; outline: none;
}
.search-wrapper input::placeholder { color: rgba(255,255,255,0.5); }
.search-wrapper input:focus {
    background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.6);
}
.search-results {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border-radius: 0 0 8px 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    max-height: 320px; overflow-y: auto; z-index: 2000;
}
.search-results.visible { display: block; }
.search-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    cursor: pointer; border-bottom: 1px solid #f0f0f0; font-size: 0.82rem; color: #333;
}
.search-item:hover { background: #f4f6f8; }
.search-item-label { font-weight: 500; }
.search-item-sub { font-size: 0.75rem; color: #888; }
.search-item-icon {
    width: 28px; height: 28px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: 0.7rem;
    font-weight: 700; color: #fff; flex-shrink: 0;
}

/* --- KOSTRA Table --- */
.kostra-info { font-size: 12px; color: #666; margin-bottom: 8px; }
.kostra-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.kostra-table th { background: var(--primary); color: #fff; padding: 4px 6px; text-align: center; font-weight: 500; }
.kostra-table td { padding: 3px 5px; text-align: center; border-bottom: 1px solid #eee; }
.kostra-table .kostra-dur { text-align: left; font-weight: 600; color: var(--primary); }
.kostra-table .kostra-mid { background: #fff3cd; }
.kostra-table .kostra-high { background: #f8d7da; font-weight: 600; }

/* --- Ganglinie --- */
.ganglinie-controls { margin-bottom: 8px; }
.ganglinie-controls select { padding: 4px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }
#ganglinie-container { background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; padding: 4px; }
#ganglinie-canvas { width: 100%; height: auto; }
#ganglinie-info { font-size: 11px; margin-top: 6px; }

.hidden { display: none !important; }

/* --- Responsive --- */
@media (max-width: 800px) {
    .panel { width: 100%; min-width: 100%; position: absolute; bottom: 0; max-height: 60vh; z-index: 900; border-radius: 16px 16px 0 0; }
    .header-subtitle { display: none; }
    .legend-bar { display: none; }
}
