/* Zeiterfassung – Basis-Styling */

:root {
    /* Abgeschwächte Markenfarben, abgeleitet aus dem Bob Run-Logo
       (Grün-/Petrolton des Schwungs, per Sättigung/Helligkeit gedämpft
       für den Einsatz als UI-Akzentfarbe statt Neon-Ton). */
    --color-primary: #1e815f;
    --color-primary-dark: #156147;
    --color-text: #1f2937;
    --color-muted: #6b7280;
    --color-border: #d1d5db;
    --color-bg: #f5f6f8;
    --color-card: #ffffff;
    --color-success-bg: #e8f7f1;
    --color-success-text: #135941;
    --color-error-bg: #fef2f2;
    --color-error-text: #b91c1c;
    /* Warmer Akzent (Gelb/Orange aus dem Logo), gedämpft – für den
       Wochenend-Hintergrund in der Erfassung/im Rapport. */
    --color-weekend-bg: #fff8e8;
    /* Kompletter Farbverlauf des Logo-Schwungs, für den dezenten
       Akzentstreifen am oberen Seitenrand. */
    --brand-gradient: linear-gradient(90deg, #ffe14d 0%, #ffc33c 28%, #6be8b8 62%, #1e815f 100%);
    --radius: 6px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
}

/* Dezenter Marken-Farbverlauf am oberen Rand jeder Seite. */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--brand-gradient);
    z-index: 1000;
}

a { color: var(--color-primary); }

h1 { font-size: 1.5rem; margin: 0.4rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; color: var(--color-muted); }

/* Header / Navigation */
header {
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.7rem 1.2rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.8rem;
}
.header-left { display: flex; align-items: center; justify-content: flex-start; min-width: 0; }
.header-center { display: flex; align-items: center; justify-content: center; gap: 0.6rem; }
.header-right { display: flex; align-items: center; justify-content: flex-end; gap: 0.8rem; flex-wrap: wrap; min-width: 0; }
.brand { font-weight: 600; white-space: nowrap; }
header nav { display: flex; align-items: center; gap: 1rem; }
header nav a { text-decoration: none; font-weight: 500; color: var(--color-text); }
header nav a:hover { color: var(--color-primary); text-decoration: underline; }
.user-info { color: var(--color-muted); font-size: 0.88rem; white-space: nowrap; }
.header-logo { height: 40px; width: auto; display: block; }
.header-logout { padding: 0.35rem 0.8rem; font-size: 0.85rem; }

/* Sprachumschalter (DE/IT) neben dem Abmelden-Button. */
.lang-switch { display: flex; align-items: center; gap: 0.3rem; }
.lang-switch .inline-form { display: inline-flex; }
.lang-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-card);
    color: var(--color-muted);
    cursor: pointer;
}
.lang-btn:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.lang-btn--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    cursor: default;
}

@media (max-width: 640px) {
    .header-inner { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .header-left, .header-right { justify-content: center; }
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.2rem;
}

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
}
.login-box {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.login-box h1 { font-size: 1.25rem; margin-top: 0; }
/* Der "Anmelden"-Button steht im Markup direkt nach dem Passwort-Feld
   (ohne umschliessendes Element) und bekommt sonst keinen Abstand nach
   oben ab, dadurch klebt er am Eingabefeld. */
.login-box button[type="submit"] { margin-top: 1rem; }
.subtitle { color: var(--color-muted); margin-top: -0.6rem; }
.hint { color: var(--color-muted); font-size: 0.85rem; }

/* Forms */
label { display: block; font-weight: 500; margin: 0.7rem 0 0.2rem; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=time], input[type=number], select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.form-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    max-width: 700px;
}
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 160px; }
.form-row > div.grow { flex: 2; }
.form-actions { margin-top: 1.2rem; display: flex; gap: 0.6rem; }
.inline-form { display: inline-flex; gap: 0.4rem; align-items: center; }

button, .button, .button-secondary {
    display: inline-block;
    padding: 0.55rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}
button, .button {
    background: var(--color-primary);
    color: #fff;
}
button:hover, .button:hover { background: var(--color-primary-dark); }
.button-secondary {
    background: #fff;
    color: var(--color-text);
    border-color: var(--color-border);
}
.button-secondary:hover { background: #f0f1f3; }
.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-primary);
    text-decoration: underline;
    font: inherit;
    cursor: pointer;
}
.link-button.danger { color: var(--color-error-text); }

.alert { padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: var(--color-error-bg); color: var(--color-error-text); }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }

/* Page head with action button */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.6rem; }

/* Tables – schlankes, modernes Zeilenraster (Karten-Look statt Excel-Gitter),
   passend zur Login-Maske. Ausnahme: der gedruckte Rapport behält sein
   volles Tabellenraster (siehe .report-tabelle weiter unten). */
