/* --------------------------------------------------------
   Grundlayout: Container, Sidebar und main
   -------------------------------------------------------- */
:root {
  --topbar-height: 56px;   /* passe an deine tatsächliche Topbar-Höhe an */
  --footer-height: 40px;   /* passe an deine Footer-Höhe an */
  /* Standardbreite der Sidebar */
  --sidebar-width: 240px;
  /* Minimal- und Maximalwerte */
  --sidebar-min: 150px;
  --sidebar-max: 50%;
}

body {
  margin: 0;
  position: relative;
  height: 100vh;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;    /* ← hier hinzufügen */
}

h2 {
  margin: 1;
  font-size: 1.5rem;
  text-align: center;
}

.container {
  position: absolute;
  top: var(--topbar-height);
  bottom: var(--footer-height);
  left: 0;
  right: 0;
  display: flex;
}

/* Sidebar: linke Leiste mit fester Breite */
.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  min-width: var(--sidebar-min);
  max-width: var(--sidebar-max);
  resize: horizontal;    /* Griff rechts zum Ziehen */
  overflow: auto;        /* Scroll bei Überlauf */
  background-color: #f4f4f4;
  border-right: 1px solid #ddd;
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100%;
  /* height: calc(100% - var(--topbar-height)); */
  /* overflow: hidden;         / * geändert: scroll nur im courseList * / */
}

.sidebar h2 {
  margin-top: 0;
  font-size: 1.2rem;
}

/* Die Kursliste scrollt bei Überlauf */
.sidebar #courseList {
  flex: 1;                  /* füllt den restlichen Platz */
  overflow-y: auto;         /* aktiviert Scrollen */
}

/* --------------------------------------------------------
   Styling der Stundenplan-Tabelle
   -------------------------------------------------------- */
.timetable-container {
  flex: 1 1 auto;
  height: 100%;
  overflow: auto;
  padding: 16px;
  box-sizing: border-box;
  background-color: #fff;
  min-width: 0;          /* wichtig, damit das Flex-Item bei Bedarf kleiner wird */
}

.timetable {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed; /* alle Spalten gleich breit */
}

.timetable th,
.timetable td {
  border: 1px solid #ccc;
  text-align: center;
  vertical-align: middle;
  padding: 4px;
  position: relative;
}

/* Alternierender Hintergrund pro Tag (je zwei Spalten A/B) */
.timetable td[data-day="1"],
.timetable td[data-day="3"] {
  background-color: #eeeeee;
}
.timetable td[data-day="0"],
.timetable td[data-day="2"],
.timetable td[data-day="4"] {
  background-color: #fff;
}

/* Mittagspause Zellen (dunkelgrau) */
.timetable td.lunch {
  background-color: #666 !important;
}

.timetable th {
  background-color: #eaeaea;
  font-weight: bold;
  font-size: 0.95rem;
}

.hour-label {
  background-color: #f0f0f0;
  font-weight: bold;
  width: 40px;
}

/* Unterrichtszellen */
.cell {
  height: 48px; /* feste Höhe */
}

/* Inhalt einer belegten Zelle */
.cell .content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1.2;
  color: #000;
  box-sizing: border-box;
  padding: 2px;
  white-space: pre-wrap !important;

}

/* --------------------------------------------------------
   Zusätzliche Styles für gruppierte Kurse mit <details>
   -------------------------------------------------------- */

/* Grundstruktur für die Details‐Gruppen */
.sidebar details {
  margin-bottom: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  overflow: hidden;
}

/* Wenn eine Gruppe offen ist, etwas andere Rahmenfarbe */
.sidebar details[open] {
  border-color: #007bff;
}

/* Das Summary selbst */
.sidebar summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.95rem;
  list-style: none; /* Punkt entfernen */
}

/* Kleines Pfeil‐Icon rechts (Dreieck) */
.sidebar summary::-webkit-details-marker {
  display: none;
}
.sidebar summary::before {
  content: "▶";
  font-size: 0.85rem;
  margin-right: 6px;
  transition: transform 0.2s ease-in-out;
}
.sidebar details[open] summary::before {
  transform: rotate(90deg);
}

/* --------------------------------------------------------
   Layout für einzelne Kurs-Einträge (.course-item)
   -------------------------------------------------------- */
.sidebar .course-item {
  display: grid;
  /* Haken-Spalte + Content-Spalte */
  grid-template-columns: auto 1fr;
  /* Zeile 1: Fach + Lehrer, Zeile 2: Termine */
  grid-template-rows: auto auto;
  grid-gap: 4px 8px;
  align-items: start;
  padding: 6px 8px;
  border-top: 1px solid #eee;
  background-color: #fafafa;
  font-size: 0.9rem;
}

