/* ================================================================
   WAWi – gesundesgemuese.de
   App CSS v0.1
   ================================================================ */

:root {
    --sidebar-w: 220px;
    --accent:    #27ae60;
    --accent-dk: #1e8449;
    --sidebar-bg:#1a2332;
    --sidebar-txt:#b8c9d9;
    --sidebar-active-bg: rgba(39,174,96,.15);
    --sidebar-active-txt: #27ae60;
    --body-bg:   #f0f2f5;
    --card-bg:   #ffffff;
    --border:    #e2e8f0;
    --text:      #1a202c;
    --text-muted:#718096;
    --danger:    #e53e3e;
    --warning:   #d69e2e;
    --info:      #3182ce;
    --radius:    10px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

/* ----------------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--body-bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ----------------------------------------------------------------
   Layout
   ---------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ----------------------------------------------------------------
   Sidebar
   ---------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-txt);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 18px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo {
    display: block;
    width: 140px;
    height: auto;
    opacity: .92;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13.5px;
    color: var(--sidebar-txt);
    cursor: pointer;
    border-radius: 0;
    transition: background .15s, color .15s;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: rgba(255,255,255,.05);
    color: #fff;
    text-decoration: none;
}
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-txt);
    border-left-color: var(--accent);
    font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.07);
    font-size: 12px;
    color: #5a7080;
}
.sidebar-user {
    font-weight: 600;
    color: var(--sidebar-txt);
    font-size: 13px;
    margin-bottom: 2px;
}
.sidebar-role {
    font-size: 11px;
    color: #4a6070;
    text-transform: capitalize;
    margin-bottom: 8px;
}
.sidebar-footer a {
    color: #5a7080;
    font-size: 12px;
}
.sidebar-footer a:hover { color: var(--danger); }

/* ----------------------------------------------------------------
   Main Content
   ---------------------------------------------------------------- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.page-header h1 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}
.page-header .header-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.page-body {
    padding: 24px 28px;
    flex: 1;
}

/* ----------------------------------------------------------------
   Cards
   ---------------------------------------------------------------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* KPI-Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}
.kpi-unit {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}
.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.kpi-card.accent .kpi-value { color: var(--accent); }
.kpi-card.danger .kpi-value { color: var(--danger); }
.kpi-card.warning .kpi-value { color: var(--warning); }

/* ----------------------------------------------------------------
   Grid-Hilfklassen
   ---------------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
table.data-table thead th {
    background: #f7f9fc;
    border-bottom: 2px solid var(--border);
    padding: 10px 14px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    white-space: nowrap;
}
table.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
table.data-table tbody tr:hover { background: #f9fafb; }
table.data-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
}
table.data-table tbody tr:last-child { border-bottom: none; }

/* ----------------------------------------------------------------
   Badges / Status
   ---------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-green  { background: #d4edda; color: #155724; }
.badge-yellow { background: #fff3cd; color: #856404; }
.badge-red    { background: #f8d7da; color: #721c24; }
.badge-blue   { background: #cce5ff; color: #004085; }
.badge-gray   { background: #e9ecef; color: #495057; }

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; filter: brightness(.93); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: #e9ecef; color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-sm        { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }
.btn-icon      { padding: 6px; border-radius: 6px; }

/* ----------------------------------------------------------------
   Forms
   ---------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color .15s;
    line-height: 1.5;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(39,174,96,.12);
}
.form-control::placeholder { color: #a0aec0; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ----------------------------------------------------------------
   Alerts
   ---------------------------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 16px;
    border: 1px solid;
}
.alert-success { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.alert-danger  { background: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.alert-warning { background: #fff3cd; border-color: #ffeeba; color: #856404; }
.alert-info    { background: #d1ecf1; border-color: #bee5eb; color: #0c5460; }

/* ----------------------------------------------------------------
   Progress Bar (Limit-Auslastung)
   ---------------------------------------------------------------- */
.progress-bar-wrap {
    background: #e9ecef;
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width .3s ease;
}
.progress-bar.warn  { background: var(--warning); }
.progress-bar.crit  { background: var(--danger); }

/* ----------------------------------------------------------------
   Divider / Helpers
   ---------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ----------------------------------------------------------------
   Spinner
   ---------------------------------------------------------------- */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------
   Login Page
   ---------------------------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px;
    box-shadow: 0 20px 40px rgba(0,0,0,.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo .logo-icon {
    width: 52px; height: 52px;
    background: var(--accent);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-size: 24px;
}
.login-logo h1 {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
}
.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ----------------------------------------------------------------
   Modal Backdrop
   ---------------------------------------------------------------- */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.38);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    isolation: isolate;
}
.modal-backdrop > div {
    position: relative;
    z-index: 9001;
    background: #ffffff;
}

/* ----------------------------------------------------------------
   Responsive (Tablet ≤ 900px → Bottom Nav)
   ---------------------------------------------------------------- */
@media (max-width: 900px) {
    .sidebar {
        width: 100%;
        height: 60px;
        top: auto;
        bottom: 0;
        left: 0;
        flex-direction: row;
        align-items: center;
    }
    .sidebar-brand, .sidebar-footer { display: none; }
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        padding: 0;
        width: 100%;
        justify-content: space-around;
        overflow: hidden;
    }
    .nav-item {
        flex-direction: column;
        gap: 3px;
        padding: 8px 6px;
        font-size: 10px;
        border-left: none;
        border-top: 3px solid transparent;
        flex: 1;
        justify-content: center;
        align-items: center;
        text-align: center;
    }
    .nav-item.active { border-top-color: var(--accent); border-left-color: transparent; }
    .nav-item svg { width: 22px; height: 22px; }

    .main-content { margin-left: 0; margin-bottom: 60px; }
    .page-body { padding: 16px; }
    .page-header { padding: 12px 16px; position: static; }
    .grid-2, .grid-3, .kpi-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