table { border-collapse: collapse; width: 100%; background: var(--color-card); }
th, td { padding: 0.6rem 0.85rem; text-align: left; font-size: 0.92rem; border-bottom: 1px solid var(--color-border); }
thead th {
    background: rgba(30, 129, 95, 0.07);
    color: var(--color-primary-dark);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}
tbody tr:last-child > td { border-bottom: none; }
tbody tr:hover > td { background: rgba(30, 129, 95, 0.035); }
tfoot td, .report-total-row td { background: #f7f8fa; font-weight: 600; border-top: 2px solid var(--color-border); border-bottom: none; }
tfoot td:empty { display: none; }

/* Karten-Rahmen um Tabellen (gleiches "Setting" wie die Login-Maske:
   weisse Fläche, abgerundete Ecken, dezenter Schatten). */
.table-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    margin-top: 1rem;
}
.table-card table { margin: 0; }
.table-card thead th:first-child { border-top-left-radius: 9px; }
.table-card thead th:last-child { border-top-right-radius: 9px; }

/* Tabellen mit vielen Spalten (Mitarbeiterliste) auf schmalen Bildschirmen
   lieber horizontal scrollen lassen, statt Spalten kaputt zu quetschen. */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.entry-table tr.weekend td, .report-tabelle tr.weekend td { background: var(--color-weekend-bg); }
/* Heutiger Tag: dezent hervorgehoben, damit er auf einen Blick auffindbar
   ist (zusätzlich zum Auto-Scroll auf dem Handy, siehe timeentry.js).
   Der linke Akzentstreifen ist nur in der Desktop-Tabellenansicht aktiv;
   auf dem Handy übernimmt stattdessen der Karten-Rahmen unten (siehe
   @media max-width:700px) die Hervorhebung. */
@media (min-width: 701px) {
    .entry-table tr.today td { background: rgba(30, 129, 95, 0.06); }
    .entry-table tr.today td:first-child { box-shadow: inset 3px 0 0 var(--color-primary); }
}
.today-badge {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 0.3rem;
}
.entry-table .day-cell { white-space: nowrap; font-weight: 500; width: 6.5rem; }
.entry-table .time-input { width: 6.5rem; }
.entry-table .pause-input { width: 5rem; }
.entry-table .note-input { min-width: 10rem; width: 100%; }

/* Markiert Von/Bis, wenn in der Zeile ein Wert steht, das jeweils andere
   Feld aber (noch) fehlt – siehe assets/timeentry.js validateRow(). */
.entry-table .time-input.field-invalid {
    border-color: var(--color-error-text);
    background: var(--color-error-bg);
}
.entry-table .total-cell, .report-tabelle td:nth-child(6) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum-label { text-align: right; }

.status-col { width: 1%; white-space: nowrap; padding-left: 0.4rem; padding-right: 0.4rem; }
.save-status { font-size: 0.8rem; color: var(--color-muted); white-space: nowrap; }
.save-status--saving { color: var(--color-muted); }
.save-status--ok { color: var(--color-success-text); }
.save-status--error { color: var(--color-error-text); font-weight: 600; text-decoration: underline; }
.hint.no-print { margin: -0.4rem 0 0.8rem; }

.admin-table .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inactive-row { color: var(--color-muted); }

/* Aktions-Links in Tabellen als kleine Pillen statt nackter, aneinandergereihter
   Textlinks – wirkt aufgeräumter/weniger "roh". */