/* Checkbox ganz links, über beide Zeilen */
.sidebar .course-item input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1 / span 2;
  margin: 4px 6px 0 0;
}

/* Kursname + Lehrer rechts davon in Zeile 1 */
.sidebar .course-item label {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

/* Fach fett */
.sidebar .course-item label .subject {
  font-weight: bold;
  white-space: nowrap;
}

/* Lehrer normal */
.sidebar .course-item label .teacher {
  font-weight: normal;
  color: #555;
  margin-top: 2px;
  white-space: nowrap;
}

/* Sportart in der Sidebar-Kursliste kursiv und kleiner */
.sidebar .course-item label .sport-art {
  display: block;       /* jede Sportart in neuer Zeile */
  font-style: italic;
  font-size: 0.8rem;
  color: #555;
  margin-top: 2px;
}

/* Termine rechtsbündig unter dem Label (Zeile 2, Spalte 2) */
.sidebar .course-item .schedule-text {
  grid-column: 2;
  grid-row: 2;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #555;
}

/* Jede Terminzeile etwas Abstand */
.sidebar .course-item .schedule-text div {
  margin-bottom: 4px;
}

/* deaktivierte Kurse in der Sidebar heller & kursiv */
.course-item.disabled {
  /* etwas helleres Grau */
  color: #888;
}

.course-item.disabled label {
  /* kursiver Text */
  text-decoration: line-through;
  /* sicherstellen, dass das Label die Farbe übernimmt */
  color: inherit;
}

/* --------------------------------------------------------
   Scrollbar-Optik (optional)
   -------------------------------------------------------- */
.sidebar::-webkit-scrollbar,
.timetable-container::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.timetable-container::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

/* --------------------------------------------------------
   Sidebar Steuerungselemente
   -------------------------------------------------------- */
.sidebar-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.sidebar-controls button {
  flex: 1;
  padding: 4px;
  font-size: 0.9rem;
}

/* --------------------------------------------------------
   Anzeige Gesamtstunden unter dem Stundenplan
   -------------------------------------------------------- */
.timetable-container .total-hours {
  margin-top: 12px;
  text-align: right;
  font-weight: bold;
  font-size: 1rem;
}

/* --------------------------------------------------------
   Speichern/Laden Steuerungselemente
   -------------------------------------------------------- */
.sidebar-save-load {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.sidebar-save-load button {
  padding: 4px;
  font-size: 0.9rem;
}


/* --------------------------------------------------------
   Top‐Bar mit Datei‐Dropdown und Aktionen
   -------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background-color: #f4f4f4;
  border-bottom: 1px solid #ddd;
  gap: 12px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  z-index: 1000;
}
.topbar label {
  font-weight: bold;
}
.topbar-controls {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

#saveSelection,
#loadSelection {
  visibility: hidden; 
}

/* Hover‐Cursor auf belegten Zellen */
.cell.filled:hover {
  cursor: not-allowed;
}

/* Highlight‐Outline bei Hover */
.cell.filled.highlight {
  outline: none;  
  /* roter Innen-Schatten für Rand */
  box-shadow: inset 0 0 0 3px rgb(255, 0, 0);
  /* helle Hintergrund-Änderung */
  background-color: rgba(255, 0, 0, 0.1);
  /* leicht heraufgesetzte Zelle */
  position: relative;
  z-index: 1;
}

/* Konflikt‐Highlight für Stundenplan‐Zellen */
.cell.conflict-highlight {
  /* kräftiger oranger Rahmen */
  box-shadow: inset 0 0 0 3px rgb(255, 0, 0);
  /* leicht orange Hinter­grund */
  background-color: rgba(255, 165, 0, 0.2);
}

/* Fußleiste für Warnmeldungen */
#messageBar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #ff2a00;        /* helles Gelb */
  color: #fff6d9;             /* dunkles Gelb/Braun */
  border-top: 1px solid #ffeeba;
  padding: 8px 16px;
  font-size: 0.9rem;
  box-sizing: border-box;
  display: block;             /* immer anzeigen */
  z-index: 1000;
  white-space: pre-wrap;     /* Mehrzeilige Warnungen erlauben */
}

/* --------------------------------------------------------
   Fullscreen-Overlay für Warnhinweis
   -------------------------------------------------------- */
.overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.overlay.hidden {
  display: none;
}
.overlay-content {
  background: #fff;
  padding: 24px;
  max-width: 320px;
  text-align: center;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.overlay-content p {
  margin-bottom: 16px;
  font-size: 1rem;
}
.overlay-content button {
  padding: 8px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}
