/* ========== Base / Tokens ========== */
:root {
  --bg:    #f7f7f8;
  --card:  #fff;
  --txt:   #111;
  --muted: #666;

  --pri:   #2563eb;

  --err:   #8a0017;
  --errbg: #ffe9e9;
  --errbd: #ffc8c8;

  --ok:    #0b7a3d;
  --okbg:  #e6fff0;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Inter, sans-serif;
}

/* Tabellen-Styling für Kleiderkammer/Inventur */
.table {
  width: auto;
  border-collapse: collapse;
  margin-top: 1rem;
}
.table th, .table td {
  padding: .6rem .5rem;
  border-bottom: 1px solid #eee;
  text-align: left;
}
.table th { font-weight: 700; }
.table .qty { text-align: right; }


/* ========== Layout / Card ========== */
.card {
  max-width: 560px;            /* reicht auch für create_user */
  margin: 6vh auto;
  background: var(--card);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,.06);
}

.card.db {
  max-width: 95% !important
}

h1 {
  margin: 0 0 14px;
  font-size: 1.35rem;
}

/* ========== Form ========== */
label {
  display: block;
  font-weight: 600;
  margin: .75rem 0 .35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="time"],
select {
  width: 100%;
  padding: .8rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  background: #fff;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="time"]:focus,
select:focus {
  border-color: #c7d2fe;       /* leichte Fokus-Markierung */
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.btn {
  width: 100%;
  margin-top: 1rem;
  padding: .9rem 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--pri);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center
}

.btn:disabled {
  opacity: .7;
  cursor: not-allowed;
}

.hint {
  color: var(--muted);
  font-size: .9rem;
  margin-top: .5rem;
}

/* ========== Alerts ========== */
.error {
  background: var(--errbg);
  color: var(--err);
  padding: .75rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid var(--errbd);
}

.success {
  background: var(--okbg);
  color: var(--ok);
  padding: .75rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid rgba(11,122,61,.12);
}

/* ========== Button group (start.php) ========== */
.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.btn-group .btn {
  flex: 1;
}

/* Kleinformat-Button für Icons/Aktionen in Tabellen */
.btn-icon {
  width: 2rem;
  padding: .35rem 0;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

/* Defekte Artikel (bzw. Bedarf) rot markieren */
.defect {
  color: #c00;
  font-weight: bold;
}

/* Zeilen mit Null-Bestand leicht ausgegraut und nach unten sortiert */
.muted-row {
  color: #999;
  opacity: .75;
}

.need-info {
  position: relative;
  text-decoration: underline;
  cursor: help;
}

/* Tooltip-Blase */
.need-info:hover::after {
  content: attr(data-users);
  position: absolute;
  left: 1.2rem;   /* leicht rechts vom (-1) */
  top: -0.25rem;
  background: rgba(0,0,0,.85);
  color: #fff;
  padding: .35rem .5rem;
  border-radius: .25rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  white-space: pre;     /* \n im data-users als Zeilenumbruch anzeigen */
  z-index: 10;
  max-width: 28ch;
}

/* kleiner Pfeil (optional) */
.need-info:hover::before {
  content: '';
  position: absolute;
  left: .6rem;
  top: .15rem;
  border: 6px solid transparent;
  border-right-color: rgba(0,0,0,.85);
}

.btn-success { background: #2e7d32; color: #fff; }
.btn-success:hover { filter: brightness(0.95); }
.btn-icon { padding: .25rem .5rem; }

/* SweetAlert: Select nicht überstehen lassen */
/* Input an Popup anpassen */
.swal2-input,
.swal2-textarea,
.swal2-select {
  width: 85% !important;
  max-width: 90% !important;
  box-sizing: border-box;
}

/* Benutzer-Detail Bestätigungsnachrichten */
.alert {
  padding: .6rem 1rem;
  border-radius: .4rem;
  margin-bottom: 1rem;
  animation: fadein .3s ease;
  position: relative;
}

.alert.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@keyframes fadeout {
  to { opacity: 0; max-height: 0; margin: 0; padding: 0; }
}

.flash {
  padding: .6rem 1rem;
  border-radius: .4rem;
  margin-bottom: 1rem;
  position: relative;
  transition: opacity .4s, max-height .4s, margin .4s, padding .4s;
}
.flash.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}
.flash.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}
.flash.is-hiding {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}

/* Eingabefelder */
/* Inputs & Selects – clean, konsistent */
input:not([type]),
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  padding: .55rem .65rem;
  border: 1px solid #d7d7d7;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7aa7ff;
  box-shadow: 0 0 0 3px rgba(122,167,255,.15);
}

