/* ClassTests v2-Refresh — Komponenten-Overrides + App-Shell
 * --------------------------------------------------------------
 * Wird NACH style.css geladen. Drei Aufgaben:
 *  1) Komponenten-Reskin: --ct-* Klassen visuell auf v2-Stil
 *  2) Neue v2-Komponenten: .shell .sidebar .topbar .btn .card .tbl …
 *  3) Aliase: .btn ↔ .ct-btn, .card ↔ .ct-card etc.
 *
 * Rollback: Datei aus header.ejs entfernen → ClassTests sieht aus
 * wie vor dem Refresh.
 */

/* ============================================================ */
/* 1 · TOPBAR — bestehende .ct-navbar visuell aktualisieren     */
/* ============================================================ */

/* Topbar wird halbtransparent + blur (statt Violett-Gradient) */
.ct-navbar {
  background: rgba(238, 245, 249, 0.82) !important;
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}
.ct-navbar-brand,
.ct-navbar-link,
.ct-navbar-user-button {
  color: var(--ink) !important;
}
.ct-navbar-link:hover,
.ct-navbar-link.active {
  background: rgba(10,11,16,0.04) !important;
  color: var(--ink) !important;
}
.ct-nav-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}
.ct-nav-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
}

/* ============================================================ */
/* 2 · BUTTON-RESKIN                                            */
/* ============================================================ */

.ct-btn {
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--r-md);
  transition: transform var(--t-fast) var(--ease),
              background var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              border-color var(--t-mid) var(--ease),
              color var(--t-mid) var(--ease);
}
.ct-btn-primary {
  background: var(--ink) !important;
  color: #fff !important;
  border: 1px solid var(--ink);
  box-shadow: none;
}
.ct-btn-primary:hover:not(:disabled) {
  background: #000 !important;
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}
.ct-btn-secondary {
  background: var(--amber) !important;
  color: #fff !important;
  border: 1px solid var(--amber);
  box-shadow: 0 2px 6px rgba(255,144,104,.25);
}
.ct-btn-secondary:hover:not(:disabled) {
  background: var(--amber-2) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(255,144,104,.35);
}
.ct-btn-outline {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border: 1px solid var(--border);
}
.ct-btn-outline:hover:not(:disabled) {
  background: var(--surface-2) !important;
  border-color: var(--border-2);
}
.ct-btn-warning {
  background: var(--warning);
  color: #fff;
  border: 1px solid var(--warning);
}
.ct-btn-danger {
  background: transparent !important;
  color: var(--danger) !important;
  border: 1px solid transparent;
}
.ct-btn-danger:hover:not(:disabled) {
  background: rgba(255,85,112,0.08) !important;
}

/* ============================================================ */
/* 3 · CARD / FORM / BADGE / TABLE Refresh                      */
/* ============================================================ */

.ct-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: none;
}
.ct-card:hover {
  transform: none;
  box-shadow: var(--sh-sm);
}

/* Karten in Grid-Zellen sollen die volle Zeilenhöhe ausfüllen, damit
 * z.B. Klassen-Karten mit unterschiedlich viel Inhalt gleich hoch wirken. */
.ct-stats-grid > .ct-card,
.ct-stats-grid > .ct-card-link {
  height: 100%;
}
.ct-stats-grid {
  align-items: stretch;
}

.ct-input, .ct-select, .ct-textarea {
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  transition: border-color var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease);
}
.ct-input:focus, .ct-select:focus, .ct-textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255,144,104,0.18);
  outline: none;
}

.ct-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}

