/* ============================================================
   SchichtKalender – App CSS
   Modernes Design, CSS Variables, Dark Mode
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --purple:       #57068c;
  --purple-2:     #7a1fa2;
  --purple-soft:  #f4eafc;

  --bg:           #f2f2f7;
  --surface:      #ffffff;
  --surface-2:    #fafafa;
  --border:       rgba(0,0,0,.09);
  --text:         #1c1c1e;
  --text-2:       #3a3a3c;
  --muted:        #6b7280;

  --green:        #34c759;
  --red:          #ff3b30;
  --blue:         #007aff;
  --amber:        #f59e0b;
  --teal:         #0d9488;

  --radius:       18px;
  --radius-sm:    12px;
  --shadow:       0 4px 24px rgba(0,0,0,.07);
  --shadow-sm:    0 2px 10px rgba(0,0,0,.05);

  --nav-h:        64px;
  --header-h:     56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f0f14;
    --surface:   #1c1c24;
    --surface-2: #252530;
    --border:    rgba(255,255,255,.09);
    --text:      #f1f1f8;
    --text-2:    #c8c8d8;
    --muted:     #888899;
    --shadow:    0 4px 24px rgba(0,0,0,.35);
  }
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

a { color: var(--purple); text-decoration: none; }
button { font-family: inherit; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }

/* ── Header ────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.brand { flex: 1; min-width: 0; }
.brand .title  { font-size: 18px; font-weight: 900; color: var(--purple); letter-spacing: -.2px; }
.brand .sub    { font-size: 12px; color: var(--muted); margin-top: 1px; }
.hdr-actions   { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Bottom Nav ────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 0 6px;
  transition: color .15s;
  position: relative;
}
.bn-item.active { color: var(--purple); }
.bn-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 2.5px;
  border-radius: 0 0 3px 3px;
  background: var(--purple);
}
.bn-ico { font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.bn-ico svg { width: 24px; height: 24px; display: block; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, transform .06s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover  { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--purple); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--purple-2); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12px; }
.btn.icon { width: 40px; padding: 0; border-radius: 50%; font-size: 17px; }

/* ── Cards ─────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 12px 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form { display: grid; gap: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input,
.field select,
input, select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(87,6,140,.12);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Login ─────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: 0;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .app-name { font-size: 26px; font-weight: 900; color: var(--purple); }
.login-logo .app-sub  { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-err { color: var(--red); font-size: 13px; text-align: center; margin-top: 10px; }

/* ── Calendar Grid ─────────────────────────────────────────── */
:root {
  --block-bg:   #e1f5fe;
  --block-text: #0277bd;
}
@media (prefers-color-scheme: dark) {
  :root { --block-bg: #1a2d3f; --block-text: #60b8e0; }
}

.cal-wrap { max-width: 1200px; margin: 0 auto; padding: 10px; }

.cal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  gap: 10px;
}
.cal-top-label { font-size: 17px; font-weight: 800; color: var(--text); }
.cal-nav { display: flex; gap: 6px; }

#multiCalendar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}
/* Desktop/Notebook: bei kleiner Fensterbreite vertikal stapeln statt horizontal snappen.
   Dadurch funktioniert normales Mausrad-/Touchpad-Scrollen zuverlässig. */
@media (max-width: 1000px) and (hover: hover),
       (max-width: 1000px) and (pointer: fine) {
  #multiCalendar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Smartphone/Tablet: horizontaler Monats-Slider bleibt erhalten. */
@media (max-width: 1000px) and (hover: none) and (pointer: coarse) {
  #multiCalendar {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
  }
  .month-block { min-width: min(320px, 90vw); scroll-snap-align: center; }
}

.month-block {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.month-title {
  text-align: center;
  padding: 11px;
  font-weight: 800;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 14px;
}
.weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.weekday-header div {
  padding: 6px 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
}

.day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 3px 2px 2px;
  border: 0.5px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  position: relative;
  background: var(--surface);
  transition: background .1s;
  overflow: hidden;
  min-height: 42px;
}
.day:hover       { background: var(--surface-2); }
.day.other-month { opacity: .32; }
.day.sunday      { background: color-mix(in srgb, var(--amber) 6%, var(--surface)); }
.day.selected    { background: color-mix(in srgb, var(--purple) 18%, var(--surface)) !important; outline: 2px solid var(--purple); outline-offset: -2px; border-radius: 3px; }
.day.holiday     { background: color-mix(in srgb, var(--red) 7%, var(--surface)); }

/* Heutiger Tag: blauer Ring um die Tageszahl + leichter Hintergrund */
.day.today {
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
}
.day.today .day-num {
  background: var(--blue);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0,122,255,.45);
}
.day.today.selected { outline-color: var(--blue); }
.day.vacation    { background: color-mix(in srgb, var(--blue) 5%, var(--surface)); }
.day.block       { background: var(--block-bg); color: var(--block-text); }
.day.block-half-after-ns {
  background: linear-gradient(135deg, var(--surface) 50%, var(--block-bg) 50%);
}

