/* ---------------------------------------------------------------------
   Farbschema: helle Variablen in :root, dunkle unter [data-theme="dark"].
   Reihenfolge wichtig für den "system"-Fall (kein explizites data-theme):
   prefers-color-scheme greift dann als Fallback.
--------------------------------------------------------------------- */

:root {
  --bg: #f6f4ff;
  --surface: #ffffff;
  --surface-alt: #f3f0ff;
  --border: #e6e1f9;
  --text: #211c34;
  --text-muted: #726c92;

  --primary: #7c5cff;
  --primary-2: #ff6ec7;
  --primary-hover: #6a49f2;
  --danger: #ff5570;
  --danger-bg: #ffe9ee;
  --success: #22c48d;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 4px 16px rgba(124, 92, 255, 0.1);
  --shadow-hover: 0 10px 28px rgba(124, 92, 255, 0.18);
  --shadow-modal: 0 20px 60px rgba(33, 20, 60, 0.25);

  --font: "Poppins", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16132a;
    --surface: #1f1b36;
    --surface-alt: #262040;
    --border: #362f54;
    --text: #f2effd;
    --text-muted: #a99fd6;

    --primary: #a48bff;
    --primary-2: #ff8bd6;
    --primary-hover: #b6a1ff;
    --danger: #ff7d95;
    --danger-bg: #3a1e2a;
    --success: #3fdba0;

    --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-modal: 0 24px 70px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --bg: #16132a;
  --surface: #1f1b36;
  --surface-alt: #262040;
  --border: #362f54;
  --text: #f2effd;
  --text-muted: #a99fd6;

  --primary: #a48bff;
  --primary-2: #ff8bd6;
  --primary-hover: #b6a1ff;
  --danger: #ff7d95;
  --danger-bg: #3a1e2a;
  --success: #3fdba0;

  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-modal: 0 24px 70px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
}

/* Verspielte Hintergrund-Blobs */

.bg-blobs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  animation: float 16s ease-in-out infinite;
}

:root[data-theme="dark"] .blob {
  opacity: 0.25;
}

.blob-1 {
  width: 380px;
  height: 380px;
  top: -120px;
  left: -100px;
  background: var(--primary);
}

.blob-2 {
  width: 320px;
  height: 320px;
  top: 20%;
  right: -140px;
  background: var(--primary-2);
  animation-delay: -5s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  bottom: -140px;
  left: 30%;
  background: #ffb020;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -30px) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

/* Header */

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

.header-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  font-size: 34px;
}

#page-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  outline: none;
  border-radius: 8px;
  padding: 2px 6px;
  margin-left: -6px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#page-title:hover,
#page-title:focus {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  outline: 2px dashed var(--border);
  outline-offset: 3px;
}

.header-hint {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Banner (z. B. Netzwerkfehler) */

.banner {
  background: var(--danger-bg);
  color: var(--danger);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
}

.banner.hidden {
  display: none;
}

/* Login-Screen */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  padding: 40px 32px 32px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  animation: pop-in 0.25s ease;
}

.login-theme-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
}

.login-card h1 {
  font-size: 21px;
  font-weight: 700;
  margin: 10px 0 2px;
}

.login-card .field {
  text-align: left;
  margin: 18px 0 4px;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.field-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-submit {
  width: 100%;
  margin-top: 14px;
}

/* Buttons */

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.45);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
}

.btn-icon {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 6px;
  border-radius: 999px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-icon:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.theme-toggle:hover {
  transform: rotate(-14deg);
}

/* Board / weekly grid */

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 18px;
  padding: 28px 28px 60px;
  align-items: start;
}

@media (max-width: 900px) {
  .board {
    grid-template-columns: 1fr;
  }
}

.day-column {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.day-column:hover {
  box-shadow: var(--shadow-hover);
}

/* Drop-Ziel beim Ziehen einer Kachel per Drag & Drop */
.day-column.drag-over {
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
  background: var(--surface-alt);
}

/* Jeder Wochentag bekommt einen eigenen Farbakzent */
.day-column:nth-child(1) { --day-accent: #3ec1ff; }
.day-column:nth-child(2) { --day-accent: #7c5cff; }
.day-column:nth-child(3) { --day-accent: #ff6ec7; }
.day-column:nth-child(4) { --day-accent: #ffa23a; }
.day-column:nth-child(5) { --day-accent: #22d3b4; }

.day-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.day-header::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--day-accent, var(--primary));
  flex-shrink: 0;
}

.day-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.day-lessons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 20px;
}

.empty-day-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 22px 4px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* Lesson tile */

.lesson-tile {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--tile-bg, var(--surface-alt));
  border-left: 5px solid var(--tile-color, var(--primary));
  box-shadow: var(--shadow);
  cursor: grab;
  transition: box-shadow 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.lesson-tile:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px) scale(1.01);
}

.lesson-tile.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* Pausen-Kacheln: kompakt, etwa ein Drittel der normalen Höhe */
.lesson-tile--break {
  padding: 4px 13px;
  border-left-width: 3px;
  display: flex;
  align-items: center;
}

.lesson-time-inline {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.lesson-subject {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.lesson-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.lesson-note {
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 4px;
}

.add-lesson-btn {
  width: 100%;
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 9px;
  font-family: inherit;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  margin-top: auto;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.add-lesson-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--surface-alt);
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fade-in 0.15s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 26px 22px;
  box-shadow: var(--shadow-modal);
  animation: pop-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.field input {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

.color-field {
  border: none;
  padding: 0;
  margin: 0 0 14px;
}

.color-field legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0;
  margin-bottom: 6px;
}

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface) inset;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: -4px 0 12px;
}

.form-error.hidden {
  display: none;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.modal-actions-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.hidden {
  display: none !important;
}
