/* SimpleRental - Basis-Stylesheet
   Modernes, minimalistisches Design-System auf Basis von CSS-Variablen. */

:root {
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-surface-alt: #f0f1f4;
    --color-border: #e2e4e9;
    --color-text: #1c1f26;
    --color-text-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-soft: #eaf0fe;
    --color-success: #16a34a;
    --color-success-soft: #e8f8ee;
    --color-warning: #d97706;
    --color-warning-soft: #fef3e2;
    --color-danger: #dc2626;
    --color-danger-soft: #fdecec;
    --color-gray-planned: #9aa1ad;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);
    --sidebar-width: 248px;
    --header-height: 60px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
}
h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.75em; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--color-text-muted); }
strong { font-weight: 650; }

img { max-width: 100%; }

/* ---------------------------------------------------------------- */
/* App-Shell / Navigation                                            */
/* ---------------------------------------------------------------- */

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

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.1rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: 1px solid var(--color-border);
}
.sidebar__brand .logo-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-soft);
}

.sidebar__nav { flex: 1; padding: 0.75rem 0.6rem; overflow-y: auto; }
.sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 2px;
}
.sidebar__nav a svg { width: 19px; height: 19px; flex-shrink: 0; opacity: 0.75; }
.sidebar__nav a:hover { background: var(--color-surface-alt); }
.sidebar__nav a.is-active { background: var(--color-primary-soft); color: var(--color-primary-hover); }
.sidebar__nav a.is-active svg { opacity: 1; }

.sidebar__footer {
    padding: 0.9rem 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
}
.sidebar__user { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.sidebar__avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--color-primary-soft); color: var(--color-primary-hover);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15, 18, 25, 0.4);
    z-index: 35; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    height: var(--header-height);
    background: rgba(245, 246, 248, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1rem;
}
.hamburger {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    border: 1px solid var(--color-border); background: var(--color-surface);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    flex-shrink: 0;
}
.hamburger span, .hamburger::before, .hamburger::after {
    /* handled via svg icon in markup */
}
.topbar__title { font-weight: 650; font-size: 1.05rem; flex: 1; }

.app-main {
    flex: 1;
    width: 100%;
    padding: 1.1rem 1rem 3rem;
    max-width: 1180px;
    margin: 0 auto;
}

@media (min-width: 900px) {
    .sidebar { transform: none; position: fixed; }
    .app-shell { padding-left: var(--sidebar-width); }
    .hamburger { display: none; }
    .sidebar-backdrop { display: none; }
    .topbar__title { font-size: 1.2rem; }
    .app-main { padding: 1.75rem 2.25rem 3.5rem; }
}

/* ---------------------------------------------------------------- */
/* Layout-Hilfen                                                     */
/* ---------------------------------------------------------------- */

.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-header__text p { margin: 0.15rem 0 0; color: var(--color-text-muted); }

.grid { display: grid; gap: 1rem; }
.grid-cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.space-between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- */
/* Karten / Buttons / Formulare                                      */
/* ---------------------------------------------------------------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.card--tight { padding: 1rem; }

.stat-card { display: flex; flex-direction: column; gap: 0.35rem; }
.stat-card__value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-card__label { color: var(--color-text-muted); font-size: 0.85rem; }
.stat-card--warning .stat-card__value { color: var(--color-warning); }
.stat-card--danger .stat-card__value { color: var(--color-danger); }
.stat-card--primary .stat-card__value { color: var(--color-primary); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 0.6rem 1.05rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--color-surface-alt);
    color: var(--color-text);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { text-decoration: none; background: #e6e8ec; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-outline { background: transparent; border-color: var(--color-border); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 0.38rem 0.7rem; font-size: 0.82rem; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.field label { font-weight: 600; font-size: 0.86rem; }
.field .hint { font-size: 0.78rem; color: var(--color-text-muted); }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=number], input[type=search], select, textarea {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; gap: 0.9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-row input { width: auto; }

.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.55rem; border-radius: 999px;
    font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em;
    background: var(--color-surface-alt); color: var(--color-text-muted);
}
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary-hover); }
.badge-gray { background: #eef0f3; color: var(--color-gray-planned); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.6rem; border-bottom: 1px solid var(--color-border); font-size: 0.9rem; }
th { color: var(--color-text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.table-link-row { cursor: pointer; }
.table-link-row:hover { background: var(--color-surface-alt); }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--color-text-muted); }

/* ---------------------------------------------------------------- */
/* Flash / Toasts                                                    */
/* ---------------------------------------------------------------- */

