/* === Grunddesign === */
:root {
    --color-primary: #2c3e50;
    --color-accent: #2980b9;
    --color-bg: #f4f6f9;
    --color-card: #fff;
    --color-border: #dce1e7;
    --color-muted: #6c757d;
    --radius: 8px;
    --shadow: 0 2px 6px rgba(0,0,0,0.05);
}

body {
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--color-bg);
    color: var(--color-primary);
    text-align: center;
}

/* === Überschriften & Text === */
h1, h2 {
    margin: 1.5rem 0 1rem;
    font-weight: 600;
}

p, label {
    font-size: 1rem;
}

#formSwitcher {
    justify-content: center;
    display: flex;
    margin: auto;
}

/* === Site Header + Navigation === */
.site-header {
    background-color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: relative;
    z-index: 1001; /* oberhalb Leaflet-Panes (max ~800) */
}
.header-brand {
    color: white;
    font-size: 1.15rem;
    font-weight: 700;
    text-decoration: none;
    padding: 0.75rem 0;
    letter-spacing: 0.5px;
}
.header-brand .brand-sub {
    font-weight: 400;
    opacity: 0.7;
    font-size: 0.85em;
    margin-left: 4px;
}
.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.35);
    color: white;
    font-size: 1.2rem;
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
}
.nav-toggle:hover {
    background-color: rgba(255,255,255,0.15);
}
#navMenu {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}
#navMenu ul {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
#navMenu li {
    margin-bottom: 0;
    border: none;
    padding: 0;
    border-radius: 0;
}
#navMenu a {
    display: block;
    color: rgba(255,255,255,0.88);
    font-weight: 500;
    text-decoration: none;
    padding: 0.7rem 0.85rem;
    border-radius: 4px;
    transition: background 0.15s;
    white-space: nowrap;
}
#navMenu a:hover,
#navMenu a.active {
    background-color: rgba(255,255,255,0.15);
    color: white;
}
#navMenu a.active {
    font-weight: 700;
}
.nav-lock {
    font-size: 1.1rem;
}

/* === Karte === */
#map {
    height: 600px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 1.5rem 0;
    width: 80%;
}

.center-map {
    display: flex;
    justify-content: center;
}

/* === Filterform === */
#filterForm, 
#umrissForm {
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

/* === Checkboxen === */
#filterForm label,
#umrissForm label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#filterForm p,
#umrissForm p {
    margin: 0;
}

/* === Tabellen === */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

th, td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.95rem;
}

th {
    background-color: #f8f9fb;
    font-weight: 600;
    color: var(--color-primary);
}

tr:hover {
    background-color: #f0f4f8;
}

/* === Eingabefelder & Buttons === */
input[type="text"], 
input[type="email"], 
input[type="password"],
input[type="file"], 
select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: white;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
}

input[type="text"]:focus, 
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.2);
}

.form-block input[type="text"],
.form-block input[type="email"],
.form-block input[type="password"] {
    width: unset;

}

button {
    background-color: var(--color-accent);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}
button:hover {
    background-color: #1f6392;
}

/* === Tooltip modernisieren === */
.leaflet-tooltip {
    background-color: white;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
}

/* === Feedbackboxen === */
.feedback {
    background-color: #e9f7ef;
    color: #218c74;
    border-left: 4px solid #1e7e34;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: var(--radius);
}

/* === Log-Fenster z. B. bei Importen === */
#log {
    font-family: monospace;
    background: #f1f1f1;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin-top: 1rem;
}

/* === Admin Controls Layout === */
.admin-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Admin-Menü Links */
li {
    margin-bottom: 0.5em;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    padding: 0.5rem;
}

nav li {
    margin-bottom: 0;
    border: unset;
}

.ul-admin {
    list-style: none;
    margin-left: 20%;
    padding: 0;
    margin-right: 20%;
}

/* === Footer === */
.footer-user {
    text-align: center;
}
.footer-user a {
    margin: 0 0.5rem;
    text-decoration: none;
}

.footer-user a:hover {
    text-decoration: underline;
}

nav a.active {
  font-weight: bold;
  text-decoration: underline;
}

