/* =========================================================================
   Feuerwehr E-Learning – Stylesheet
   ========================================================================= */

:root {
    --fw-red:        #c1121f;
    --fw-red-dark:   #9a0e18;
    --fw-dark:       #1d1d1f;
    --fw-gray:       #6b7280;
    --fw-light:      #f4f5f7;
    --fw-border:     #e2e4e8;
    --fw-white:      #ffffff;
    --fw-success:    #2e7d32;
    --fw-success-bg: #e6f4ea;
    --fw-error:      #c62828;
    --fw-error-bg:   #fdecea;
    --fw-warn:       #b26a00;
    --fw-warn-bg:    #fff4e0;
    --radius:        10px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg:     0 8px 24px rgba(0,0,0,.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--fw-dark);
    background: var(--fw-light);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--fw-red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────────────────────────── */
.site-header {
    background: var(--fw-red);
    color: #fff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.6rem; }
.brand-logo { height: 40px; width: auto; border-radius: 6px; background:#fff; padding:2px; }
.main-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.main-nav > a { color: #fff; font-weight: 500; }
.nav-user { display: flex; align-items: center; gap: .75rem; }
.nav-username { opacity: .9; font-size: .9rem; }
.btn-logout {
    background: rgba(255,255,255,.18);
    color: #fff;
    padding: .35rem .8rem;
    border-radius: 6px;
    font-size: .85rem;
}
.btn-logout:hover { background: rgba(255,255,255,.3); text-decoration: none; }

/* Suchfeld in der Navigation */
.nav-search { display: flex; align-items: center; }
.nav-search input {
    width: 180px;
    padding: .4rem .7rem;
    border: none;
    border-radius: 6px 0 0 6px;
    font-size: .85rem;
    background: rgba(255,255,255,.95);
}
.nav-search button {
    border: none;
    background: rgba(0,0,0,.18);
    color: #fff;
    padding: .4rem .7rem;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-size: .85rem;
}
.nav-search button:hover { background: rgba(0,0,0,.3); }

/* Suchergebnisse */
.search-result {
    background: var(--fw-white);
    border: 1px solid var(--fw-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    margin-bottom: .8rem;
}
.search-result a.result-title { font-weight: 600; font-size: 1.05rem; }
.search-result .result-meta { font-size: .8rem; color: var(--fw-gray); margin: .15rem 0 .4rem; }
.search-result .result-snippet { font-size: .9rem; color: #444; margin: 0; }
mark { background: #ffe9a8; color: inherit; padding: 0 .1em; border-radius: 2px; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.site-main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0; font-size: 1.6rem; }

/* ── Breadcrumb ───────────────────────────────────────────────────────── */
.breadcrumb {
    font-size: .9rem;
    color: var(--fw-gray);
    margin-bottom: 1rem;
}
.breadcrumb a { color: var(--fw-gray); }
.breadcrumb span { margin: 0 .35rem; }

/* ── Cards / Grid ─────────────────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}
.card {
    background: var(--fw-white);
    border: 1px solid var(--fw-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card a.card-link { display: block; color: inherit; padding: 1.1rem; }
.card a.card-link:hover { text-decoration: none; }
.card-icon { font-size: 1.8rem; margin-bottom: .4rem; }
.card-title { font-weight: 600; font-size: 1.05rem; margin: 0 0 .25rem; }
.card-desc { color: var(--fw-gray); font-size: .9rem; margin: 0; }
.card-thumb { width: 100%; height: 150px; object-fit: cover; display:block; background:#eee; }
.card-meta { font-size: .78rem; color: var(--fw-gray); padding: 0 1.1rem 1rem; }

/* ── Panels / Inhalt ──────────────────────────────────────────────────── */
.panel {
    background: var(--fw-white);
    border: 1px solid var(--fw-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.panel h2 { margin-top: 0; }
.content-body { font-size: 1rem; }
.content-body img { max-width: 100%; height: auto; border-radius: 8px; }

/* ── Medien ───────────────────────────────────────────────────────────── */
.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .75rem;
    margin: 1rem 0;
}
.media-gallery img { width: 100%; height: 160px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.media-gallery figure { margin: 0; }
.media-gallery figcaption { font-size: .82rem; color: var(--fw-gray); margin-top: .35rem; text-align: center; line-height: 1.3; }
.media-video, .media-embed iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 8px;
}
.pdf-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--fw-light);
    border: 1px solid var(--fw-border);
    border-radius: 8px;
    padding: .6rem .9rem;
    margin: .25rem .25rem 0 0;
    color: var(--fw-dark);
    font-weight: 500;
}
.pdf-link:hover { background: #ececef; text-decoration: none; }

/* ── Tabellen ─────────────────────────────────────────────────────────── */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--fw-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
table.data th, table.data td {
    text-align: left;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--fw-border);
    font-size: .92rem;
}
table.data th { background: var(--fw-light); font-weight: 600; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafafa; }

/* ── Beladungsliste / Gerätefächer ────────────────────────────────────── */
.compartment {
    background: var(--fw-white);
    border: 1px solid var(--fw-border);
    border-left: 4px solid var(--fw-red);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.compartment-head {
    padding: .8rem 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--fw-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.compartment-head small { color: var(--fw-gray); font-weight: 400; }

/* ── Formulare ────────────────────────────────────────────────────────── */
form .field { margin-bottom: 1.1rem; }
form label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .92rem; }
form .hint { color: var(--fw-gray); font-size: .82rem; font-weight: 400; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], select, textarea {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--fw-border);
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--fw-red);
    box-shadow: 0 0 0 3px rgba(193,18,31,.12);
}
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 200px; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; }
.checkbox-row input { width: auto; }
.checkbox-list { display:flex; flex-direction:column; gap:.4rem; max-height:220px; overflow:auto;
    border:1px solid var(--fw-border); border-radius:8px; padding:.6rem; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--fw-red);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .6rem 1.1rem;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s ease;
}
.btn:hover { background: var(--fw-red-dark); text-decoration: none; color:#fff; }
.btn-secondary { background: #e8e8eb; color: var(--fw-dark); }
.btn-secondary:hover { background: #dcdce0; color: var(--fw-dark); }
.btn-danger { background: var(--fw-error); }
.btn-danger:hover { background: #a31515; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Flash-Nachrichten ────────────────────────────────────────────────── */
.flash {
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .92rem;
    border: 1px solid transparent;
}
.flash-success { background: var(--fw-success-bg); color: var(--fw-success); border-color:#bfe3c6; }
.flash-error   { background: var(--fw-error-bg);   color: var(--fw-error);   border-color:#f5c6c0; }
.flash-warning { background: var(--fw-warn-bg);    color: var(--fw-warn);    border-color:#f3dca6; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: var(--fw-light);
    color: var(--fw-gray);
}
.badge-admin { background: #fde7e9; color: var(--fw-red); }
.badge-on    { background: var(--fw-success-bg); color: var(--fw-success); }
.badge-off   { background: #eee; color: var(--fw-gray); }

/* ── Login ────────────────────────────────────────────────────────────── */
.auth-wrap {
    max-width: 400px;
    margin: 4rem auto;
}
.auth-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}
.auth-card h1 { text-align: center; margin-top: 0; font-size: 1.4rem; }
.auth-logo { text-align: center; font-size: 2.5rem; margin-bottom: .5rem; }

/* ── Admin-Tabs ───────────────────────────────────────────────────────── */
.admin-tabs {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--fw-border);
}
.admin-tabs a {
    padding: .6rem 1rem;
    color: var(--fw-gray);
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.admin-tabs a:hover { text-decoration: none; color: var(--fw-dark); }
.admin-tabs a.active { color: var(--fw-red); border-bottom-color: var(--fw-red); }

/* ── Footer ───────────────────────────────────────────────────────────── */
.site-footer {
    background: var(--fw-dark);
    color: #cfcfd4;
    font-size: .85rem;
    padding: 1.1rem 1.25rem;
    margin-top: auto;
}
.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: center;
}
.site-footer a { color: #fff; }
.footer-sep { opacity: .4; }

/* ── Hilfsklassen ─────────────────────────────────────────────────────── */
.muted { color: var(--fw-gray); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.empty-state {
    text-align: center;
    color: var(--fw-gray);
    padding: 3rem 1rem;
}
.empty-state .big { font-size: 2.5rem; display:block; margin-bottom:.5rem; }
.actions-cell { white-space: nowrap; display:flex; gap:.4rem; }

/* ── Lightbox ─────────────────────────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92%; max-height: 92%; border-radius: 8px; }

/* ── Mobile / Responsive ──────────────────────────────────────────────── */
@media (max-width: 760px) {
    .site-main { padding: 1.1rem .9rem 2.5rem; }

    /* Header nicht klebend – spart Platz beim Scrollen */
    .site-header { position: static; }
    .header-inner { height: auto; padding: .55rem .9rem; flex-wrap: wrap; gap: .5rem; }
    .brand-name { font-size: 1.02rem; }

    /* Navigation bricht unter das Logo um */
    .main-nav { width: 100%; flex-wrap: wrap; gap: .55rem .9rem; align-items: center; }
    .nav-user { margin-left: auto; }
    .nav-username { display: none; }
    .nav-search { order: 5; flex: 1 0 100%; }
    .nav-search input { width: 100%; flex: 1; }

    /* Seitenkopf */
    .page-head { gap: .5rem; }
    .page-head h1 { font-size: 1.3rem; }

    /* Panels & Abstände kompakter */
    .panel { padding: 1.1rem; }

    /* Eingaben: 16px verhindert automatisches Hineinzoomen auf iOS */
    input[type=text], input[type=email], input[type=password], input[type=number],
    input[type=url], input[type=search], select, textarea { font-size: 16px; }

    /* Formularzeilen untereinander stapeln (überschreibt feste Inline-Breiten) */
    .form-row { flex-direction: column; gap: 0; }
    .form-row > .field { width: 100%; min-width: 0; flex: 1 1 auto !important; }

    /* Breite Tabellen horizontal scrollbar machen */
    table.data { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

    /* Verwaltungs-Tabs: horizontal wischbar statt umbrechen */
    .admin-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-tabs a { white-space: nowrap; }

    /* Aktions-Buttons in Tabellen dürfen umbrechen */
    .actions-cell { flex-wrap: wrap; }

    /* Gerätefach-Kopf umbricht bei langen Bezeichnungen */
    .compartment-head { flex-wrap: wrap; gap: .2rem; }

    /* Karten passen sich automatisch an (1 Spalte auf schmalen Geräten) */
    .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    /* Bildergalerie kompakter, damit mehrere Vorschaubilder nebeneinander passen */
    .media-gallery { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

    /* Anmelde-/Reset-Karten näher am oberen Rand */
    .auth-wrap { margin: 1.5rem auto; }
    .auth-card { padding: 1.5rem; }
}

/* Sehr kleine Geräte */
@media (max-width: 380px) {
    .brand-name { font-size: .95rem; }
    .btn { padding: .55rem .9rem; }
    .btn-sm { padding: .35rem .6rem; }
}
