/* ══════════════════════════════════════════════════════════════════════
   shared.css – Gemeinsame Styles für alle Seiten der Lernplattform
   Florian Stricker · Klavierklasse · PH Heidelberg
   ══════════════════════════════════════════════════════════════════════ */

/* ── CSS-Variablen ────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg:         #0f0e0c;
  --surface:    #1a1814;
  --card:       #201e1a;
  --card-active:#fdf6e3;
  --card-next:  #2a2720;
  --gold:       #c9a84c;
  --gold-light: #e8c96a;
  --gold-dim:   rgba(201,168,76,0.12);
  --text:       #e8dfc8;
  --text-muted: #7a7060;
  --accent:     #8b3a2a;
  --text-dark:  #2a2520;
}
:root.light {
  color-scheme: light;
  --bg:         #f5f0e8;
  --surface:    #eee8d8;
  --card:       #f8f4ec;
  --card-active:#ffffff;
  --card-next:  #ddd6c6;
  --gold:       #8b6914;
  --gold-light: #a07a1a;
  --gold-dim:   rgba(139,105,20,0.08);
  --text:       #2a2520;
  --text-muted: #8a7e6e;
  --accent:     #8b3a2a;
}

/* ── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { max-width: 100vw; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Lato', -apple-system, sans-serif;
  font-weight: 400;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Inst-Header (oberste Zeile: PH · Klavierklasse · Stricker) ──────── */
.inst-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 40px;
  background: rgba(201,168,76,0.08);
  border-bottom: 1px solid rgba(201,168,76,0.2);
  font-family: 'Lato', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: rgba(201,168,76,0.75);
  position: relative;
  z-index: 2;
}
:root.light .inst-header {
  background: rgba(139,105,20,0.06);
  border-bottom-color: rgba(139,105,20,0.15);
  color: rgba(139,105,20,0.7);
}

/* inst-row: auf Desktop transparent (Kinder sind direkte flex-children) */
.inst-row { display: contents; }

.inst-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-style: italic;
  letter-spacing: 0.12em;
}

/* ── Main-Header (zweite Zeile: Logo · Nav · Buttons) ────────────────── */
.main-header {
  padding: 18px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
  border-bottom: 1px solid rgba(201,168,76,0.15);
  background: rgba(15,14,12,0.95);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 2;
}
:root.light .main-header {
  background: rgba(245,240,232,0.95);
  border-bottom-color: rgba(139,105,20,0.12);
}

/* ── User-Info (rechts im Header) ────────────────────────────────────── */
.user-info {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.user-info strong { color: var(--gold); }
:root.light .user-info { color: var(--text-muted); }

/* ── Logo ─────────────────────────────────────────────────────────────── */
.logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-transform: uppercase;
  flex-shrink: 0;
  text-decoration: none;
}
.logo span, .logo a { color: var(--text); font-weight: 400; text-decoration: none; }
.logo a { color: inherit; }
.logo-sub { color: var(--text-muted); font-size: 0.85em; }
:root.light .logo span { color: #5a5040; }

/* ── Nav-Links ────────────────────────────────────────────────────────── */
.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 1;
  flex-wrap: nowrap;
  min-width: 0;
}
.nav-links::-webkit-scrollbar { display: none; }
/* Dropdown sichtbar machen trotz overflow-x:auto – nur wenn per Klick geöffnet */
.nav-links:has(.el-dropdown-wrap.open) { overflow: visible; }

/* Im Journal-Header (flex-row): Nav nach rechts schieben */
.main-header .nav-links { margin-left: auto; }

