/* ============================================================
   style.css  —  Schulungsverwaltungs-App
   Mobile-first, max-width 480px, Ampelfarben
   ============================================================ */

:root {
  --primary:   #1a3a5c;
  --accent:    #0066cc;
  --bg:        #f4f6f9;
  --card-bg:   #ffffff;
  --border:    #dde2e9;
  --text:      #1a1a2e;
  --muted:     #6b7280;
  --green:     #16a34a;
  --green-bg:  #dcfce7;
  --yellow:    #ca8a04;
  --yellow-bg: #fef9c3;
  --red:       #dc2626;
  --red-bg:    #fee2e2;
  --radius:    10px;
  --shadow:    0 2px 8px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }

/* ── SCREENS ─────────────────────────────────────────────── */
.screen { display: none; flex-direction: column; min-height: 100vh; }
.screen.active { display: flex; }

/* ── HEADER ──────────────────────────────────────────────── */
.app-header {
  background: var(--primary);
  color: white;
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.app-header h1 { font-size: 1.05rem; font-weight: 700; }
.app-header .user-info { font-size: 0.75rem; opacity: .85; text-align: right; }
.btn-logout { background: transparent; border: 1px solid rgba(255,255,255,.4); color: white; padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; cursor: pointer; }

/* ── CONTENT AREA ────────────────────────────────────────── */
.content { padding: 16px; flex: 1; max-width: 900px; margin: 0 auto; width: 100%; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--primary); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none; transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { opacity: .8; transform: scale(.97); }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-success { background: var(--green); color: white; }
.btn-danger  { background: var(--red);   color: white; }
.btn-outline { background: transparent; border: 2px solid var(--accent); color: var(--accent); }
.btn-full { width: 100%; margin-bottom: 8px; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ── LOGIN ───────────────────────────────────────────────── */
#screen-login {
  background: linear-gradient(135deg, var(--primary) 0%, #2c5282 100%);
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
.login-box {
  background: white;
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  margin: 20px;
}
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo h2 { color: var(--primary); font-size: 1.3rem; margin-top: 8px; }
.login-logo .subtitle { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

/* ── FORMULAR ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 0.92rem; background: var(--bg);
  color: var(--text); transition: border-color .2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { outline: none; border-color: var(--accent); background: white; }
.form-group textarea { resize: vertical; min-height: 72px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1.1rem; }

/* ── CHECKBOX-FELD ───────────────────────────────────────── */
.checkbox-field {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; background: var(--bg); cursor: pointer;
  transition: background .15s;
}
.checkbox-field:hover { background: #e8f0fe; }
.checkbox-field input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.checkbox-field label { font-size: 0.88rem; cursor: pointer; }
.checkbox-field.checked { background: #e8f0fe; border-color: var(--accent); }

/* ── UPLOAD-FELD ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 8px;
  padding: 20px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.has-file { border-color: var(--accent); background: #e8f0fe; }
.upload-zone .upload-icon { font-size: 1.8rem; }
.upload-zone p { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.upload-zone.has-file p { color: var(--green); font-weight: 600; }
.upload-zone input[type="file"] { display: none; }

/* ── UNTERSCHRIFT ────────────────────────────────────────── */
.sig-container { border: 2px solid var(--border); border-radius: 8px; background: white; overflow: hidden; position: relative; width: 100%; }
.sig-canvas { display: block; width: 100%; height: 150px; touch-action: none; cursor: crosshair; background: white; }
.sig-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }

/* ── AMPEL-BADGES ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700;
}
.badge-gruen  { background: var(--green-bg);  color: var(--green); }
.badge-gelb   { background: var(--yellow-bg); color: var(--yellow); }
.badge-rot    { background: var(--red-bg);    color: var(--red); }
.ampel-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-gruen { background: var(--green); }
.dot-gelb  { background: var(--yellow); }
.dot-rot   { background: var(--red); }

/* ── SCHULUNGS-KARTEN ────────────────────────────────────── */
.schulung-item {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.schulung-item:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); border-color: var(--accent); }
.schulung-item .titel { font-weight: 700; font-size: 0.92rem; color: var(--primary); }
.schulung-item .meta  { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }
.schulung-item .right { text-align: right; flex-shrink: 0; }

/* ── FORTSCHRITTSBALKEN ──────────────────────────────────── */
.progress-bar {
  width: 100%; height: 8px; background: var(--border);
  border-radius: 4px; overflow: hidden; margin-top: 6px;
}
.progress-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.fill-gruen  { background: var(--green); }
.fill-gelb   { background: var(--yellow); }
.fill-rot    { background: var(--red); }

/* ── TABELLE (Admin-Übersicht) ────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th { background: var(--primary); color: white; padding: 10px 12px; text-align: left; font-size: 0.78rem; letter-spacing: .04em; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg); }
.td-name { font-weight: 600; }

/* ── TABS ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 16px; gap: 2px; }
.tab-btn {
  flex: 1; padding: 10px 6px; background: none; border: none; cursor: pointer;
  font-size: 0.82rem; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px; transition: color .15s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── FORMULAR-ABSCHNITT ──────────────────────────────────── */
.form-section { margin-bottom: 20px; }
.form-section-title {
  font-size: 0.9rem; font-weight: 800; color: var(--primary);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 12px; padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}
.pflicht-mark { color: var(--red); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: white; border-radius: 14px; padding: 24px;
  max-width: 480px; width: calc(100% - 32px); max-height: 80vh;
  overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.modal-title { font-size: 1.05rem; font-weight: 800; color: var(--primary); margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* ── AUDIT-TRAIL ─────────────────────────────────────────── */
.audit-item { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; font-size: 0.8rem; }
.audit-time { color: var(--muted); white-space: nowrap; font-size: 0.75rem; }
.audit-icon { font-size: 1rem; flex-shrink: 0; }

/* ── FEHLERMELDUNG ───────────────────────────────────────── */
.error-msg {
  background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5;
  border-radius: 8px; padding: 10px 14px; font-size: 0.85rem;
  margin-bottom: 12px; display: none;
}
.error-msg.show { display: block; }
.success-msg {
  background: var(--green-bg); color: var(--green); border: 1px solid #86efac;
  border-radius: 8px; padding: 10px 14px; font-size: 0.85rem;
  margin-bottom: 12px; display: none;
}
.success-msg.show { display: block; }

/* ── DIVIDER ─────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { font-size: 0.88rem; }

/* ── STAT-KACHELN ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-tile {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 10px; text-align: center; border: 1px solid var(--border);
}
.stat-tile .zahl { font-size: 1.8rem; font-weight: 800; }
.stat-tile .label { font-size: 0.72rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat-tile.gruen .zahl { color: var(--green); }
.stat-tile.gelb  .zahl { color: var(--yellow); }
.stat-tile.rot   .zahl { color: var(--red); }

/* ── RESPONSIV (Tablet/Desktop) ──────────────────────────── */
@media (min-width: 640px) {
  .content { padding: 24px 32px; }
  .login-box { padding: 40px 36px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .content { padding: 28px 48px; }
}

/* ── PFLICHT-HINWEIS ─────────────────────────────────────── */
.pflicht-hinweis { font-size: 0.78rem; color: var(--muted); margin-bottom: 16px; }
.pflicht-hinweis span { color: var(--red); }

/* ── BACK-BUTTON ─────────────────────────────────────────── */
.back-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; color: var(--accent);
  font-size: 0.88rem; font-weight: 600; cursor: pointer; padding: 6px 0;
  margin-bottom: 12px;
}

/* ── ZUWEISUNG ERSTELLEN (Admin-Formular) ────────────────── */
.assign-form { display: flex; flex-direction: column; gap: 10px; }

/* ── TENANT-BADGE ────────────────────────────────────────── */
.tenant-badge {
  display: inline-block; background: #e0e7ff; color: #3730a3;
  border-radius: 5px; padding: 2px 7px; font-size: 0.72rem; font-weight: 700;
}
/* ── LOADING SPIN ─────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FORM ACTIONS ─────────────────────────────────────────── */
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ── SPRACH-BUTTONS ───────────────────────────────────────── */
.sprach-btn { background:#f3f4f6;color:#374151;border:1px solid #e5e7eb;font-size:.75rem;padding:4px 9px; }
.sprach-btn.active-lang { background:#0047cc;color:#fff;border-color:#0047cc; }
.sprach-btn:hover:not(.active-lang) { background:#e5e7eb; }

/* ── DARK MODE BUTTON ─────────────────────────────────────── */
.dark-mode-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 1rem;
  cursor: pointer;
  transition: background .2s;
}
.dark-mode-btn:hover { background: rgba(255,255,255,.25); }

/* ══════════════════════════════════════════════════════════════
   DARK MODE
══════════════════════════════════════════════════════════════ */
body.dark-mode {
  --bg:       #111827;
  --card-bg:  #1f2937;
  --border:   #374151;
  --text:     #f9fafb;
  --muted:    #9ca3af;
  --primary:  #0f1f35;
}
body.dark-mode .card          { background: var(--card-bg); border-color: var(--border); color: var(--text); }
body.dark-mode .card-title    { color: #e5e7eb; }
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea       { background: #374151; border-color: #4b5563; color: #f9fafb; }
body.dark-mode input::placeholder { color: #6b7280; }
body.dark-mode .schulung-item { background: #1f2937; border-color: #374151; }
body.dark-mode .schulung-item:hover { background: #263448; }
body.dark-mode .badge-gruen   { background:#064e3b;color:#6ee7b7; }
body.dark-mode .badge-gelb    { background:#78350f;color:#fde68a; }
body.dark-mode .badge-rot     { background:#7f1d1d;color:#fca5a5; }
body.dark-mode .stat-tile     { background:#1f2937;border:1px solid #374151; }
body.dark-mode .stat-tile .zahl { color:#60a5fa; }
body.dark-mode .login-box     { background:#1f2937;color:#f9fafb; }
body.dark-mode .app-header    { background:#0f1f35; }
body.dark-mode .btn-outline   { border-color:#4b5563;color:#e5e7eb; }
body.dark-mode .btn-outline:hover { background:#374151; }
body.dark-mode .audit-item    { border-color:#374151; }
body.dark-mode .form-section  { border-color:#374151; }
body.dark-mode .form-section-title { color:#93c5fd; background:#1e3a5f; }
body.dark-mode .tab-btn       { background:#1f2937;color:#9ca3af;border-color:#374151; }
body.dark-mode .tab-btn.active { background:#0047cc;color:#fff; }
body.dark-mode .progress-bar  { background:#374151; }
body.dark-mode table          { color:#f9fafb; }
body.dark-mode th             { background:#263448;color:#9ca3af; }
body.dark-mode td             { border-color:#374151; }
body.dark-mode .table-wrap    { border-color:#374151; }
body.dark-mode .sprach-btn    { background:#374151;color:#e5e7eb;border-color:#4b5563; }
body.dark-mode .upload-zone   { background:#1f2937;border-color:#4b5563;color:#9ca3af; }
