/* ===========================================================================
   aufgaben.css – Aufgabenplanung
   Fügt sich in das bestehende dashboard.css-System ein.
   Nutzt dessen .modal__*, .dash-panel, .calendar-card; ergänzt nur das,
   was spezifisch für die Aufgabenplanung ist (Kalender-Grid, Aufgabenkarten).
   =========================================================================== */

/* ===== MODAL-ROOT =========================================================
   Alle Modals werden dynamisch hier hineingeladen.
   Der .modal__backdrop (aus dashboard.css) ist das äußere Element jeder
   Modal-Datei und übernimmt den Fullscreen-Overlay. Wir überschreiben hier
   nur die Positionierung, damit der Backdrop fixed über dem ganzen Viewport
   liegt (und über deiner comm-bar mit z-index: 1030). */

#modal-root:empty { display: none; }

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: none;
}

#modal-root > .modal__backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  pointer-events: all;
}

body.modal-open { overflow: hidden; }

/* ===== HEADER-ZEILE / ACTION-BAR ========================================== */

.ap-hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}
.ap-hdr h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.15;
  color: #1f2937;
}
.ap-hdr p {
  margin: 4px 0 0;
  font-size: .88rem;
  color: #6b7280;
  font-weight: 500;
}
.ap-abar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== BUTTONS ============================================================
   Ergänzend zu eurem bestehenden Button-System. */

