/* ===================================================================
   Stundenplan (companion) — Styles
   Ergänzt styles.css / styles-companion.css. Touch-optimiert.
   =================================================================== */

/* ---- Unter-Reiter im Klassenbuch (Einträge / Stundenplan) ---- */
.kb-subtabs {
  display: flex; gap: 6px; margin: 2px 0 14px;
  background: var(--surface-2); padding: 4px; border-radius: 12px;
}
.kb-subtab {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 10px; border: 0; border-radius: 9px; background: transparent;
  color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; min-height: 40px;
}
.kb-subtab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ---- Kopfzeile / Werkzeuge ---- */
.sp-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sp-h2 { font-size: 18px; font-family: var(--font-display); margin: 0; }

.sp-weekbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 12px; }
.sp-weekinfo { flex: 1 1 auto; text-align: center; line-height: 1.2; }
.sp-weeknum { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.sp-weeknum .ti { color: var(--accent); }
.sp-weekrange { color: var(--text-2); font-size: 12.5px; }
.sp-now { font-size: 11px; font-weight: 600; color: var(--accent-2-text); background: var(--accent-2-bg); padding: 1px 7px; border-radius: 999px; }
.sp-weekbar .sp-today { flex: 0 0 auto; }

/* ---- Raster ---- */
.sp-gridwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; padding: 2px; }
.sp-grid { display: grid; gap: 6px; min-width: 460px; align-items: stretch; }
.sp-corner { display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.sp-dayhead {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 2px; border-radius: 10px; background: var(--surface-2);
  font-weight: 600; font-size: 13px; line-height: 1.1;
}
.sp-dayhead.today { background: var(--accent-soft); color: var(--accent); }
.sp-daydate { font-size: 10.5px; font-weight: 500; color: var(--text-3); }
.sp-dayhead.today .sp-daydate { color: var(--accent); }

.sp-timecell {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 1px;
  padding: 4px 6px 4px 0; text-align: right;
}
.sp-tlabel { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.sp-ttime { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.sp-pauserow {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 5px 10px; border-radius: 8px;
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, transparent 8px, transparent 16px);
  color: var(--text-3); font-size: 12px; font-weight: 500;
}
.sp-pausetime { font-variant-numeric: tabular-nums; }

.sp-cell {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  min-height: 52px; padding: 6px 6px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); text-align: left;
  --c: var(--text-3);
}
.sp-cell:not(.empty) {
  border-color: color-mix(in srgb, var(--c) 40%, var(--border));
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  border-left: 3px solid var(--c);
}
.sp-cell.empty { color: var(--text-3); align-items: center; justify-content: center; border-style: dashed; }
.sp-cell-subj { font-size: 12.5px; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 4px; line-height: 1.15; }
.sp-cell-subj .ti { color: var(--c); font-size: 14px; flex: 0 0 auto; }
.sp-cell.open { box-shadow: 0 0 0 2px var(--accent) inset; }
.sp-cell.today:not(.empty) { background: color-mix(in srgb, var(--c) 16%, var(--surface)); }
.sp-cell.ovr::after {
  content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px;
  border-radius: 2px; background: #f59f00; box-shadow: 0 0 0 2px var(--surface);
}
.sp-inds { display: flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--text-3); font-size: 11px; }
.sp-inds .ti { font-size: 13px; }
.sp-ind-viol {
  display: inline-flex; align-items: center; justify-content: center; min-width: 15px; height: 15px;
  padding: 0 3px; border-radius: 999px; background: #c0392b; color: #fff; font-size: 10px; font-weight: 700;
}

