/* ========== 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);
}

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"],
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,
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;
}

.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 */
.swal2-select { width: 85% !important; max-width: 90% !important; }

/* 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;
}