/* Labels mit Luft */
label { display:block; margin-bottom:.25rem; font-weight:500; }

/* Grid (Formulare) – einheitlich */
.row { display:grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 860px) {
  .row { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
/* Volle Breite für einzelne Zeilen */
.row > .full { grid-column: 1 / -1; }

/* Tab-Buttons (auch für „Zurück“ nutzen) */
.tabbtn,
a.tabbtn {
  display: inline-block;
  padding: .5rem .75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f7f7f7;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background .12s, border-color .12s, box-shadow .12s;
}

.tabbtn:hover,
a.tabbtn:hover { background:#f2f2f2; }

.tabbtn.active,
a.tabbtn.active {
  background: #fff;
  border-color: #bbb;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

/* Alerts (Auto-Fade) */
@keyframes fadeout { to { opacity:0; transform: translateY(-4px); } }
.alert { transition: opacity .2s; }

.swal2-radio-list {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-center !important;
  gap: 0.5rem;
}

/* Mobile: etwas „weiter weg“ wirken lassen */
@media (max-width: 420px) {
  body { 
    font-size: 15px;            /* statt 16px -> alles minimal kleiner */
  }
  .card {
    margin: 4vh auto;           /* etwas weniger vertikaler Rand */
    padding: 18px;              /* weniger Innenabstand */
    border-radius: 12px;
  }
  h1 { 
    font-size: 1.2rem;          /* Heading leicht kleiner */
  }
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    padding: .6rem .65rem;      /* Inputs kompakter */
    font-size: .95rem;
  }
  .btn {
    padding: .75rem 1rem;       /* Buttons kompakter */
    font-size: .95rem;
  }
  .table th, .table td {
    padding: .5rem .45rem;      /* Tabellen enger */
  }
}

/* ======== Verbessertes Scroll-Layout für Tabellen ======== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  box-shadow: inset 0 -1px 0 #eee;
  background: #fff;
  padding-bottom: .25rem;       /* Platz für Scrollbar */
}

/* Optional: leichter Schatten rechts bei Überlauf */
.table-wrap::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 16px;
  background: linear-gradient(to right, transparent, rgba(0,0,0,.05));
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.table-wrap:hover::after {
  opacity: 1;
}

/* Scrollbar etwas dezenter gestalten */
.table-wrap::-webkit-scrollbar {
  height: 8px;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}
.table-wrap::-webkit-scrollbar-track {
  background: #f5f5f5;
}


/* Buttons in Tabellen nicht full-width machen */
.table .btn {
  width: auto;
  display: inline-block;
  white-space: nowrap;
  padding: .5rem .75rem;
}

/* Kompakte Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.pagination .tabbtn {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: #f3f3f3;
  border: 1px solid #ddd;
  text-decoration: none;
  color: #333;
  line-height: 1.2;
}

.pagination .tabbtn:hover {
  background: #e9e9e9;
}

.pagination .tabbtn.active {
  background: var(--pri);
  border-color: var(--pri);
  color: #fff;
}

.pagination .tabbtn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Dienstbuch */
.autogrow{ resize:none; overflow:hidden; min-height:140px; }
.trainer-grid{ display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:8px 12px; }
.trainer-item{ display:flex; align-items:center; gap:8px; }
.trainer-box{ border:1px solid #ddd; padding:10px; border-radius:8px; }

.table-wrap.table-wrap-center td:not(:first-child),
.table-wrap.table-wrap-center th:not(:first-child) {
  text-align: center;
}

/* Erste Spalte (inkl. Überschrift) explizit links */
.table-wrap.table-wrap-center td:first-child,
.table-wrap.table-wrap-center th:first-child {
  text-align: left;
}

.time-row {
  display: flex;
  gap: 1rem;              /* Abstand zwischen den Feldern */
}

.time-field {
  flex: 1;                /* beide gleich breit */
}

.actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

th.actions-col,
td.actions-col {
  width: 120px;
  min-width: 110px;
}

/* Dienstbuch - View */

/* Card / Box */
.box {
  background: #fff;
  border: 1px solid rgba(20, 20, 20, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px; /* ersetzt inline-style */
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

/* Optional: etwas kompaktere Variante für Tabellen/Listen */
.box--kv {
  padding: 12px 14px;
}

/* Key-Value Grid */
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  align-items: baseline;
}

/* Labels */
.kv .muted {
  color: rgba(20, 20, 20, 0.55);
  font-size: 12.5px;
  letter-spacing: 0.2px;
  text-transform: none; /* wenn du uppercase willst: uppercase */
  line-height: 1.25;
}

/* Values */
.kv > div:not(.muted) {
  color: rgba(20, 20, 20, 0.92);
  line-height: 1.35;
  word-break: break-word;
}

/* “Leer”-Optik (dein —) etwas softer */
.kv > div:not(.muted):has(> :is(span, strong, em)) {
  /* optional – meist unnötig, nur als Platzhalter */
}

/* Trennlinien pro Zeile (optional, wirkt sehr ordentlich) */
.kv > .muted {
  padding-top: 6px;
}
.kv > .muted:nth-of-type(n + 2),
.kv > .muted:nth-of-type(n + 2) + div {
  border-top: 1px solid rgba(20, 20, 20, 0.06);
  padding-top: 10px;
}

/* Pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(20, 20, 20, 0.12);
  background: rgba(20, 20, 20, 0.04);
  color: rgba(20, 20, 20, 0.85);
  white-space: nowrap;
}

/* Optionale Farbvarianten nach Art (wenn du Klassen setzen willst)
   z.B. <span class="pill pill--theorie">Theorie</span> */
.pill--success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.28);
  color: rgba(6, 95, 70, 1);
}
.pill--warning {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.30);
  color: rgba(120, 53, 15, 1);
}
.pill--danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.30);
  color: rgba(127, 29, 29, 1);
}
.pill--info {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.28);
  color: rgba(30, 64, 175, 1);
}

