/* MitStadt — Stil-System (Phase 2 UX-Polish, FE-1..FE-5)
 *
 * Token-basiert mit CSS-Custom-Properties. Mobile-first.
 * Grün-Branding (Wald/Stadtgrün), klare Hierarchie, Touch-≥48px.
 */

:root {
    /* Brand */
    --c-brand: #1a4d2e;
    --c-brand-dark: #103319;
    --c-brand-light: #d6e8dc;
    --c-accent: #f4a261;

    /* Severity */
    --c-sev-low: #94a3b8;
    --c-sev-medium: #f4a261;
    --c-sev-high: #e76f51;
    --c-sev-critical: #c1121f;

    /* Status */
    --c-status-available: #94a3b8;
    --c-status-sponsored: #1a4d2e;
    --c-status-active: #2d8659;
    --c-status-overdue: #e76f51;

    /* Neutrals */
    --c-bg: #fafaf9;
    --c-surface: #ffffff;
    --c-border: #e5e7eb;
    --c-text: #1f2937;
    --c-muted: #6b7280;

    /* Spacing */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;

    /* Radii und Shadows */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.16);

    /* Typografie */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.5rem;
    --fs-3xl: 2rem;
    --lh-tight: 1.25;
    --lh-base: 1.5;
}

@media (prefers-color-scheme: dark) {
    :root {
        --c-bg: #0f1714;
        --c-surface: #1a221e;
        --c-border: #2d3a32;
        --c-text: #e5e7eb;
        --c-muted: #9ca3af;
        --c-brand-light: #2d4a3a;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* === Layout === */

.app-header {
    background: var(--c-brand);
    color: #fff;
    padding: var(--sp-3) var(--sp-4);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-header a {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.app-header .brand {
    font-size: var(--fs-lg);
}

.app-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 0 auto;
}

.app-nav {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex-wrap: wrap;
    font-size: var(--fs-sm);
}

.app-nav .nav-link {
    color: #fff;
    text-decoration: none;
    opacity: .85;
    padding: .35rem .6rem;
    border-radius: 6px;
}

.app-nav .nav-link:hover {
    opacity: 1;
    background: rgba(255, 255, 255, .1);
}

.app-nav .nav-user {
    border-left: 1px solid rgba(255, 255, 255, .25);
    padding-left: var(--sp-3);
    margin-left: var(--sp-2);
}

.app-nav .nav-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .4);
    color: #fff;
    padding: .3rem .75rem;
    min-height: 0;
    border-radius: 6px;
    font-size: var(--fs-sm);
    cursor: pointer;
    text-decoration: none;
}

.app-nav .nav-btn:hover {
    background: rgba(255, 255, 255, .15);
}

.app-main {
    padding: var(--sp-4);
    max-width: 960px;
    margin: 0 auto;
}

.container-narrow {
    max-width: 560px;
    margin: 0 auto;
}

/* === Typografie === */

h1 { font-size: var(--fs-2xl); line-height: var(--lh-tight); margin: 0 0 var(--sp-4); }
h2 { font-size: var(--fs-xl); line-height: var(--lh-tight); margin: var(--sp-6) 0 var(--sp-3); }
h3 { font-size: var(--fs-lg); margin: var(--sp-4) 0 var(--sp-2); }

p { margin: 0 0 var(--sp-3); }
.muted { color: var(--c-muted); font-size: var(--fs-sm); }

/* === Buttons === */

.btn,
button.btn,
input[type="submit"].btn {
    appearance: none;
    border: 1.5px solid var(--c-brand);
    background: var(--c-brand);
    color: #fff;
    padding: var(--sp-3) var(--sp-4);
    min-height: 48px;
    border-radius: var(--r-md);
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    transition: transform 0.05s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover { background: var(--c-brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

.btn-secondary {
    background: var(--c-surface);
    color: var(--c-brand);
}
.btn-secondary:hover { background: var(--c-brand-light); }

.btn-ghost {
    background: transparent;
    color: var(--c-brand);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--c-brand-light); }

.btn-danger {
    background: var(--c-sev-critical);
    border-color: var(--c-sev-critical);
}

.btn-block { display: flex; width: 100%; }

/* Floating Action Button */
.fab {
    position: fixed;
    right: var(--sp-4);
    bottom: var(--sp-4);
    box-shadow: var(--shadow-lg);
    border-radius: var(--r-pill);
    padding: var(--sp-4) var(--sp-6);
    z-index: 30;
}

/* === Forms === */

label { display: block; margin-bottom: var(--sp-2); font-weight: 500; font-size: var(--fs-sm); }

input, textarea, select {
    width: 100%;
    padding: var(--sp-3);
    min-height: 48px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-md);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: var(--fs-base);
    font-family: inherit;
}

input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: none;
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px var(--c-brand-light);
}

.field { margin-bottom: var(--sp-4); }

/* === Card / Surface === */

.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: var(--sp-3); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-3);
}

/* === Badges === */

.badge {
    display: inline-block;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--c-brand-light);
    color: var(--c-brand);
}

.badge-sev-low { background: #e2e8f0; color: var(--c-sev-low); }
.badge-sev-medium { background: #fde6c8; color: #b25d1e; }
.badge-sev-high { background: #fad6cd; color: #9d3a23; }
.badge-sev-critical { background: #f8c1c5; color: var(--c-sev-critical); }

/* === Map === */

.map-container {
    width: 100%;
    height: 70vh;
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow-sm);
}

.map-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
}

/* === Bottom-Sheet === */

.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--c-surface);
    border-top-left-radius: var(--r-lg);
    border-top-right-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-4);
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 40;
}

.bottom-sheet[aria-expanded="true"] {
    transform: translateY(0);
}

.bottom-sheet .handle {
    width: 40px;
    height: 4px;
    background: var(--c-border);
    border-radius: var(--r-pill);
    margin: 0 auto var(--sp-3);
}

/* === Tabs === */

.tabs {
    display: flex;
    border-bottom: 1.5px solid var(--c-border);
    gap: var(--sp-1);
    margin-bottom: var(--sp-3);
}

.tab {
    padding: var(--sp-2) var(--sp-3);
    background: transparent;
    border: none;
    color: var(--c-muted);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1.5px;
    min-height: 44px;
}

.tab[aria-selected="true"] {
    color: var(--c-brand);
    border-bottom-color: var(--c-brand);
}

/* === Lists === */

.list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list li + li {
    margin-top: var(--sp-2);
}

.list-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: var(--sp-3);
}

/* === Stats / KPIs === */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--sp-3);
}

.kpi {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    text-align: center;
}

.kpi-value {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--c-brand);
    line-height: 1;
}

.kpi-label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    color: var(--c-muted);
    letter-spacing: 0.04em;
    margin-top: var(--sp-1);
}

/* === Stepper === */

.stepper {
    display: flex;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}

.stepper .step {
    flex: 1;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--c-border);
}

.stepper .step.active { background: var(--c-brand); }
.stepper .step.done { background: var(--c-status-active); }

/* === Utilities === */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.text-sm { font-size: var(--fs-sm); }
.text-muted { color: var(--c-muted); }

/* === Responsive === */

@media (min-width: 768px) {
    .app-main { padding: var(--sp-6) var(--sp-8); }
    .map-container { height: 75vh; }
}
