/* ==========================================================================
   Schichtwerk – Schichtkalender
   Mobile-first, Light/Dark über prefers-color-scheme
   ========================================================================== */

:root {
  /* Farbtokens – Light */
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-alt: #e8efed;
  --text: #1d2b28;
  --text-muted: #5c6f6a;
  --border: #d3ddda;
  --accent: #0e7a6f;
  --accent-strong: #0a5c54;
  --accent-contrast: #ffffff;
  --premium: #b07a1e;
  --today-ring: #0e7a6f;
  --holiday: #a3452f;
  --cell-other: #f7faf9;
  --urlaub: #e0a10e;
  --krank: #c94f4f;
  --shadow: 0 1px 3px rgba(20, 40, 36, 0.10), 0 4px 14px rgba(20, 40, 36, 0.06);
  --radius: 12px;
  --radius-sm: 7px;
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101715;
    --surface: #1a2320;
    --surface-alt: #22302c;
    --text: #e4ecea;
    --text-muted: #93a5a0;
    --border: #31403b;
    --accent: #2eb8a5;
    --accent-strong: #4fd0be;
    --accent-contrast: #0c1512;
    --premium: #d9a94a;
    --today-ring: #2eb8a5;
    --holiday: #e08a70;
    --cell-other: #151d1b;
    --urlaub: #d9a10e;
    --krank: #d96a6a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }

/* --- Header ------------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-icon { display: block; }
.brand-text h1 { font-size: 1.25rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.tagline { margin: 0; font-size: 0.78rem; color: var(--text-muted); }

/* --- Layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
  max-width: 1180px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr); align-items: start; }
}

.sidebar { display: flex; flex-direction: column; gap: 1rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

/* --- Buttons & Felder ---------------------------------------------------- */

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-ghost { background: transparent; }

.btn-premium {
  background: transparent;
  border-color: var(--premium);
  color: var(--premium);
}
.btn-premium:hover { background: var(--premium); color: var(--surface); border-color: var(--premium); }

.btn-icon { padding: 0.4rem 0.7rem; line-height: 1; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.field { display: block; margin: 0.6rem 0; }
.field > span, .field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

input, select {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  width: 100%;
}
input:focus, select:focus, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="color"] { padding: 0.15rem; height: 2.3rem; }

/* --- Kalender ------------------------------------------------------------ */

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.cal-nav { display: flex; align-items: center; gap: 0.5rem; }
.month-label { font-weight: 800; font-size: 1.1rem; min-width: 10.5ch; text-align: center; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-cell {
  position: relative;
  min-height: 68px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 3px 4px 4px;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.other-month { background: var(--cell-other); opacity: 0.55; cursor: default; }
.cal-cell.weekend { background: var(--surface-alt); }
.cal-cell.other-month.weekend { background: var(--cell-other); }
.cal-cell.today { outline: 2px solid var(--today-ring); outline-offset: -1px; }

.cell-day { font-size: 0.78rem; font-weight: 700; }
.cal-cell.holiday .cell-day { color: var(--holiday); }

.cell-holiday {
  font-size: 0.6rem;
  line-height: 1.15;
  color: var(--holiday);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 5px;
  margin-top: auto;
  align-self: flex-start;
}
.chip-urlaub { background: var(--urlaub); color: #1d1503; }
.chip-krank { background: var(--krank); color: #fff; }
.chip-override { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text-muted); }

.cal-hint { font-size: 0.78rem; color: var(--text-muted); margin: 0.6rem 0 0; }

.cal-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 0.5rem;
}

/* --- Statistik ----------------------------------------------------------- */

.stats { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.stats-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.35rem 1rem;
  font-size: 0.85rem;
}
.stats-list li { display: flex; justify-content: space-between; gap: 0.5rem; }
.stats-list .stat-value { font-weight: 800; }
.stat-dot {
  display: inline-block;
  width: 0.7em; height: 0.7em;
  border-radius: 50%;
  margin-right: 0.35em;
}

/* --- Muster-Editor -------------------------------------------------------- */

.pattern-editor { margin: 0.75rem 0; }
.pattern-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 2rem;
  padding: 0.4rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.pattern-chip {
  border: none;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.pattern-empty { font-size: 0.78rem; color: var(--text-muted); align-self: center; }

.pattern-buttons { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 0.5rem; }
.pattern-add {
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.pattern-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* --- Schichttypen --------------------------------------------------------- */

.type-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.6rem; }
.type-row {
  display: grid;
  grid-template-columns: 1fr 3.4rem 2.8rem;
  gap: 4px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem;
}
.type-row .type-times { grid-column: 1 / -1; display: flex; gap: 4px; align-items: center; }
.type-row .type-times input { flex: 1; }
.type-row .type-times span { font-size: 0.75rem; color: var(--text-muted); }
.type-delete { justify-self: end; }

/* --- Werbung / Premium ----------------------------------------------------- */

.ad-slot {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem;
  text-align: center;
}
.ad-label {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.35rem;
}
.ad-placeholder { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--text-muted); }

.premium-list { padding-left: 1.2rem; margin: 0.5rem 0; }
.premium-list li { margin: 0.25rem 0; }

.panel-teaser { border-style: dashed; }

/* --- Export ---------------------------------------------------------------- */

.export-actions { display: flex; flex-direction: column; gap: 0.5rem; }

/* --- Footer ----------------------------------------------------------------- */

.app-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  align-items: center;
}
.app-footer p { margin: 0; }
.footer-nav { display: flex; gap: 0.5rem; align-items: center; }

/* --- Modals ------------------------------------------------------------------ */

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  width: min(92vw, 460px);
}
.modal::backdrop { background: rgba(10, 20, 18, 0.55); }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

.day-options { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
.day-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  text-align: left;
}
.day-option:hover { border-color: var(--accent); }
.day-option .chip { margin: 0; }
.day-option.selected { outline: 2px solid var(--accent); outline-offset: -1px; }

/* --- Druckansicht ------------------------------------------------------------- */

@media print {
  body { background: #fff; color: #000; }
  .app-header, .sidebar, .cal-hint, .app-footer, .modal, .cal-toolbar .btn { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .panel { border: none; box-shadow: none; padding: 0; }
  .month-label { font-size: 1.3rem; }
  .cal-cell { min-height: 60px; break-inside: avoid; cursor: default; }
  .cal-grid, .cal-weekdays { gap: 2px; }
  .stats { break-inside: avoid; }
  @page { size: A4 landscape; margin: 12mm; }
}

/* --- Erste-Schritte-Hilfe ---------------------------------------------------- */

.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.help-btn {
  inline-size: 2rem; block-size: 2rem; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit; font-weight: 700; font-size: 1rem; line-height: 1;
  cursor: pointer; flex: 0 0 auto;
}
.help-btn:hover, .help-btn:focus-visible { color: var(--accent); border-color: var(--accent); }
.tour-intro { color: var(--text-muted); }
.tour-steps { margin: 0 0 1rem; padding-left: 1.25rem; display: grid; gap: 0.6rem; }
.tour-steps li strong { color: var(--accent-strong); }
.know-box {
  background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.9rem 1rem; margin-bottom: 1rem;
}
.know-box h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.know-box ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.4rem; }
.know-box li { font-size: 0.9rem; color: var(--text-muted); }
