/* Ganz bewusst schlichtes, plain CSS ohne Framework – leicht zu lesen und
   anzupassen, auch ohne CSS-Vorkenntnisse. */

:root {
  --gelb: #f5b400;
  --dunkel: #1f2937;
  --grau: #6b7280;
  --hellgrau: #f3f4f6;
  --rand: #d1d5db;
  --rot: #b91c1c;
  --weiss: #ffffff;
  --gelb-hell: #fef3c7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--hellgrau);
  color: var(--dunkel);
}

h1 {
  margin-top: 0;
}

/* --- Grundgerüst: Sidebar links, Inhalt rechts --- */

.app-layout {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.content {
  flex: 1;
  min-width: 0; /* verhindert, dass breite Tabellen den Flex-Container sprengen */
  padding: 24px 32px 64px;
  max-width: 1200px;
}

/* --- Sidebar --- */

.sidebar {
  width: 230px;
  flex-shrink: 0;
  min-height: 100vh;
  background: var(--dunkel);
  color: var(--weiss);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
}

.sidebar-brand {
  padding: 20px;
  font-weight: bold;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-nav a {
  color: var(--weiss);
  text-decoration: none;
  padding: 10px 20px;
  font-size: 0.95rem;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav a.aktiv {
  background: var(--gelb);
  color: var(--dunkel);
  font-weight: 600;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.85rem;
}

.sidebar-user .rolle-tag {
  color: #cbd5e1;
  margin: 2px 0 10px;
  text-transform: capitalize;
}

.sidebar-user form button {
  margin-top: 0;
  width: 100%;
  background: transparent;
  border: 1px solid var(--weiss);
  color: var(--weiss);
  padding: 6px 10px;
}

/* --- Login (eigene, schlichte Seite ohne Sidebar) --- */

.login-container {
  max-width: 360px;
  margin: 80px auto;
  padding: 32px;
  background: var(--weiss);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.hinweis {
  color: var(--grau);
  font-size: 0.85rem;
  margin: 4px 0 16px;
}

.hinweis-klein {
  color: var(--grau);
  font-size: 0.8rem;
}

/* --- Formulare --- */

form label {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

form input,
form select,
form textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--rand);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
}

form button {
  margin-top: 20px;
  padding: 10px 16px;
  background: var(--gelb);
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

form button:hover {
  filter: brightness(0.95);
}

.formular {
  background: var(--weiss);
  padding: 16px;
  border-radius: 8px;
  max-width: 420px;
  margin-top: 8px;
}

.monat-auswahl {
  max-width: 220px;
  margin-bottom: 16px;
}

.rollen-formular {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rollen-formular select {
  width: auto;
}

.rollen-formular button {
  margin-top: 0;
  padding: 6px 12px;
}

.passwort-formular {
  display: flex;
  gap: 8px;
  align-items: center;
}

.passwort-formular input {
  width: 150px;
}

.passwort-formular button {
  padding: 6px 12px;
}

.loeschen-button {
  margin-top: 0;
  background: transparent;
  border: 1px solid var(--rot);
  color: var(--rot);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.loeschen-button:hover {
  background: #fee2e2;
}

.fehler {
  background: #fee2e2;
  color: var(--rot);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.9rem;
}

.erfolg {
  background: #dcfce7;
  color: #15803d;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Status-Box im Schichtplan: zeigt Admin/Eigentümer, ob der gerade
   angezeigte Monat für Mitarbeiter freigegeben ist. */
.freigabe-status {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 4px;
  border: 1px solid;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.freigabe-status--frei {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.freigabe-status--nicht-frei {
  background: #fee2e2;
  color: var(--rot);
  border-color: #fca5a5;
}

.freigabe-status a {
  color: inherit;
  font-weight: 600;
}

/* Statistik-Box im Schichtplan (Admin/Eigentümer) */
.statistik-box {
  max-width: 360px;
  margin-bottom: 20px;
}

.statistik-box h2 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.statistik-tabelle {
  margin-top: 0;
}

/* --- Tabs (z.B. Schichtmeldungen / Gelöscht) --- */

.tab-leiste {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-leiste a {
  padding: 8px 14px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--dunkel);
  background: var(--weiss);
  border: 1px solid var(--rand);
  font-size: 0.9rem;
}

.tab-leiste a.aktiv {
  background: var(--gelb);
  border-color: var(--gelb);
  font-weight: 600;
}

/* --- Tabelle ---
   Für den Schichtplan bewusst mit sichtbaren Gitterlinien auf JEDER Zelle
   (nicht nur unten), damit es wie ein Excel-Raster aussieht. */

.tabelle-scroll {
  overflow-x: auto;
}

.tabelle {
  width: 100%;
  border-collapse: collapse;
  background: var(--weiss);
  margin-top: 8px;
}

.tabelle th,
.tabelle td {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--rand);
  vertical-align: middle;
}

.tabelle th {
  background: var(--hellgrau);
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--grau);
}

/* Buttons/Formulare innerhalb von Tabellenzellen sollen nicht den
   normalen oberen Formular-Abstand bekommen. */
.tabelle form button {
  margin-top: 0;
}

.datum-zelle {
  font-weight: 600;
  white-space: nowrap;
  vertical-align: top;
}

/* Samstag, Sonntag, Feiertag: Datum in Rot */
.datum-rot {
  color: var(--rot);
}

/* NUR Feiertag (nicht Sonntag): komplette Tages-Zeile(n) leicht eingefärbt */
.feiertag-zeile {
  background: var(--gelb-hell);
}

/* --- Schichtplan-spezifisch --- */

.schichtplan-tabelle th:first-child,
.schichtplan-tabelle td:first-child {
  min-width: 190px;
}

.schichtplan-tabelle .schicht-zeit {
  font-size: 0.75rem;
  color: var(--grau);
  margin-bottom: 4px;
}

.schichtplan-tabelle .zuweisung-formular select {
  width: 100%;
  min-width: 0;
}

.schichtplan-tabelle .mitarbeiter-name {
  font-size: 0.95rem;
}

/* Zelle für eine Schicht, die es an diesem Tag gar nicht gibt
   (Früh-/Mittagschicht Montag-Freitag) */
.schicht-leer {
  background: var(--hellgrau);
  color: var(--rand);
  text-align: center;
}

.feiertag-name {
  font-size: 0.75rem;
  font-weight: normal;
  margin-top: 2px;
}

/* Zelle einer Schicht, in der die eingeloggte Person selbst eingeteilt ist */
.eigene-schicht {
  font-weight: 700;
}

.eigene-schicht .schicht-zeit {
  font-weight: 400;
}

/* Schichtwünsche-Spalte ganz rechts im Schichtplan (nur Admin/Eigentümer) */
.schichtwuensche-zelle {
  min-width: 200px;
  vertical-align: top;
  font-size: 0.85rem;
}

.schichtwuensche-liste {
  margin: 0;
  padding-left: 18px;
}

.schichtwuensche-liste li {
  margin-bottom: 4px;
}

.schichtwuensche-liste li:last-child {
  margin-bottom: 0;
}

/* --- Schichttausch --- */

/* Zwei Formulare (Bestätigen/Ablehnen) nebeneinander in einer Tabellenzelle */
.tabellen-form-inline {
  display: inline-block;
  margin-right: 6px;
}

.tabellen-form-inline button {
  margin-top: 0;
}

.status-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-tag--offen {
  background: var(--gelb-hell);
  color: #92400e;
}

.status-tag--bestaetigt {
  background: #dcfce7;
  color: #15803d;
}

.status-tag--abgelehnt {
  background: #fee2e2;
  color: var(--rot);
}

/* --- Responsive: Handy/schmale Bildschirme ---
   Unter 720px wird aus der linken Sidebar eine obere Leiste, deren Links
   umbrechen statt die Seite in die Breite zu drücken. Tabellen scrollen
   dank .tabelle-scroll ohnehin schon horizontal (siehe oben) - auf einem
   Handy ist das für breite Tabellen wie den Schichtplan normal und ok. */
@media (max-width: 720px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: 0;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .sidebar-brand {
    padding: 14px 16px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 2px;
  }

  .sidebar-nav a {
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
  }

  .sidebar-user {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 10px 16px;
  }

  .sidebar-user .rolle-tag {
    margin: 0;
  }

  .sidebar-user form {
    margin: 0;
    width: auto;
  }

  .sidebar-user form button {
    width: auto;
    padding: 6px 14px;
  }

  .content {
    padding: 16px 16px 40px;
  }

  h1 {
    font-size: 1.4rem;
  }

  .login-container {
    max-width: none;
    margin: 32px 16px;
    padding: 24px;
  }

  /* Auf schmalen Screens lieber untereinander als nebeneinander gequetscht */
  .rollen-formular,
  .passwort-formular {
    flex-wrap: wrap;
  }

  .passwort-formular input {
    width: 100%;
  }

  /* Etwas größere Tippfläche für Buttons in Tabellenzellen */
  .loeschen-button,
  .tabelle form button {
    padding: 8px 12px;
  }
}

/* --- Schichtplan: Warnung "doppelt eingeteilt" + unbesetzte Schicht
   (nur admin/eigentuemer, siehe routes/schichtplan.js + schicht-zelle.ejs) --- */

.warnung-doppelt {
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--rot);
  white-space: normal;
}

.schicht-unbesetzt {
  background: #fff1f1;
}

/* --- Schichtplan-Kopfzeile: Monatsname + Drucken-Button --- */

.schichtplan-kopfzeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.monat-titel {
  font-weight: 600;
  margin: 0;
}

.drucken-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--weiss);
  border: 1px solid var(--rand);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.drucken-button:hover {
  background: var(--hellgrau);
}

/* --- Startseite (/start): Nachricht-Banner + Hinweis-Karten --- */

.nachricht-banner {
  background: var(--gelb-hell);
  border: 2px solid var(--gelb);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  max-width: 560px;
}

.nachricht-banner-kopf {
  font-weight: 700;
  margin-bottom: 8px;
  color: #92400e;
}

.nachricht-banner-text {
  white-space: pre-wrap;
  margin: 0 0 16px;
  font-size: 1rem;
}

.nachricht-banner button {
  margin-top: 0;
}

.hinweis-karten {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 24px;
}

.hinweis-karte {
  background: var(--weiss);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hinweis-karte strong {
  font-size: 1.6rem;
}

.hinweis-karte span {
  font-size: 0.85rem;
  color: var(--grau);
}

.hinweis-karte ul {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--dunkel);
}

.hinweis-karte--link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}

.hinweis-karte--link:hover {
  border-color: var(--gelb);
}

/* --- Druckansicht (Schichtplan -> "Drucken") ---
   .nur-bildschirm markiert alles, was im Ausdruck keinen Sinn macht
   (Navigation, Monatsauswahl, Statistik) oder aus Datenschutzgründen nicht
   auf einem ausgehängten Plan stehen soll (Schichtwünsche-Spalte). */
@media print {
  .nur-bildschirm,
  .sidebar,
  .drucken-button {
    display: none !important;
  }

  .app-layout {
    display: block;
  }

  .content {
    padding: 0;
    max-width: none;
  }

  .tabelle-scroll {
    overflow: visible;
  }

  .tabelle, .tabelle th, .tabelle td {
    border-color: #000;
  }

  /* Das <select> zur Schicht-Zuweisung soll wie reiner Text aussehen,
     nicht wie ein Formularfeld mit Dropdown-Pfeil. */
  .zuweisung-formular select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    color: inherit;
  }
}