.sp-hint, .sp-section-empty, .sp-viol-empty {
  color: var(--text-3); font-size: 13px; text-align: center; padding: 14px 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.sp-section-empty, .sp-viol-empty { padding: 8px 4px; justify-content: flex-start; }

/* ---- Detailbereich ---- */
.sp-detail { margin-top: 14px; }
.sp-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sp-detail-when { display: flex; flex-direction: column; }
.sp-detail-date { font-weight: 600; font-size: 15px; font-family: var(--font-display); }
.sp-detail-time { color: var(--text-2); font-size: 12.5px; }
.sp-detail-subj { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.sp-subj-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-weight: 600; font-size: 13.5px; --c: var(--text-3);
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.sp-subj-chip .ti { color: var(--c); }
.sp-ovr-note { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: #b8860b; margin-bottom: 4px; }

.sp-fld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); margin-top: 12px; }
.sp-fld textarea, .sp-fld input, .sp-fld select {
  width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font-size: 15px; font-family: inherit; resize: vertical;
}

.sp-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.sp-section-t { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.sp-section-t .ti { color: var(--text-3); }
.sp-addbtn { margin-top: 8px; }

/* ---- Verstöße ---- */
.sp-viol {
  display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border-radius: 10px;
  background: var(--surface-2); border-left: 3px solid var(--c); margin-bottom: 6px; --c: var(--text-3);
}
.sp-viol > .ti { color: var(--c); font-size: 17px; margin-top: 1px; }
.sp-viol-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.sp-viol-who { color: var(--text-2); font-size: 12.5px; }
.sp-viol-note { color: var(--text-2); font-size: 12.5px; font-style: italic; }

.sp-violform { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.sp-violform .kb-who { margin-top: 0; }
.sp-violform-act { display: flex; gap: 8px; margin-top: 12px; }

/* ---- Anhänge ---- */
.sp-files { display: flex; flex-wrap: wrap; gap: 10px; }
.sp-fileitem { position: relative; }
.sp-thumb {
  width: 78px; height: 78px; border-radius: 10px; border: 1px solid var(--border-2);
  background-size: cover; background-position: center; cursor: pointer; padding: 0;
}
.sp-filechip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 180px; padding: 9px 12px;
  border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; min-height: 44px;
}
.sp-filechip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-file-del {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; min-height: 0;
  border-radius: 999px; border: 0; background: var(--text); color: var(--surface);
  display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-sm);
}
.sp-file-del.confirm { background: #c0392b; color: #fff; }

/* ---- Bearbeiten: Zeitraster-Zeilen ---- */
.sp-rowedits { display: flex; flex-direction: column; gap: 8px; }
.sp-rowedit { display: flex; align-items: center; gap: 6px; }
.sp-rowedit.pause { opacity: .92; }
.sp-rowedit select, .sp-rowedit input {
  padding: 8px 8px; border-radius: 9px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font-size: 14px; min-width: 0;
}
.sp-rowtype { flex: 0 0 92px; }
.sp-rowlabel { flex: 1 1 70px; }
.sp-rowtime { flex: 0 0 96px; font-variant-numeric: tabular-nums; }
.sp-rowdash { color: var(--text-3); }
@media (max-width: 520px) {
  .sp-rowtype { flex-basis: 78px; }
  .sp-rowtime { flex-basis: 84px; }
}

/* ---- Fach-Auswahl (Overlay) ---- */
.sp-pickmodal { max-width: 440px; }
.sp-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; max-height: 52vh; overflow-y: auto; }
.sp-pick {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 12px; border-radius: 11px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer; --c: var(--text-3); min-height: 46px;
}
.sp-pick .ti { color: var(--c); font-size: 17px; flex: 0 0 auto; }
.sp-pick.active { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 35%, transparent) inset; background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.sp-freitext { margin-bottom: 6px; }
@media (max-width: 420px) { .sp-picks { grid-template-columns: 1fr; } }

/* ---- Lightbox ---- */
.sp-lightbox {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(10, 10, 16, .82); backdrop-filter: blur(3px);
}
.sp-lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-md); }
.sp-lightbox-x {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px; width: 40px; height: 40px;
  border-radius: 999px; border: 0; background: rgba(255, 255, 255, .14); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer;
}