/* === Mobile Optimierung === */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    #navMenu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--color-primary);
        display: none;
        flex-direction: column;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
    #navMenu.open {
        display: flex;
    }
    #navMenu ul {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }
    #navMenu a {
        padding: 0.85rem 1.25rem;
        border-radius: 0;
    }

    #filterForm {
        flex-direction: column;
    }

    table, th, td {
        font-size: 0.9rem;
    }

    /* Ranking: Tabelle ausblenden, Cards einblenden auf Mobile */
    .ranking-table { display: none !important; }
    .ranking-cards { display: grid !important; }

    .page-container {
        padding: 0 0.75rem;
    }
}

/* ===================================================
   NEUE KLASSEN (Distanz, Ranking, Karten, Filter)
   =================================================== */

/* --- Page Container --- */
.page-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    text-align: left;
}

/* --- Footer Links --- */
.footer-links {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.88rem;
    color: var(--color-muted);
}
.footer-links a {
    color: var(--color-muted);
    text-decoration: none;
    margin: 0 4px;
}
.footer-links a:hover { text-decoration: underline; }
.footer-links span { color: #ccc; }

/* --- Distanz-Badges --- */
.dist-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
    align-items: center;
}
.dist-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}
.dist-car     { background: #d5edff; color: #1a5276; }
.dist-transit { background: #d4efdf; color: #1d6a3a; }
.dist-straight{ background: #f5f0e0; color: #7d6608; }
.dist-pending { background: #f3f3f3; color: #888; }
.dist-hint    { font-size: 0.78rem; color: var(--color-muted); margin-left: 4px; }
/* Table column variants */
.dist-col     { font-size: 0.88rem; color: #555; white-space: nowrap; }
.grade-col    { text-align: center; }
.rank-col     { width: 40px; text-align: center; font-weight: 700; color: var(--color-muted); }
.center-col   { text-align: center; }
.school-link  { color: var(--color-accent); font-weight: 500; text-decoration: none; }
.school-link:hover { text-decoration: underline; }

/* --- Grade Badge --- */
.grade-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 4px;
    font-weight: 700;
    color: white;
}
.grade-empty { color: #aaa; font-size: 0.88rem; }

/* --- Schulform Badge --- */
.sf-badge {
    display: inline-block;
    background: #e8edf2;
    color: #2c3e50;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 0.78rem;
    font-weight: 500;
}

/* --- Ranking Wrap (Desktop-Tabelle / Mobile-Cards) --- */
.ranking-wrap {
    overflow-x: auto;
}
.ranking-table {
    display: table;
    min-width: 600px;
}
.ranking-cards {
    display: none; /* shown at ≤768px via media query */
    grid-template-columns: 1fr;
    gap: 0.75rem;
}
.r-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow);
}
.r-card-top {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}
.r-card-name {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-accent);
    text-decoration: none;
    margin-bottom: 0.2rem;
}
.r-card-name:hover { text-decoration: underline; }
.r-card-meta {
    font-size: 0.88rem;
    color: var(--color-muted);
    margin-bottom: 0.35rem;
}
.r-card-footer {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: #555;
    border-top: 1px solid #f0f0f0;
    padding-top: 0.4rem;
    margin-top: 0.35rem;
}

/* --- Filter Panel (Ranking) --- */
.filter-panel {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.filter-toggle {
    width: 100%;
    background: #f8f9fb;
    border: none;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    color: var(--color-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.filter-toggle:hover { background: #edf0f4; }
.filter-body {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: flex-end;
}
.filter-row label {
    font-size: 0.88rem;
    color: var(--color-muted);
    display: block;
    margin-bottom: 0.2rem;
}
.filter-row select,
.filter-row input[type="number"] {
    width: auto;
    min-width: 130px;
    padding: 0.4rem 0.7rem;
}

/* --- Sort Links (Ranking) --- */
.result-count {
    font-size: 0.88rem;
    color: var(--color-muted);
    margin-bottom: 0.75rem;
}
.sort-link {
    color: var(--color-accent);
    font-size: 0.82rem;
    text-decoration: none;
    white-space: nowrap;
}
.sort-link:hover { text-decoration: underline; }
.sort-active {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* --- Pagination --- */
.pag-ellipsis { color: #aaa; padding: 0 4px; }

/* ===================================================
   MAP PAGE – kompakter Filter-Balken
   =================================================== */
.map-page-header {
    background: #fff;
    border-bottom: 1px solid var(--color-border);
}
.map-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
    padding: 0.5rem 1rem;
    max-width: 100%;
}
.map-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    position: relative;
}
.map-filter-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-muted);
    white-space: nowrap;
    margin-right: 2px;
}
.map-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f1f3f6;
    border: 1px solid #d5dae0;
    border-radius: 20px;
    padding: 3px 9px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background 0.12s, border-color 0.12s;
    margin-bottom: 0;
}
.map-chip:hover { background: #e4e8ef; }
.map-chip input { accent-color: var(--color-accent); cursor: pointer; }
.map-filter-toggle-btn {
    background: #f1f3f6;
    border: 1px solid #d5dae0;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    white-space: nowrap;
}
.map-filter-toggle-btn:hover { background: #e4e8ef; }
.map-bl-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.6rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 500;
    flex-wrap: wrap;
    gap: 0.3rem;
    max-width: 380px;
}
.map-bl-panel.open { display: flex; }

/* ===================================================
   BEWERTUNGSFORMULAR
   =================================================== */
.bw-form-page { max-width: 780px; }

.bw-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.92rem;
    line-height: 1.5;
}
.bw-alert-success {
    background: #d4edda;
    border-left: 4px solid #28a745;
    color: #155724;
}
.bw-alert-error {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    color: #721c24;
}
.bw-alert-info {
    background: #e8f4fd;
    border-left: 4px solid var(--color-accent);
    color: #1a4f72;
}

.bw-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.bw-card-title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.bw-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.25rem;
}
@media (max-width: 600px) {
    .bw-form-row { grid-template-columns: 1fr; }
}

.bw-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}
.bw-form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
}
.bw-form-group input[type="text"],
.bw-form-group input[type="email"],
.bw-form-group input[type="number"],
.bw-form-group input[type="file"],
.bw-form-group select,
.bw-form-group textarea {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: white;
    color: var(--color-primary);
    width: 100%;
    box-sizing: border-box;
}
.bw-form-group textarea {
    resize: vertical;
    min-height: 80px;
}
.bw-form-group input:focus,
.bw-form-group select:focus,
.bw-form-group textarea:focus {
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(41,128,185,0.2);
}