.ap-btn {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: .82rem;
  height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
}
.ap-btn-sec { background: #e5e7eb; color: #1f2937; }
.ap-btn-sec:hover { background: #d1d5db; }
.ap-btn-pri {
  background: #22c55e;
  color: #fff;
  box-shadow: 0 4px 10px rgba(34,197,94,.25);
}
.ap-btn-pri:hover { background: #16a34a; }
.ap-btn-ghost { background: transparent; color: #6b7280; padding: 0 10px; }
.ap-btn-ghost:hover { background: rgba(0,0,0,.04); color: #1f2937; }
.ap-btn-danger { background: transparent; color: #b3261e; }
.ap-btn-danger:hover { background: #fef2f2; }
.ap-btn-sm { height: 28px; padding: 0 10px; font-size: .72rem; border-radius: 10px; }

/* ===== WOCHEN-NAVIGATION ================================================== */

.ap-tb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ap-wn { display: flex; align-items: center; gap: 4px; }
.ap-wn button {
  border: 0;
  background: transparent;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  color: #1f2937;
  font-family: inherit;
}
.ap-wn button:hover { background: rgba(0,0,0,.05); }
.ap-wt {
  font-weight: 800;
  font-size: .98rem;
  padding: 0 8px;
  min-width: 190px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ap-today {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,.08);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  color: #1f2937;
  font-family: inherit;
}
.ap-today:hover { background: #e5e7eb; }

/* ===== STATS / CHIPS ====================================================== */

.ap-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.ap-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  border: 1px solid rgba(0,0,0,.06);
  background: #f8fafc;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}
.ap-chip .d { width: 8px; height: 8px; border-radius: 50%; background: #d1d5db; }
.ap-chip.done .d { background: #22c55e; }
.ap-chip.open .d { background: #3b82f6; }

/* ===== FILTER-REIHE ======================================================= */

.ap-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  margin-bottom: 12px;
}
.ap-fl {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  margin-right: 4px;
}
.ap-pf {
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  color: #1f2937;
  font-family: inherit;
  text-decoration: none;
}
.ap-pf:hover { background: #f8fafc; }
.ap-pf.on { background: #1f2937; color: #fff; border-color: #1f2937; }

/* ===== QUELLEN-LEGENDE ==================================================== */

.ap-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: .72rem;
  color: #6b7280;
  font-weight: 600;
}
.ap-lg { display: inline-flex; align-items: center; gap: 5px; }
.ap-ld { width: 7px; height: 7px; border-radius: 50%; }
.ap-ld.template { background: #5b21b6; }
.ap-ld.recurring { background: #0369a1; }
.ap-ld.manual { background: #9ca3af; }

/* ===== KALENDER-GRID ====================================================== */

.ap-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.ap-col { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ap-dh {
  padding: 8px 4px;
  background: #f8fafc;
  border-radius: 12px;
  text-align: center;
  border: 1px solid rgba(0,0,0,.04);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.ap-dh:hover { background: #e5e7eb; }
.ap-dh.today { background: #dcfce7; border-color: #86efac; }
.ap-dh-wd {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6b7280;
  line-height: 1;
}
.ap-dh.today .ap-dh-wd { color: #15803d; }
.ap-dh-dt {
  font-size: .95rem;
  font-weight: 800;
  margin-top: 3px;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}
.ap-dh.today .ap-dh-dt { color: #15803d; }

/* ===== AUFGABEN-KARTE ===================================================== */

.ap-task {
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  padding: 6px 7px;
  cursor: pointer;
  position: relative;
  transition: all .12s;
  min-width: 0;
}
.ap-task:hover {
  border-color: rgba(0,0,0,.2);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.ap-task-row { display: flex; gap: 5px; align-items: flex-start; }
.ap-chk {
  width: 13px;
  height: 13px;
  min-width: 13px;
  border: 1.5px solid #9ca3af;
  border-radius: 4px;
  margin-top: 1px;
  position: relative;
  background: #fff;
  flex-shrink: 0;
}
.ap-task.done { opacity: .5; }
.ap-task.done .ap-chk { background: #22c55e; border-color: #22c55e; }
.ap-task.done .ap-chk::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 4px;
  height: 7px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}
.ap-task.done .ap-tt { text-decoration: line-through; }
.ap-tbd { flex: 1; min-width: 0; }
.ap-tm {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.ap-tt {
  font-size: 11px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.25;
  margin-top: 1px;
  word-wrap: break-word;
  padding-right: 8px;
}
.ap-tsd { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; }
.ap-tsd.template { background: #5b21b6; }
.ap-tsd.recurring { background: #0369a1; }
.ap-tsd.manual { background: #9ca3af; }
.ap-pp {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 9px;
  font-weight: 800;
  margin-top: 3px;
  line-height: 1.3;
}
.ap-task-ghost {
  opacity: .4;
  background: #ede9fe !important;
  border: 1.5px dashed #5b21b6 !important;
}
.ap-task-chosen {
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  transform: rotate(1deg);
  cursor: grabbing !important;
}
.ap-task { cursor: pointer; }
.ap-drop-hint { display: none; }
.ap-droppable:empty .ap-drop-hint,
.ap-droppable .ap-drop-hint:only-child {
  display: block;
}
  background: #fafbfc;
  color: #9ca3af;
  font-size: 10px;
  text-align: center;
  padding: 12px 4px;
  border-radius: 10px;
  font-weight: 600;
  font-style: italic;
}

/* ===== WEEK-NOTICE (leere Wochen, nur recurring) ========================== */

.ap-ws {
  padding: 10px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: .8rem;
  color: #1e40af;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ap-ws button {
  background: #1e40af;
  color: #fff;
  border: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-left: auto;
  white-space: nowrap;
}
.ap-ws button:hover { background: #1e3a8a; }

/* ===========================================================================
   MODAL – ergänzende Styles (Modal-Basis kommt aus dashboard.css)
   =========================================================================== */

/* Tabs im Vorlagen-Modal */
.mdl-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid rgba(0,0,0,.08);
  background: #fff;
}
.mdl-tab {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  color: #6b7280;
  border-radius: 10px 10px 0 0;
  font-family: inherit;
  position: relative;
  bottom: -1px;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.mdl-tab.on { color: #1f2937; border-bottom-color: #22c55e; }

/* Zwei-Spalten-Layout (Liste + Detail) im Vorlagen-Modal */
.mdl-split {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 300px;
}
.mdl-split-list {
  border-right: 1px solid rgba(0,0,0,.08);
  background: #f8fafc;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.mdl-split-detail { padding: 16px 20px; overflow-y: auto; }
@media (max-width: 640px) {
  .mdl-split { grid-template-columns: 1fr; }
  .mdl-split-list { border-right: 0; border-bottom: 1px solid rgba(0,0,0,.08); max-height: 200px; }
}

/* Vorlagen-Liste: Item */
.mdl-item {
  background: #fff;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  text-decoration: none;
  color: inherit;
}
.mdl-item:hover { border-color: rgba(0,0,0,.18); }
.mdl-item.on { background: #ede9fe; border-color: #c4b5fd; }
.mdl-item-name { font-weight: 700; font-size: .82rem; line-height: 1.2; color: #1f2937; }
.mdl-item.on .mdl-item-name { color: #5b21b6; }
.mdl-item-meta {
  font-size: .68rem;
  color: #6b7280;
  margin-top: 3px;
  font-weight: 600;
}
.mdl-item.on .mdl-item-meta { color: #7c3aed; }

.mdl-new {
  background: #fff;
  border: 1px dashed rgba(0,0,0,.25);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  color: #6b7280;
  text-align: center;
  font-family: inherit;
  margin-top: 4px;
}
.mdl-new:hover { border-color: #22c55e; color: #22c55e; }

/* Vorlagen-Detail */
.mdl-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #ede9fe;
  color: #5b21b6;
  font-size: .7rem;
  font-weight: 800;
  border: 1px solid #c4b5fd;
}
.mdl-sec {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  margin: 8px 0 6px;
}
.mdl-desc {
  font-size: .82rem;
  color: #4b5563;
  line-height: 1.5;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 12px;
  border-left: 3px solid #5b21b6;
}

.mdl-pills { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.mdl-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,.06);
  font-size: .72rem;
  font-weight: 700;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}
.mdl-pill b { color: #5b21b6; font-weight: 800; }

/* Timeline (Tagesablauf) */
.mdl-tl { display: flex; flex-direction: column; gap: 2px; }
.mdl-slot {
  display: grid;
  grid-template-columns: 54px 14px 1fr;
  gap: 10px;
  align-items: stretch;
  min-height: 52px;
}
.mdl-t {
  font-size: .75rem;
  font-weight: 800;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
  padding-top: 10px;
  text-align: right;
}
.mdl-line { position: relative; display: flex; justify-content: center; align-items: flex-start; padding-top: 12px; }
.mdl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5b21b6;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px #5b21b6;
  position: relative;
  z-index: 1;
}
.mdl-line::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: -2px;
  left: 50%;
  width: 1.5px;
  background: #e5e7eb;
  transform: translateX(-50%);
}
.mdl-slot:last-child .mdl-line::before { bottom: auto; height: 16px; }
.mdl-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.mdl-card-t { font-weight: 800; font-size: .82rem; color: #1f2937; line-height: 1.3; }
.mdl-card-m { font-size: .72rem; color: #6b7280; margin-top: 2px; font-weight: 600; }

/* Usage-Info */
.mdl-usage {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: .75rem;
  color: #4b5563;
  line-height: 1.6;
  font-weight: 600;
}
.mdl-usage b { color: #1f2937; font-weight: 800; }

/* ===== FORM-INPUTS IM MODAL =============================================== */

.field { display: grid; gap: 6px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-label {
  font-size: .8rem;
  font-weight: 700;
  color: #1f2937;
}
.field-input,
.field-select,
.field-textarea {
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(17,24,39,.03);
  border: 1px solid rgba(17,24,39,.14);
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  color: #1f2937;
  box-sizing: border-box;
}
.field-textarea { height: auto; min-height: 70px; padding: 10px 12px; }
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: none;
  background: #fff;
  border-color: rgba(17,24,39,.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,.15);
}
.field-input.has-error,
.field-select.has-error,
.field-textarea.has-error {
  border-color: #b3261e;
  background: #fef2f2;
}
.field-error {
  font-size: .72rem;
  color: #b3261e;
  font-weight: 700;
  margin-top: 2px;
}

/* ===== VORSCHAU-BOX (im Apply-Modal) ====================================== */

.mdl-preview {
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mdl-pv-sum { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: .75rem; }
.mdl-pv-num {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #fff;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.06);
  font-weight: 700;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}
.mdl-pv-num .dd { width: 7px; height: 7px; border-radius: 50%; }
.mdl-pv-ok { font-size: .75rem; font-weight: 700; color: #15803d; }
.mdl-pv-conflict { font-size: .75rem; font-weight: 700; color: #b3261e; }
.mdl-pv-list { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.mdl-pv-it {
  display: grid;
  grid-template-columns: 44px 8px 1fr;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  background: #fff;
  border-radius: 8px;
  font-size: .72rem;
}
.mdl-pv-it .dd { width: 6px; height: 6px; border-radius: 50%; justify-self: center; }
.mdl-pv-tm { font-weight: 800; color: #1f2937; font-variant-numeric: tabular-nums; }
.mdl-pv-nm { font-weight: 700; color: #1f2937; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdl-pv-nm span { color: #6b7280; font-weight: 600; }

/* Wochenauswahl (radio-ähnliche Liste) */
.mdl-wk-grid { display: flex; flex-direction: column; gap: 6px; }
.mdl-wk {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1.5px solid rgba(0,0,0,.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all .12s;
  text-align: left;
  font-family: inherit;
  text-decoration: none;
  color: inherit;
}
.mdl-wk:hover { border-color: rgba(0,0,0,.2); }
.mdl-wk.on { border-color: #22c55e; background: #f0fdf4; }
.mdl-wk-rd {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #9ca3af;
  flex-shrink: 0;
  position: relative;
  background: #fff;
}
.mdl-wk.on .mdl-wk-rd { border-color: #22c55e; background: #22c55e; }
.mdl-wk.on .mdl-wk-rd::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}
.mdl-wk-b { flex: 1; min-width: 0; }
.mdl-wk-l { font-weight: 800; font-size: .82rem; color: #1f2937; }
.mdl-wk-m { font-size: .72rem; color: #6b7280; font-weight: 600; margin-top: 1px; }

/* Wochentag-Auswahl */
.mdl-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mdl-day {
  background: #fff;
  border: 1.5px solid rgba(0,0,0,.08);
  border-radius: 10px;
  padding: 8px 4px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  text-decoration: none;
  color: inherit;
}
.mdl-day:hover { border-color: rgba(0,0,0,.2); }
.mdl-day.on { background: #22c55e; border-color: #22c55e; color: #fff; }
.mdl-day-l {
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6b7280;
  line-height: 1;
}
.mdl-day.on .mdl-day-l { color: #dcfce7; }
.mdl-day-d { font-size: .82rem; font-weight: 800; margin-top: 3px; color: #1f2937; font-variant-numeric: tabular-nums; }
.mdl-day.on .mdl-day-d { color: #fff; }

/* Erfolg nach Anwenden */
.mdl-success {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin: 20px;
}
.mdl-success-i {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}
.mdl-success-t { font-weight: 800; color: #15803d; font-size: .95rem; }
.mdl-success-s { font-size: .75rem; color: #166534; margin-top: 4px; font-weight: 600; line-height: 1.5; }

/* ===== RECURRING-LISTE ==================================================== */

.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,.05);
  border-radius: 12px;
}
.rec-time { font-weight: 800; font-variant-numeric: tabular-nums; color: #1f2937; font-size: .82rem; }
.rec-title { font-weight: 700; color: #1f2937; font-size: .82rem; line-height: 1.3; }
.rec-meta { font-size: .72rem; color: #6b7280; margin-top: 2px; font-weight: 600; }
.rec-actions { display: flex; gap: 4px; }
.rec-freq-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: .7rem;
  font-weight: 800;
  margin-right: 6px;
}