.ct-badge {
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: rgba(10,11,16,0.06);
  color: var(--ink-2);
  padding: 2px 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.ct-badge-success { background: rgba(24,166,122,0.12); color: var(--success); }
.ct-badge-warning { background: rgba(224,138,46,0.16); color: #854d0e; }
.ct-badge-danger  { background: rgba(255,85,112,0.14); color: #c83054; }

.ct-table thead th,
.ct-table th {
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: var(--mute) !important;
  background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
}
.ct-table tbody td { color: var(--ink); }
.ct-table tbody tr:hover { background: var(--surface-2); }

/* ============================================================ */
/* 4 · APP-SHELL: .shell .sidebar .topbar (für Lehrer-Bereich)  */
/* ============================================================ */

.shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar"
    "main";
  min-height: 100vh;
  background: var(--bg);
}
.shell .sidebar {
  display: none;
  grid-area: sidebar;
  height: 100vh;
  position: sticky;
  top: 0;
}
.shell .topbar { grid-area: topbar; position: sticky; top: 0; z-index: 40; }
.shell > main,
.shell > .main {
  grid-area: main;
  max-width: 100%;
  min-width: 0; /* verhindert Overflow durch Tabellen */
}
/* Bestehende Templates haben oft <main class="ct-container"> mit eigenem
 * padding. Wir respektieren das, ergänzen nur ggf. fehlendes top-padding,
 * damit der Inhalt nicht direkt unter dem Topbar klebt. */
.shell > main.ct-container,
.shell > main { padding: 20px; }
@media (min-width: 1024px) {
  .shell > main.ct-container,
  .shell > main { padding: 28px 32px; }
}

/* Mobile-Drawer */
.shell.drawer-open::before {
  content: '';
  position: fixed; inset: 0;
  background: rgba(10,11,16,0.4);
  z-index: 45;
  backdrop-filter: blur(2px);
  animation: ctDrawFade var(--t-mid) var(--ease);
}
@keyframes ctDrawFade { from { opacity: 0; } to { opacity: 1; } }

.shell.drawer-open .sidebar {
  display: flex;
  position: fixed; left: 0; top: 0; bottom: 0;
  width: min(280px, 84vw);
  z-index: 50;
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  box-shadow: var(--sh-lg);
  animation: ctDrawSlide var(--t-slow) var(--ease);
}
@keyframes ctDrawSlide { from { transform: translateX(-100%); } to { transform: translateX(0); } }

@media (min-width: 1024px) {
  .shell {
    grid-template-columns: var(--sb-w) 1fr;
    grid-template-areas:
      "sidebar topbar"
      "sidebar main";
  }
  .shell .sidebar { display: flex; }
  .shell .main { padding: 28px 32px; }
}

/* Sidebar */
.sidebar {
  width: var(--sb-w);
  background: var(--purple);
  color: rgba(255,255,255,0.86);
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 6px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
  position: relative; z-index: 2;
  text-decoration: none;
}
.sb-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--amber), var(--amber-2));
  color: #fff; font-size: 12px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(255,144,104,.35);
}
.sb-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -0.015em; }
.sb-sub  { font-size: 11px; color: rgba(255,255,255,0.55); }

.sb-group { margin-bottom: 12px; position: relative; z-index: 2; }
.sb-group.sb-bottom {
  margin-top: auto; margin-bottom: 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sb-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  padding: 0 8px 8px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  color: rgba(255,255,255,0.74);
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  position: relative;
}
.sb-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sb-item.active {
  background: rgba(255,255,255,0.10);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--amber);
}
.sb-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}
.sb-count {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.85);
  padding: 1px 7px; border-radius: 999px;
}

/* Sterne in Sidebar */
.sb-stars { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sb-stars .star {
  position: absolute;
  color: #fff3d6;
  text-shadow:
    0 0 4px rgba(255,220,150,0.7),
    0 0 10px rgba(255,180,80,0.4);
  animation: ctStarTwinkle 4s var(--ease) infinite;
}
.sb-stars .star.sm { font-size: 8px;  opacity: 0.6; }
.sb-stars .star.md { font-size: 12px; opacity: 0.8; }
.sb-stars .star:nth-child(2n) { animation-delay: 1.2s; }
.sb-stars .star:nth-child(3n) { animation-delay: 2.1s; }
@keyframes ctStarTwinkle {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 0.95; transform: scale(1.1); }
}

/* Topbar (für App-Shell) */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(238, 245, 249, 0.82);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; }
.tb-menu {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--ink); cursor: pointer;
}
.tb-menu:hover { background: var(--surface-2); border-color: var(--border-2); }
@media (min-width: 1024px) { .tb-menu { display: none; } }
.tb-title {
  font-size: 14px; font-weight: 600;
  color: var(--ink); margin: 0;
}