.day-num {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.day.sunday .day-num { color: var(--amber); }
.day.holiday .day-num { color: var(--red); }

.shift-info {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
  margin-top: 1px;
}

.entry-badge {
  font-size: 8.5px;
  font-weight: 800;
  background: var(--purple);
  color: #fff;
  border-radius: 3px;
  padding: 0px 3px;
  margin-top: 2px;
  line-height: 1.4;
}
.entry-st {
  font-size: 8.5px;
  font-weight: 800;
  background: var(--teal);
  color: #fff;
  border-radius: 3px;
  padding: 0px 3px;
  margin-top: 2px;
  line-height: 1.4;
}

.holiday-badge {
  font-size: 7.5px;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
  margin-top: 1px;
}
.vacation-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--blue);
  opacity: .5;
}
.vac-sommer     { background: var(--purple); }
.vac-herbst     { background: var(--amber); }
.vac-weihnachten{ background: #0ea5e9; }
.vac-ostern     { background: var(--green); }
.vac-pfingsten  { background: #ec4899; }

/* ── Month Footer (Zeitkonto) ──────────────────────────────── */
.month-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.konto-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.k-box { text-align: center; }
.k-box .lbl { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase; display: block; margin-bottom: 2px; }
.k-box .val { font-size: 12px; font-weight: 800; display: block; }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-bold  { color: var(--text); }
.text-purple { color: var(--purple); }

.fsq-wrap { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.fsq-bar  { height: 100%; background: var(--purple); border-radius: 3px; transition: width .4s; }
.fsq-label { font-size: 10px; color: var(--muted); text-align: center; margin-top: 4px; }

/* ── Editor Panel ──────────────────────────────────────────── */
#editor {
  position: fixed;
  bottom: var(--nav-h);
  left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  padding: 10px 14px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.editor-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.editor-info .sel-label { font-size: 13px; font-weight: 700; color: var(--text); }
.editor-info .sel-sub   { font-size: 11px; color: var(--muted); }
.entry-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-type {
  flex: 1;
  min-width: 52px;
  max-width: 80px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, transform .08s;
}
.btn-type:hover  { background: var(--purple-soft); border-color: rgba(87,6,140,.3); color: var(--purple); }
.btn-type:active { transform: scale(.95); }
.btn-type.delete { color: var(--red); }
.btn-type.delete:hover { background: rgba(255,59,48,.07); border-color: rgba(255,59,48,.3); }

/* ── Toast ─────────────────────────────────────────────────── */
.app-toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: color-mix(in srgb, var(--text) 90%, transparent);
  color: var(--surface);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  z-index: 999;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Year Overview ─────────────────────────────────────────── */
.year-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 12px 0 0;
}
.year-nav .year-label { font-size: 20px; font-weight: 900; color: var(--text); min-width: 60px; text-align: center; }

.tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  flex: 1;
  min-width: 80px;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.tab.active { background: var(--surface); color: var(--purple); box-shadow: var(--shadow-sm); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Jahrestabelle */
.year-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.year-table th {
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.year-table th:first-child { text-align: left; }
.year-table td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.year-table td:first-child { text-align: left; font-weight: 700; }
.year-table tr:last-child td { border-bottom: none; }
.year-table tr:hover td { background: var(--surface-2); }
.year-table .sum-row td { font-weight: 800; color: var(--purple); background: var(--purple-soft); border-radius: 0; }
.cell-green { color: var(--green); }
.cell-red   { color: var(--red);   }

/* SVG Charts */
.chart-wrap {
  width: 100%;
  overflow-x: auto;
}
.chart-wrap svg { width: 100%; height: auto; }

/* Abwesenheitsliste */
.absence-group { margin-bottom: 16px; }
.absence-group-title { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.absence-list { display: flex; flex-wrap: wrap; gap: 6px; }
.absence-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.chip-FS  { background: color-mix(in srgb, var(--purple) 10%, var(--surface)); color: var(--purple); }
.chip-U   { background: color-mix(in srgb, var(--blue)   10%, var(--surface)); color: var(--blue); }
.chip-BU  { background: color-mix(in srgb, #6366f1 12%, var(--surface)); color: #4f46e5; }
.chip-KR  { background: color-mix(in srgb, var(--red)    10%, var(--surface)); color: var(--red); }
.chip-ZT  { background: color-mix(in srgb, var(--green)  10%, var(--surface)); color: #166534; }
.chip-AFZ { background: color-mix(in srgb, var(--amber)  10%, var(--surface)); color: var(--amber); }
.chip-ST  { background: color-mix(in srgb, var(--teal)   10%, var(--surface)); color: var(--teal); }

.empty-hint { text-align: center; color: var(--muted); font-size: 14px; padding: 32px; }

/* ── Profil ─────────────────────────────────────────────────── */
.profil-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.profil-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--purple);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; font-weight: 900;
  flex-shrink: 0;
}
.profil-name   { font-size: 18px; font-weight: 800; }
.profil-sub    { font-size: 13px; color: var(--muted); margin-top: 2px; }
.save-hint { font-size: 12px; color: var(--green); text-align: center; margin-top: 10px; }
.section-label { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 8px; }

/* ── Misc ───────────────────────────────────────────────────── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.kpi .k-lbl { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-val { font-size: 20px; font-weight: 900; color: var(--purple); margin-top: 4px; }
.kpi .k-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

@media (max-width: 480px) {
  .kpi .k-val { font-size: 17px; }
}

/* Header title SVG icon */
.title-icon { display:inline-flex; align-items:center; vertical-align:middle; margin-right:6px; }
.title-icon svg { width:20px; height:20px; color:var(--purple); }