.bw-help    { font-size: 0.78rem; color: var(--color-muted); }
.bw-optional { font-weight: 400; color: var(--color-muted); font-size: 0.85em; }
.req        { color: #dc3545; margin-left: 1px; }

/* Slider */
.bw-slider-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.bw-slider {
    flex: 1;
    height: 8px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 4px;
    outline: none;
    background: linear-gradient(to right, #28a745 100%, #e0e0e0 100%); /* wird per JS überschrieben */
    transform: scaleX(-1); /* 1 = rechts (beste Note), 6 = links */
}
.bw-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #aaa;
    border-radius: 50%;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.bw-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 5px rgba(0,0,0,0.1);
}
.bw-slider::-moz-range-track {
    height: 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
}
.bw-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #aaa;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: none;
}
.bw-slider-label-left,
.bw-slider-label-right {
    font-size: 0.78rem;
    color: var(--color-muted);
    white-space: nowrap;
}
.bw-slider-value {
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-accent);
    margin-top: 0.2rem;
}
.bw-cat-group { padding-bottom: 0.6rem; border-bottom: 1px solid #f0f0f0; }
.bw-cat-group:last-child { border-bottom: none; }
.bw-cat-val {
    min-width: 2.5ch;
    color: var(--color-accent);
    font-size: 0.95rem;
}

/* Studienfächer-Grid */
.bw-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.35rem;
}
.bw-check-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: background 0.1s;
    margin-bottom: 0;
}
.bw-check-label:hover { background: #f0f4f8; border-color: var(--color-border); }
.bw-check-label input { accent-color: var(--color-accent); cursor: pointer; }

/* Submit button */
.btn-primary-lg {
    background: var(--color-accent);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary-lg:hover { background: #1f6392; }

/* Schulform badge color variants */
.sf-prim  { background: #cfe2ff; color: #084298; }
.sf-sek_1 { background: #d1e7dd; color: #0f5132; }
.sf-gym   { background: #f8d7da; color: #842029; }
.sf-sop_d { background: #fff3cd; color: #664d03; } /* Sopäd */
.sf-bs    { background: #e2d9f3; color: #432874; }

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    justify-content: center;
    margin: 1.5rem 0;
}
.pagination a,
.pagination span {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--color-accent);
    background: white;
}
.pagination a:hover { background: #e8f2fb; }
.pagination span.current {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    font-weight: 700;
}