.user-chip {
  display: none;
  align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--t-mid) var(--ease);
}
@media (min-width: 640px) { .user-chip { display: inline-flex; } }
.user-chip:hover { border-color: var(--border-2); }
.uc-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fde4c0, #f3c98a);
  color: #5a3a0a; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border);
}
.uc-name { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.uc-sub  { font-size: 10.5px; color: var(--mute); line-height: 1.2; }

/* User-Chip Dropdown (klein, dezent) */
.uc-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
  padding: 6px;
  z-index: 100;
  display: none;
}
.uc-menu.open { display: block; }
.uc-menu a, .uc-menu button {
  display: block; width: 100%;
  padding: 8px 12px;
  font: inherit; font-size: 13px;
  color: var(--ink); text-align: left;
  background: transparent; border: 0; border-radius: var(--r-sm);
  cursor: pointer; text-decoration: none;
}
.uc-menu a:hover, .uc-menu button:hover {
  background: var(--surface-2);
}
.user-chip { position: relative; }

/* ============================================================ */
/* 5 · ALIASE — kurze v2-Klassen als Synonyme zu --ct-*         */
/* ============================================================ */

.btn        { /* Basis-Klasse, optional verwendbar — sonst .ct-btn */
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 40px;
  border-radius: var(--r-md);
  font: inherit; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer;
  white-space: nowrap;
  transition: transform var(--t-fast) var(--ease),
              background var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              border-color var(--t-mid) var(--ease),
              color var(--t-mid) var(--ease);
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #000; transform: translateY(-1px); box-shadow: var(--sh-sm); }
.btn-accent  { background: var(--amber); color: #fff; box-shadow: 0 2px 6px rgba(255,144,104,.25); }
.btn-accent:hover:not(:disabled) { background: var(--amber-2); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(255,144,104,.35); }
.btn-ghost   { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--border-2); background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; gap: 6px; }
.btn-icon { padding: 0; width: 36px; min-height: 36px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: var(--sp-4);
}

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--mute); text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--surface-2); }

/* ============================================================ */
/* 6 · BODY-Background passend zur neuen Palette                */
/* ============================================================ */

body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================ */
/* 7 · GLÄTTE-PASS (Paket 1)                                    */
/* ============================================================ */

/* Quill-Editor an Form-Elementhöhen anpassen */
.ql-toolbar.ql-snow {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--surface-2);
}
.ql-container.ql-snow {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--surface);
  min-height: 120px;
}
.ql-editor { min-height: 100px; padding: 12px; }

/* Klassen-Multiselect optisch wie Form-Element */
#exam-classes-list {
  min-height: 96px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 10px;
}
#exam-classes-list:focus-within {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255,144,104,.18);
}

/* Tabellen-Header atmender machen */
.ct-table thead th,
.ct-table th {
  padding: 0.625rem 1rem !important;
}
.ct-table tbody td {
  padding: 0.75rem 1rem;
}

/* Tab-Border-Flicker beseitigen: inaktive Tabs bekommen
 * 2px transparenten Border, aktive den primary-Border. So
 * keine Höhenänderung beim Wechsel. */
.ct-tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.ct-tab {
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
}
.ct-tab.active {
  border-bottom-color: var(--amber);
  color: var(--ink);
}
.ct-tab:hover:not(.active) {
  color: var(--ink);
}

/* Matching-Ergebnis-Reihe in results.ejs: Mobile stacked, ab 600px 2 Spalten */
.ct-result-match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ct-space-sm);
}
@media (min-width: 600px) {
  .ct-result-match-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* Aktions-Button-Gruppen mit dünnem Trenner */
.ct-btn-group {
  display: inline-flex;
  align-items: center;
  gap: var(--ct-space-xs);
  padding: 0 var(--ct-space-sm);
  border-right: 1px solid var(--border);
}
.ct-btn-group:last-of-type { border-right: none; padding-right: 0; }
.ct-btn-group:first-of-type { padding-left: 0; }