.nav-link {
  padding: 4px 11px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: all 0.18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-link:hover {
  color: var(--gold);
  border-color: rgba(201,168,76,0.3);
}
/* Aktiv: nur goldene Farbe, kein Rahmen/Hintergrund */
.nav-link.active { color: var(--gold); }

:root.light .nav-link       { color: var(--text-muted); }
:root.light .nav-link:hover { color: var(--gold); border-color: rgba(139,105,20,0.25); }
:root.light .nav-link.active { color: var(--gold); }

.nav-sep { color: rgba(201,168,76,0.2); font-size: 0.7rem; flex-shrink: 0; }

/* ── EL-Dropdown in der Nav ────────────────────────────────────────── */
.el-dropdown-wrap {
  position: relative;
  flex-shrink: 0;
}
.el-dropdown-btn {
  padding: 4px 11px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Lato', sans-serif;
  white-space: nowrap;
  transition: all 0.18s;
}
.el-dropdown-btn:hover,
.el-dropdown-btn.active { color: var(--gold); border-color: rgba(201,168,76,0.3); }
.el-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  padding-top: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 6px;
  padding: 8px 0;
  min-width: 220px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.el-dropdown-wrap.open .el-dropdown-menu { display: block; }
.el-dropdown-group {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 14px 2px;
  opacity: 0.6;
}
.el-dropdown-item {
  display: block;
  padding: 7px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.el-dropdown-item:hover { background: rgba(201,168,76,0.08); color: var(--gold); }
.el-dropdown-item.active { color: var(--gold); }
:root.light .el-dropdown-btn { color: var(--text-muted); }
:root.light .el-dropdown-btn:hover,
:root.light .el-dropdown-btn.active { color: var(--gold); border-color: rgba(139,105,20,0.25); }
:root.light .el-dropdown-menu { background: var(--surface); border-color: rgba(139,105,20,0.15); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
:root.light .el-dropdown-item:hover { background: rgba(139,105,20,0.06); }

/* ── Header-Right (Zahnrad, Abmelden, Theme-Toggle) ──────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  min-width: 0;
}
.header-right::-webkit-scrollbar { display: none; }

/* ── Globale Formular-Konsistenz ──────────────────────────────────────── */
/* Selects in Journal-Seiten: einheitlich schwarz/dunkel im Dark-Theme,
   hell im Light-Theme. Trainer-Selects (.ctrl-select) haben eigene Regeln. */
.journal-select,
select.nav-select {
  background: var(--card);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 3px;
  color: var(--text);
  padding: 6px 10px;
  font-family: 'Lato', sans-serif;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
  color-scheme: dark;
}
:root.light .journal-select,
:root.light select.nav-select {
  background: var(--card);
  border-color: rgba(139,105,20,0.2);
  color-scheme: light;
}

/* ── Theme-Toggle ─────────────────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 3px;
  color: var(--gold);
  font-size: 0.82rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.18s;
  vertical-align: middle;
  margin-left: 4px;
}
.theme-toggle:hover {
  background: rgba(201,168,76,0.1);
  border-color: var(--gold);
}
:root.light .theme-toggle { border-color: rgba(139,105,20,0.3); }

/* ── Gemeinsame Light-Mode-Regeln (Trainer-Komponenten) ──────────────────── */
:root.light .card-next {
  background: #ddd6c6;
  border: 1px solid rgba(139,105,20,0.2);
  color: #2a2520;
}
:root.light .card-next .chord-root  { color: #2a2520; }
:root.light .card-next .chord-type  { color: #6b5010; }
:root.light .card-next .label-next  { color: rgba(80,60,10,0.55); }

:root.light .opt-btn          { color: #5a5040; border-color: rgba(139,105,20,0.2); }
:root.light .opt-btn.selected { background: rgba(139,105,20,0.1); border-color: var(--gold); color: var(--gold); }

:root.light .btn-preset        { color: #5a5040; border-color: rgba(139,105,20,0.2); }
:root.light .btn-preset.active { background: rgba(139,105,20,0.1); border-color: var(--gold); color: var(--gold); }

:root.light .preset-bar { background: rgba(139,105,20,0.04); border-color: rgba(139,105,20,0.12); }

:root.light .ctrl-select {
  background: #fff;
  border-color: rgba(139,105,20,0.25);
  color: var(--gold);
  color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b6914'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-color: #fff;
}

/* ── Tap-Visualisierung ─────────────────────────────────────────────────── */
.tap-wrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* ── Responsive: Tablet (max 900px) ──────────────────────────────────── */
@media (max-width: 900px) {
  .main-header { padding: 12px 20px; }
  .inst-header  { padding: 6px 20px; font-size: 0.68rem; }
  .user-info    { display: none; }
}

/* ── Responsive: Handy Hochformat (max 600px) ────────────────────────── */
@media (max-width: 600px) {
  /* inst-header: zweizeilig – PH/Stricker in Zeile 1, Klavierklasse zentriert */
  .inst-header {
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 5px 12px;
  }
  .inst-row {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
  .inst-center { position: static; transform: none; }

  .main-header { padding: 10px 16px; }
  .logo { font-size: 0.9rem; }
  .header-right { overflow-x: auto; padding-bottom: 2px; }
}

/* ── Responsive: kleines Handy (max 480px) ───────────────────────────── */
@media (max-width: 480px) {
  .logo { font-size: 0.82rem; }
  .logo-sub { display: none; }
}

/* ── Metronom-Controls (Akkord-, Kadenz-, Skalen-, Begleit-Trainer) ──────── */
.speed-control {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); flex-wrap: wrap; width: 100%;
}
.speed-control input[type="range"] {
  -webkit-appearance: none; flex: 1; min-width: 80px; max-width: 200px;
  height: 2px; background: rgba(201,168,76,0.3); border-radius: 2px;
  outline: none; cursor: pointer;
}
.speed-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--gold); cursor: pointer;
}
.speed-val {
  color: var(--gold-light); font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; display: inline-flex; align-items: center;
  cursor: pointer; user-select: none;
}
/* Fixed-width number slot: always holds exactly 3 digit-widths */
.speed-val #speedNum {
  display: inline-flex; align-items: center; justify-content: center;
  width: 3ch; gap: 0.2ch;
}
/* Tap-stroke spans: slightly narrower than 1ch so gaps are visible */
.tap-stroke {
  display: inline-block;
  width: 0.65ch; height: 0;
  border-bottom: 2px solid currentColor;
  vertical-align: middle;
  margin-bottom: 0.05em;
  flex-shrink: 0;
}
/* Small gap between number and BPM label */
.bpm-unit { padding-left: 0.5ch; }
.speed-val.tapping { color: var(--gold); }
/* tap-viz hidden – tap display merged into speedNum */
.tap-viz { display: none; }
.btn-adj {
  background: none; border: 1px solid rgba(201,168,76,0.4); border-radius: 3px;
  color: var(--gold); font-size: 1rem; line-height: 1;
  width: 28px; height: 28px; min-width: 28px; min-height: 28px; padding: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0; user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn-adj:hover { background: rgba(201,168,76,0.12); }
.btn-tap {
  background: none; border: 1px solid rgba(201,168,76,0.25); border-radius: 3px;
  color: var(--text-muted); font-family: 'Lato', sans-serif;
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 8px; height: 28px; cursor: pointer; transition: all 0.15s;
  flex-shrink: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn-metro {
  background: none; border: 1px solid rgba(201,168,76,0.3); border-radius: 3px;
  color: var(--gold); font-size: 0.9rem; line-height: 1;
  width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.18s; flex-shrink: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn-metro:hover  { background: rgba(201,168,76,0.12); border-color: var(--gold); }
.btn-metro.muted  { opacity: 0.35; }

:root.light .speed-control input[type="range"]                { background: rgba(139,105,20,0.2); }
:root.light .speed-control input[type="range"]::-webkit-slider-thumb { background: var(--gold); }
:root.light .btn-adj   { border-color: rgba(139,105,20,0.45); color: var(--gold); }
:root.light .btn-tap   { border-color: rgba(139,105,20,0.3);  color: var(--text-muted); }
:root.light .btn-metro { border-color: rgba(139,105,20,0.3);  color: var(--gold); }

/* Landscape-Toggle standardmäßig ausblenden (nur sichtbar wenn inst-header weg) */
.theme-toggle-landscape { display: none; }

/* ── Landscape mit wenig Höhe: inst-header ausblenden ────────────────── */
@media (orientation: landscape) and (max-height: 450px) {
  .inst-header { display: none; }
  /* Theme-Toggle erscheint im Haupt-Header wenn inst-header versteckt ist */
  .theme-toggle-landscape { display: inline-flex !important; }
}

/* ── Journal-Buttons (shared: index, admin, dozent) ──────────────────── */

/* ── Content-Bereich (Basis für alle Journal-Seiten) ─────────────────── */
.content {
  flex: 1;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.btn {
  padding: 5px 12px; border: 1px solid var(--gold); background: transparent;
  color: var(--gold); font-family: 'Lato', -apple-system, sans-serif;
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; transition: background 0.2s, color 0.2s;
  border-radius: 3px; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--gold); color: var(--bg); }
.btn-primary { background: var(--gold); color: var(--bg); font-weight: 700; }
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }
.btn-small { padding: 3px 8px; font-size: 0.62rem; }
.btn-auth  { padding: 10px 14px; font-size: 0.78rem; letter-spacing: 0.08em; margin-top: 8px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
:root.light .btn-primary { color: #fff; }
:root.light .btn:hover { color: #fff; }

/* ── Badges (shared: admin) ──────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.badge-admin   { background: rgba(90,122,176,0.15);  color: #5a7ab0; border: 1px solid rgba(90,122,176,0.3); }
.badge-dozent  { background: rgba(201,168,76,0.12);  color: #c9a84c; border: 1px solid rgba(201,168,76,0.3); }
.badge-active  { background: rgba(74,139,58,0.12);   color: #7ac96a; border: 1px solid rgba(74,139,58,0.3); }
.badge-inactive{ background: rgba(139,58,42,0.1);    color: #e07060; border: 1px solid rgba(139,58,42,0.2); }

/* ── Stat-Row (shared: admin, dozent) ────────────────────────────────── */
.stat-row { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
@media (max-width: 600px) {
  .stat-row { gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
}

/* ── Feedback-Meldungen (shared: alle Journal-Seiten) ────────────────── */
.msg { padding:10px 14px; border-radius:4px; font-size:0.82rem; margin-bottom:16px; }
.success-msg, .msg-success {
  padding: 10px 14px; background: rgba(74,139,58,0.15);
  border: 1px solid rgba(74,139,58,0.3); border-radius: 4px;
  color: #7ac96a; font-size: 0.82rem; margin-bottom: 16px;
}
.error-msg, .msg-error {
  padding: 10px 14px; background: rgba(139,58,42,0.15);
  border: 1px solid rgba(139,58,42,0.3); border-radius: 4px;
  color: #e07060; font-size: 0.82rem; margin-bottom: 16px;
}
:root.light .success-msg, :root.light .msg-success { background: rgba(74,139,58,0.08); color: #3a7a2a; }
:root.light .error-msg,   :root.light .msg-error   { background: rgba(139,58,42,0.08); color: #8b3a2a; }