.pill-link {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(30, 129, 95, 0.08);
    color: var(--color-primary-dark);
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
}
.pill-link:hover { background: rgba(30, 129, 95, 0.16); }
.pill-link--danger { background: var(--color-error-bg); color: var(--color-error-text); }
.pill-link--danger:hover { background: #fde2e2; }

.month-nav {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}
/* Monat-/Jahr-Auswahl darf nicht auf Kosten der sichtbaren Beschriftung
   schrumpfen (sonst z.B. "September" -> "Septeml" in einem engen Flex-Item). */
.month-nav select { width: auto; min-width: 7.5rem; flex: 0 0 auto; }
.month-nav select[name="jahr"] { min-width: 5rem; }

/* Print report */
.report-toolbar { max-width: 900px; margin: 1rem auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
/* Monat/Jahr-Auswahl direkt im Rapport-Toolbar: übernimmt das .month-nav-Raster,
   soll aber keinen eigenen Aussenabstand einbringen (sitzt schon in der
   Toolbar, die ihren eigenen Abstand zur Umgebung hat). */
.report-month-form { margin: 0; }
.report-sheet {
    background: #fff;
    max-width: 900px;
    margin: 0 auto 2rem;
    padding: 2rem;
    border: 1px solid var(--color-border);
}
/* 3-spaltiger Kopf: links "Monatsrapport – Monat Jahr", mittig zentriert
   der Firmenname, rechts das Logo. Titel und Firmenname bewusst gleich
   gross/fett, damit beide gleichwertig wirken. */
.report-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; border-bottom: 2px solid var(--color-primary); padding-bottom: 0.8rem; margin-bottom: 1.4rem; }
.report-firma { font-weight: 700; font-size: 1.1rem; text-align: center; }
.report-titel { font-weight: 700; font-size: 1.1rem; text-align: left; }
.report-logo { height: 48px; width: auto; flex-shrink: 0; justify-self: end; }
.report-stammdaten { margin-bottom: 1.2rem; }
.report-stammdaten th { background: #f7f8fa; width: 9rem; }
.report-tabelle { font-size: 0.85rem; }
/* Der gedruckte Rapport behält sein volles Tabellenraster (Excel-artig),
   unabhängig vom schlankeren Zeilenraster der App-Ansicht oben. */
.report-tabelle th, .report-tabelle td,
.report-stammdaten th, .report-stammdaten td {
    border: 1px solid var(--color-border);
}
/* Die weiter oben für die schlanken App-Tabellen gedachte Regel
   "tbody tr:last-child > td { border-bottom: none; }" (Karten-Look ohne
   doppelten Abschlussstrich) würde sonst auch hier zuschlagen und die
   untere Linie der letzten Zeile wegnehmen – für das volle Excel-Raster
   des Rapports braucht es aber genau diese Linie (Stammdaten-Block unten,
   Totalzeile unten). Deshalb hier gezielt wieder aktiviert. */
.report-stammdaten tr:last-child th, .report-stammdaten tr:last-child td { border-bottom: 1px solid var(--color-border); }
.report-tabelle .report-total-row td { border-bottom: 1px solid var(--color-border); }
.report-tabelle thead th { background: #f0f2f5; color: var(--color-text); text-transform: none; letter-spacing: normal; font-size: 0.85rem; }
.report-signaturen { display: flex; gap: 3rem; margin-top: 3rem; }
.signatur-feld { flex: 1; }
.signatur-linie { border-top: 1px solid var(--color-text); margin-bottom: 0.3rem; height: 2.4rem; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    body::before { display: none; }
    main, .report-sheet { max-width: none; padding: 0; margin: 0; }
    header { display: none; }
    .report-sheet { border: none; page: report; }
    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; }
    .table-scroll { overflow: visible; }

    /* Rapport: Querformat, ein ganzer Monat (auch 31 Tage) auf einer Seite.

       Wichtig: eine explizite (unitless) line-height auf allen Textzeilen
       der Tabelle/des Kopfs – ohne diese übernimmt der Browser die
       eingebaute Standard-Zeilenhöhe der jeweils verwendeten Schriftart,
       und die unterscheidet sich je nach Betriebssystem/Schriftart-Fallback
       spürbar (z.B. Windows "Segoe UI" vs. der Standard-Sans auf anderen
       Systemen).

       Ebenso wichtig: font-size wird unten bewusst NOCHMALS explizit auf
       th/td gesetzt (nicht nur auf .report-tabelle selbst) – sonst würde
       die allgemeine App-Regel "th, td { font-size: 0.92rem }" (siehe
       weiter oben, für die normalen Tabellen) gewinnen, weil sie direkt
       auf dem Element sitzt und Vererbung damit aussticht. Das war lange
       der eigentliche Grund für Seitenumbruch-Probleme hier.

       .report-sheet ist als Flex-Spalte über die volle Seitenhöhe (100vh
       entspricht beim Drucken der Seitengrösse minus @page-Rand) angelegt,
       damit die Unterschriftenzeile (siehe .report-signaturen) zuverlässig
       ganz unten auf der Seite sitzt statt direkt unter der Tabelle. */
    .report-sheet { display: flex; flex-direction: column; min-height: 100vh; padding: 2mm 6mm; }
    .report-header { margin-bottom: 0.6rem; padding-bottom: 0.4rem; }
    .report-logo { height: 26px; }
    .report-firma, .report-titel { font-size: 0.95rem; line-height: 1.1; }
    .report-stammdaten { margin-bottom: 0.6rem; }
    .report-stammdaten th, .report-stammdaten td { padding: 0.08rem 0.4rem; font-size: 0.68rem; line-height: 1.1; }
    .report-tabelle { font-size: 0.6rem; }
    .report-tabelle th, .report-tabelle td { padding: 0.03rem 0.3rem; font-size: 0.6rem; line-height: 1.1; }
    .report-tabelle thead th { font-size: 0.6rem; }
    /* Totalzeile: bewusst deutlich fetter/grösser als die übrigen Zeilen,
       damit die Monatssumme auf einen Blick auffindbar ist. Steht nach der
       generischen th/td-Regel oben, damit font-size hier gewinnt (gleiche
       Spezifität, spätere Regel gewinnt). */
    .report-total-row td { font-weight: 700; font-size: 0.78rem; }
    /* Unterschriftenzeile: dank margin-top:auto im Flex-Container ganz
       unten auf der Seite, mit grosszügigem Abstand zur Tabelle darüber. */
    .report-signaturen { margin-top: auto; padding-top: 1.5rem; gap: 2rem; }
    .signatur-linie { height: 0.5rem; margin-bottom: 0.1rem; }
    .signatur-feld { font-size: 0.7rem; line-height: 1.1; }
}

/* Named Page (CSS Paged Media): nur der Rapport wird quer gedruckt,
   andere Seiten (falls je gedruckt) bleiben von dieser Regel unberührt. */
@page report {
    size: A4 landscape;
    margin: 6mm;
}

/* ---------------------------------------------------------------------
   Mobile (Smartphone): Fahrer füllen die Erfassung unterwegs auf dem
   Handy aus. Die breite Monatstabelle wird unterhalb von 700px zu einer
   Liste von Karten (eine pro Tag) statt eines seitlich scrollenden
   Tabellen-Ungetüms – und Buttons/Eingabefelder werden fingerfreundlich
   grösser.
   --------------------------------------------------------------------- */
@media (max-width: 700px) {
    .header-inner { padding: 0.7rem 1rem; }
    .brand { font-size: 0.95rem; }
    main { padding: 0.8rem; }
    h1 { font-size: 1.25rem; }

    .month-nav { gap: 0.5rem; }
    .month-nav .inline-form { width: 100%; }
    .month-nav select { flex: 1 1 auto; min-width: 0; }

    /* Fingerfreundlichere Tap-Ziele */
    button, .button, .button-secondary,
    input[type=text], input[type=password], input[type=time], input[type=number], select {
        min-height: 44px;
    }

    /* Der äussere Tabellen-Rahmen entfällt auf dem Handy, da jeder Tag
       bereits als eigene Karte dargestellt wird (sonst Karte-in-Karte). */
    .entry-card {
        background: none;
        border: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    /* Zeiterfassungs-Tabelle -> Kartenliste, eine Karte pro Tag. */
    .entry-table thead { display: none; }
    .entry-table, .entry-table tbody, .entry-table tfoot,
    .entry-table tr, .entry-table td {
        display: block;
        width: 100%;
    }
    .entry-table { border: none; background: none; }

    .entry-table tbody tr[data-row] {
        background: var(--color-card);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        padding: 0.7rem 0.9rem;
        margin-bottom: 0.7rem;
    }
    .entry-table tbody tr.weekend { background: var(--color-weekend-bg); }
    .entry-table tbody tr.today {
        background: rgba(30, 129, 95, 0.05);
        border-color: var(--color-primary);
        border-width: 2px;
    }

    .entry-table td { border: none; padding: 0.3rem 0; }
    .entry-table td.day-cell {
        font-size: 1.05rem;
        font-weight: 700;
        width: auto;
        padding-bottom: 0.4rem;
        margin-bottom: 0.3rem;
        border-bottom: 1px solid var(--color-border);
    }

    /* Von/Bis/Pause/Total/Status: Beschriftung + Wert nebeneinander. */
    .entry-table td[data-label] {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
    }
    .entry-table td[data-label]::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--color-muted);
        font-size: 0.85rem;
        flex-shrink: 0;
    }
    .entry-table td .time-input,
    .entry-table td .pause-input { width: auto; max-width: 55%; }

    /* Tätigkeiten: Beschriftung + volles Eingabefeld darunter, statt
       nebeneinander (zu wenig Platz für Freitext neben dem Label). */
    .entry-table td.note-cell {
        display: block;
    }
    .entry-table td.note-cell::before {
        content: attr(data-label);
        display: block;
        font-weight: 500;
        color: var(--color-muted);
        font-size: 0.85rem;
        margin-bottom: 0.2rem;
    }
    .entry-table td.note-cell .note-input { width: 100%; }

    .entry-table .status-col {
        display: flex;
        justify-content: flex-end;
        padding-top: 0.3rem;
    }
    .entry-table .status-col:empty { display: none; }

    /* Monatssumme als einfache Zeile am Ende der Kartenliste. */
    .entry-table tfoot tr {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.6rem 0.2rem 0.2rem;
        font-weight: 600;
    }
    .entry-table tfoot .sum-label { text-align: left; }

    /* Login/Report-Karten: Randabstand etwas reduzieren. */
    .login-box { padding: 1.5rem; }
    .report-sheet { padding: 1rem; }
}
