/* Waki App - Basis-Styling (Wald/Natur-Palette)
 * Mobile-first. Keine externen Abhaengigkeiten.
 */

:root {
  --moss:   #3E6B3A;
  --moss-d: #2E5229;
  --leaf:   #8FB86B;
  --leaf-l: #C9DDB3;
  --sand:   #F4EFE2;
  --sand-d: #EFE8D4;
  --bark:   #5A4634;
  --text:   #2F3A2A;
  --muted:  #7A7363;
  --ok:     #6AA84F;
  --warn:   #C98A1B;
  --danger: #B24A3A;
  --bg:     #FBF8F0;
  --border: #D9D2BE;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--moss); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--bark); margin: 0 0 0.75rem; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 0.75rem; }
small { color: var(--muted); }
.muted { color: var(--muted); font-size: 0.9rem; }
.mt-4 { margin-top: 1.5rem; }

/* Public layout (Login etc.) */
.waki-public { background: var(--sand); min-height: 100vh; }
.public-wrap { max-width: 440px; margin: 0 auto; padding: 2rem 1rem; }
.public-head { text-align: center; margin-bottom: 1.5rem; }
.public-head .brand { font-size: 1.8rem; font-weight: 700; color: var(--moss); }
.public-head .tagline { color: var(--bark); font-size: 0.95rem; }
.public-card { background: #fff; border-radius: 16px; padding: 1.75rem; box-shadow: 0 8px 32px rgba(62,107,58,0.1); }
.public-foot { text-align: center; margin-top: 1.5rem; color: var(--muted); }

/* App layout */
.app-head { background: var(--moss); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.08); position: sticky; top: 0; z-index: 10; }
.app-head-inner { max-width: 1100px; margin: 0 auto; padding: 0.75rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.app-head .brand { color: #fff; font-weight: 700; font-size: 1.2rem; display: inline-flex; align-items: center; gap: 0.5rem; }
.app-head .brand:hover { text-decoration: none; }
.brand-logo { height: 20px; width: auto; border-radius: 4px; background: #fff; padding: 2px; object-fit: contain; }
.brand-logo-big { height: 20px; width: auto; display: block; margin: 0 auto 0.5rem; }
.public-head .brand { display: block; }
.app-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.app-nav a, .app-nav .logout-btn {
  color: #fff; padding: 0.5rem 0.75rem; border-radius: 8px;
  font-size: 0.95rem; white-space: nowrap;
}
.app-nav a:hover, .app-nav .logout-btn:hover { background: var(--moss-d); text-decoration: none; }
.logout-form { display: inline; margin: 0; }
.logout-btn { background: transparent; border: 1px solid rgba(255,255,255,0.3); cursor: pointer; font: inherit; }
.nav-toggle { display: none; background: transparent; border: 0; cursor: pointer; padding: 0.5rem; margin-left: auto; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: #fff; margin: 5px 0; }
.app-main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.app-foot { text-align: center; padding: 2rem 1rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); margin-top: 2rem; }

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .app-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-top: 0.75rem; }
  body.nav-open .app-nav { display: flex; }
  .app-nav a, .app-nav .logout-btn { text-align: left; }
}

/* Cards */
.card { background: #fff; border-radius: 12px; padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: 0 2px 10px rgba(62,107,58,0.06); border: 1px solid var(--border); }
.card h2 { margin-top: 0; }

/* Forms */
.form-stack label { display: block; margin-bottom: 1rem; font-weight: 600; color: var(--bark); }
.form-stack label > input, .form-stack label > select, .form-stack label > textarea,
.form-stack > input, .form-stack > select, .form-stack > textarea {
  display: block; width: 100%; margin-top: 0.35rem;
  padding: 0.7rem 0.9rem; font: inherit;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
}
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus {
  outline: 2px solid var(--leaf); border-color: var(--leaf);
}
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > * { flex: 1 1 200px; }

/* Buttons */
.btn {
  display: inline-block; padding: 0.7rem 1.2rem;
  font: inherit; font-weight: 600;
  background: #fff; color: var(--moss); border: 1px solid var(--moss); border-radius: 10px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--sand-d); text-decoration: none; }
.btn-primary { background: var(--moss); color: #fff; border-color: var(--moss); }
.btn-primary:hover { background: var(--moss-d); color: #fff; }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fde8e4; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.9rem; }
.btn + .btn { margin-left: 0.4rem; }

/* Flashes / Alerts */
.flash, .alert {
  border-radius: 10px; padding: 0.75rem 1rem; margin-bottom: 1rem;
  border-left: 4px solid;
}
.flash-info, .alert-info     { background: #EFF6E9; border-color: var(--leaf); color: #3b5c2c; }
.flash-error, .alert-error   { background: #FDECE8; border-color: var(--danger); color: #7b2f23; }
.flash-warn, .alert-warn     { background: #FDF4E1; border-color: var(--warn); color: #7c5512; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.table th, .table td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); }
.table th { background: var(--sand-d); color: var(--bark); font-weight: 600; font-size: 0.9rem; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #FBF8EF; }

/* Grid */
.grid { display: grid; gap: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* Pills / Badges */
.pill { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.pill-ok      { background: #E3F1D8; color: #3B7A1C; }
.pill-no      { background: #FDECE8; color: var(--danger); }
.pill-maybe   { background: #FDF4E1; color: var(--warn); }
.pill-muted   { background: var(--sand-d); color: var(--muted); }

/* Kalender (Eltern / Admin) */
.calendar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  max-width: 900px;
}
.calendar .cal-head { font-weight: 700; color: var(--bark); text-align: center; padding: 0.35rem 0; }
.cal-cell {
  aspect-ratio: 1 / 1.1;
  min-height: 72px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: transform .1s;
}
.cal-cell:hover:not(.cell-locked):not(.cell-holiday) { transform: translateY(-1px); }
.cal-cell .cal-date { font-size: 0.9rem; color: var(--muted); align-self: flex-start; }
.cal-cell .cal-status {
  font-size: 2rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex: 1;
}
.cal-cell .cal-label { font-size: 0.7rem; color: var(--muted); }

.cell-yes   .cal-status { color: var(--ok); }
.cell-no    .cal-status { color: var(--danger); }
.cell-maybe .cal-status { color: var(--warn); }
.cell-empty .cal-status::before { content: '—'; color: var(--muted); font-weight: 400; }

.cal-cell.cell-holiday, .cal-cell.cell-closure {
  background: repeating-linear-gradient(45deg, #EFE8D4, #EFE8D4 6px, #E4D9BC 6px, #E4D9BC 12px);
  cursor: not-allowed;
}
.cal-cell.cell-bridge { background: #ECE9DD; }
.cal-cell.cell-bridge::after {
  content: 'Brücke'; position: absolute; top: 2px; right: 4px;
  font-size: 0.6rem; color: var(--muted);
}
.cal-cell.cell-locked { opacity: 0.8; cursor: default; }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 0.3rem; }

/* Bulk-Panel */
.bulk-panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.bulk-panel h3 { margin-top: 0; }
.weekday-row { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.weekday-row label {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  user-select: none;
  min-width: 48px;
}
.weekday-row input { width: auto; margin: 0; }
.preset-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* Responsive */
@media (max-width: 600px) {
  .calendar { gap: 4px; grid-template-columns: repeat(5, 1fr); }
  .cal-cell { min-height: 60px; padding: 0.25rem; }
  .cal-cell .cal-status { font-size: 1.4rem; }
}

/* Wochenansicht (Erzieher / Admin) */
.week-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.75rem; }
.week-col  { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; min-height: 160px; }
.week-col-closed { background: var(--sand-d); opacity: 0.85; }
.week-head { border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; margin-bottom: 0.5rem; }
.week-day  { font-weight: 700; color: var(--bark); font-size: 1rem; }
.week-date { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }
.week-count { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.week-list { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.week-list li { padding: 0.2rem 0; border-top: 1px dashed var(--border); font-size: 0.9rem; }
.week-list li:first-child { border-top: 0; }
@media (max-width: 720px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-col { min-height: 0; }
}

/* Print (Erzieher-Druckansicht) */
@media print {
  body { background: #fff; }
  .app-head, .app-foot, .logout-form, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #999; }
  .table th { background: #eee; }
}

/* Utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