/* Responsive: 2 Spalten -> 1 Spalte */
@media (max-width: 600px) {
  .kv {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .kv .muted {
    margin-top: 8px;
  }

  /* Trennlinien in 1-Spalte weniger aggressiv */
  .kv > .muted:nth-of-type(n + 2),
  .kv > .muted:nth-of-type(n + 2) + div {
    border-top: none;
    padding-top: 0;
  }
}

.kv-highlight {
  font-size: 16px;      /* größer */
  font-weight: 700;     /* fett */
  color: rgba(20,20,20,0.95);
  letter-spacing: 0.2px;
}

/* Container */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 18px 0 22px 0;
}

/* Titel */
.month-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.4px;
  min-width: 160px;
  text-align: center;
}

/* Buttons */
.month-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  text-decoration: none;
  font-size: 20px;
  font-weight: 600;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  color: rgba(20,20,20,0.85);
  transition: all 0.2s ease;
}

/* Hover Effekt */
.month-btn:hover {
  background: rgba(0,0,0,0.05);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* Active Klick */
.month-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Basis-Status */
.status {
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-block;
  font-size: 13px;
  min-width: 90px;
}

/* Grün – anwesend */
.status--anwesend {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

/* Orange – entschuldigt */
.status--entschuldigt {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

/* Rot – fehlend */
.status--fehlend {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.35);
}