.flash-stack { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.flash {
    padding: 0.7rem 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500;
    border: 1px solid transparent;
}
.flash-success { background: var(--color-success-soft); color: #0e6b31; border-color: #bfe8cc; }
.flash-error { background: var(--color-danger-soft); color: #9c1c1c; border-color: #f3c1c1; }
.flash-info { background: var(--color-primary-soft); color: #1d4ed8; border-color: #c7d9fb; }

#toast-stack {
    position: fixed; bottom: 1.1rem; left: 50%; transform: translateX(-50%);
    z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
    width: min(92vw, 420px);
}
.toast {
    background: var(--color-text); color: #fff; padding: 0.65rem 1rem; border-radius: 999px;
    font-size: 0.86rem; font-weight: 600; box-shadow: var(--shadow-md);
    animation: toast-in 0.18s ease;
    display: flex; align-items: center; gap: 0.5rem;
}
.toast.toast-error { background: var(--color-danger); }
.toast.toast-success { background: var(--color-success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------- */
/* Popovers / Modals                                                 */
/* ---------------------------------------------------------------- */

.overlay {
    position: fixed; inset: 0; background: rgba(15, 18, 25, 0.5);
    display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.overlay.is-open { display: flex; }
.popover {
    background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
    padding: 1.25rem;
}
.popover--wide { max-width: 640px; }
.popover__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.popover__header h3 { margin: 0; }
.popover__close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--color-text-muted); line-height: 1; padding: 0.2rem; }
.popover__actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.1rem; }

/* ---------------------------------------------------------------- */
/* Scan-Oberflaeche                                                   */
/* ---------------------------------------------------------------- */

.scan-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: stretch; }
.scan-bar input[type=text] { flex: 1; min-width: 160px; font-size: 1rem; padding: 0.7rem 0.85rem; }
.scan-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.scan-actions .btn { flex: 1; }
.scan-mode-banner {
    display: none; align-items: center; gap: 0.5rem;
    background: var(--color-warning-soft); color: var(--color-warning);
    padding: 0.5rem 0.8rem; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600;
    margin-top: 0.6rem;
}
.scan-mode-banner.is-active { display: flex; }
.scan-mode-banner button { margin-left: auto; }

.item-list { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 1rem; }
.item-row {
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
    padding: 0.75rem 0.9rem;
}
.item-row.is-planned { background: var(--color-surface-alt); border-style: dashed; }
.item-row.is-complete { border-color: #cfe9d8; }
.item-row__top { display: flex; align-items: center; gap: 0.6rem; }
.item-row__name { font-weight: 650; flex: 1; }
.item-row.is-planned .item-row__name { color: var(--color-gray-planned); }
.item-row__meta { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.15rem; }
.item-row__qty { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.item-row__actions { display: flex; gap: 0.3rem; }
.item-row__units { margin: 0.5rem 0 0; padding-left: 0.9rem; list-style: none; }
.item-row__units li {
    font-style: italic; font-size: 0.82rem; color: var(--color-text-muted);
    padding: 0.15rem 0; display: flex; align-items: center; gap: 0.4rem;
}
.item-row__units li.status-defect { color: var(--color-danger); }
.item-row__units li.status-missing { color: var(--color-warning); }
.item-row__units li.status-returned { color: var(--color-success); }
.item-row__bundle-tag { font-size: 0.72rem; color: var(--color-primary); font-weight: 600; }

.camera-scan-frame {
    width: 100%; border-radius: var(--radius-md); overflow: hidden; background: #000;
    aspect-ratio: 4 / 3; position: relative;
}
#qr-reader-region { width: 100%; height: 100%; }
.camera-hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.5rem; text-align: center; }
.camera-last-scan {
    margin-top: 0.6rem; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm);
    background: var(--color-success-soft); color: var(--color-success); font-weight: 600; font-size: 0.85rem;
    display: none;
}
.camera-last-scan.is-visible { display: block; }

/* Unterschriftsfeld */
.signature-pad-wrap { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: #fff; touch-action: none; }
.signature-pad-wrap canvas { width: 100%; height: 220px; display: block; cursor: crosshair; touch-action: none; }

/* Ausweis-Upload */
.upload-tile {
    border: 1.5px dashed var(--color-border); border-radius: var(--radius-md);
    padding: 0.9rem; text-align: center; background: var(--color-surface-alt);
    cursor: pointer; position: relative;
}
.upload-tile img { max-height: 130px; border-radius: var(--radius-sm); margin-bottom: 0.4rem; }
.upload-tile input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Login */
.auth-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 1.5rem; background: radial-gradient(circle at top, #eef2ff, var(--color-bg) 60%);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .card { padding: 2rem 1.75rem; }
.auth-brand { display: flex; align-items: center; gap: 0.6rem; justify-content: center; margin-bottom: 1.5rem; font-weight: 700; font-size: 1.2rem; }
.auth-divider { display: flex; align-items: center; gap: 0.7rem; color: var(--color-text-muted); font-size: 0.78rem; margin: 1.1rem 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }
.auth-links { display: flex; justify-content: space-between; font-size: 0.85rem; margin-top: 0.9rem; }

.status-pill { display:inline-flex; align-items:center; gap:0.3rem; font-size:0.78rem; font-weight:700; padding:0.22rem 0.6rem; border-radius:999px; }
.status-draft { background:#eef0f3; color:#586071; }
.status-issued { background: var(--color-primary-soft); color: var(--color-primary-hover); }
.status-returned { background: var(--color-success-soft); color: var(--color-success); }
.status-cancelled { background: var(--color-danger-soft); color: var(--color-danger); }

.helper-text { color: var(--color-text-muted); font-size: 0.85rem; }
.divider { height: 1px; background: var(--color-border); margin: 1.1rem 0; border: none; }

@media (max-width: 560px) {
    .popover__actions { flex-direction: column-reverse; }
    .popover__actions .btn { width: 100%; }
}
