/* ============================================================
   Caltrix App CSS — Design-Tokens + Komponenten
   Quelle der Tokens: mockup/styles/tokens.css
   Quelle der Komponenten: mockup/styles/shared.css
   ============================================================ */

/* ── Design Tokens ── */
:root {
  --primary:      #1f628e;
  --primary-mid:  #2a7aad;
  --primary-dark: #195170;
  --accent:       #e09d71;
  --accent-dark:  #c07a45;
  --green:        #7ad180;
  --cream:        #ecdcc8;
  --danger:       #e05353;
  --warning:      #f59e0b;

  --bg:      #fdfcfb;
  --surface: #f8f4ef;
  --white:   #ffffff;

  --text:    #1a2e3b;
  --muted:   #6c869e;
  --border:  #e4d9ce;

  --fh: 'DM Sans', system-ui, sans-serif;
  --fb: 'Lora', Georgia, serif;

  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.09), 0 1px 4px rgba(0,0,0,0.05);
}

/* Tenant-Branding überschreibt --primary */
/* (wird per Inline-Style auf <body> gesetzt) */

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--fh);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
img, svg { display: block; }

/* ── Site Header ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 56px;
  flex-shrink: 0;
}
.site-header__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}

/* ── Logo ── */
.site-logo {
  display: flex; align-items: center; gap: 9px;
  color: var(--primary);
  font-weight: 800;
  font-size: 1.0625rem;
  text-decoration: none;
  letter-spacing: -0.025em;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Top Navigation ── */
.topnav {
  display: flex; align-items: center; gap: 2px;
  flex: 1;
}
.topnav__link {
  font-size: 0.875rem; font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.topnav__link:hover { color: var(--text); background: var(--surface); }
.topnav__link.active { color: var(--primary); font-weight: 600; background: #e6f0f8; }

/* ── Header Actions ── */
.header-actions {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: none; background: none;
  color: var(--muted);
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.notif-badge {
  position: absolute; top: 5px; right: 5px;
  background: var(--danger); color: white;
  font-size: 9px; font-weight: 700; line-height: 1;
  width: 15px; height: 15px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white);
  font-family: var(--fh);
}
.user-avatar-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  padding: 4px 8px 4px 4px;
  border-radius: var(--r-sm);
  transition: background 0.15s;
}
.user-avatar-btn:hover { background: var(--surface); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.6875rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.admin-tag {
  font-size: 0.6875rem; font-weight: 700;
  background: #e6f0f8; color: var(--primary);
  padding: 2px 8px; border-radius: var(--r-full);
  letter-spacing: 0.025em;
  border: 1px solid #c3ddf0;
}

/* ── Sub Navigation (Admin) ── */
.sub-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
}
.sub-nav__inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  gap: 0;
}
.sub-nav__link {
  font-size: 0.875rem; font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 12px 16px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.sub-nav__link:hover { color: var(--text); }
.sub-nav__link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Main Content ── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
  flex: 1;
  width: 100%;
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8125rem; color: var(--muted);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb__sep { color: var(--border); font-size: 0.75rem; }
.breadcrumb__current { color: var(--text); font-weight: 500; }

/* ── Cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ── Pills / Tags ── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.pill-primary { background: #e6f0f8; color: var(--primary); }
.pill-accent  { background: #fef0e5; color: var(--accent-dark); border: 1px solid #f8d8b8; }
.pill-danger  { background: #fdf2f2; color: var(--danger); border: 1px solid #f8c5c5; }
.pill-success { background: #f0faf0; color: #2d8a37; }
.pill-muted   { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.pill-expert  { background: #f5f0ff; color: #6d28d9; }

/* ── Level Tags ── */
.level {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 0.6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.level-basic    { background: #e6f0f8; color: #1a5a8a; }
.level-advanced { background: #fef3e8; color: #9a4a0f; }
.level-expert   { background: #f5f0ff; color: #6d28d9; }

/* ── Progress Bar ── */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px;
  border-radius: var(--r-sm);
  font-family: var(--fh);
  font-size: 0.875rem; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: #e6f0f8; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: #f8c5c5; }
.btn-disabled { background: var(--surface) !important; color: var(--muted) !important; border-color: var(--border) !important; cursor: not-allowed !important; }
.btn-sm { padding: 5px 12px; font-size: 0.8125rem; }
.btn-xs { padding: 3px 10px; font-size: 0.75rem; }

/* ── Status Dots ── */
.status-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 14px;
}
.status-done    { background: var(--primary); color: white; }
.status-active  { background: #e6f0f8; color: var(--primary); border: 2.5px solid var(--primary); }
.status-pending { background: var(--surface); color: var(--muted); border: 2px solid var(--border); }

/* ── Module Cards ── */
.module-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.module-card:hover { box-shadow: var(--shadow-md); }
.module-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,98,142,0.08), var(--shadow-sm); }
.module-card__body { flex: 1; min-width: 0; }
.module-card__num { font-size: 0.6875rem; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; margin-bottom: 2px; }
.module-card__title { font-size: 0.9375rem; font-weight: 600; color: var(--text); margin-bottom: 5px; line-height: 1.3; }
.module-card__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.8125rem; color: var(--muted); }
.module-card__actions { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.module-card__prereq { display: flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 2px 9px; border-radius: var(--r-full); margin-top: 6px; width: fit-content; }

/* ── Source Icons ── */
.src-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  font-size: 9px; font-weight: 800; font-family: var(--fh);
}
.src-yt   { background: #ff0000; }
.src-gh   { background: #24292e; }
.src-cf   { background: #0052cc; border-radius: 4px; }
.src-sp   { background: #038387; border-radius: 4px; }
.src-ps   { background: #f15b2a; border-radius: 4px; }
.src-pdf  { background: var(--surface); border: 1px solid var(--border); color: var(--muted); border-radius: 4px; }
.src-wiki { background: #e8e8e8; color: #555; border-radius: 4px; }

/* ── Avatar ── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}

/* ── Stat Tiles ── */
.stat-tile {
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  text-align: center;
}
.stat-tile__value { font-size: 1.625rem; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 4px; }
.stat-tile__label { font-size: 0.75rem; color: var(--muted); }

/* ── Site Footer ── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 18px 32px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: auto;
}
.site-footer a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.site-footer a:hover { color: var(--primary); }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); }

/* ── Toggle Button Group ── */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.view-toggle__btn {
  padding: 6px 14px;
  background: none; border: none;
  font-family: var(--fh); font-size: 0.8125rem; font-weight: 500;
  color: var(--muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center; gap: 5px;
}
.view-toggle__btn.active { background: var(--primary); color: white; }
.view-toggle__btn:not(.active):hover { background: var(--surface); }
.view-toggle__btn:not(:last-child) { border-right: 1px solid var(--border); }

/* ── Drag Handle ── */
.drag-handle { color: var(--border); cursor: grab; flex-shrink: 0; }
.drag-handle:hover { color: var(--muted); }

/* ── Three-dot Menu ── */
.menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border: none; background: none;
  border-radius: var(--r-sm); color: var(--muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--surface); color: var(--text); }

/* ── Insert Zone (Editor) ── */
.insert-zone {
  height: 8px;
  display: flex; align-items: center;
  position: relative;
  margin: 2px 0;
}
.insert-zone__line {
  width: 100%; height: 2px;
  border-radius: 1px;
  background: transparent;
  border: 1px dashed transparent;
  transition: all 0.15s;
}
.insert-zone:hover .insert-zone__line,
.insert-zone.hovered .insert-zone__line {
  border-color: var(--primary);
  background: rgba(31,98,142,0.06);
  height: 28px;
}
.insert-zone__label {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 0.75rem; font-weight: 600; color: var(--primary);
  opacity: 0; white-space: nowrap;
  transition: opacity 0.15s;
  pointer-events: none;
}
.insert-zone.hovered .insert-zone__label { opacity: 1; }

/* ── Validation Items ── */
.valid-item { display: flex; align-items: flex-start; gap: 10px; font-size: 0.875rem; padding: 6px 0; }
.valid-item__icon { flex-shrink: 0; margin-top: 1px; }
.valid-ok   { color: #2d8a37; }
.valid-warn { color: #9a4a0f; }

/* ── Data Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); padding: 10px 14px;
  text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px; font-size: 0.875rem; color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface); }
.data-table td.link { color: var(--primary); font-weight: 600; cursor: pointer; }
.data-table td.link:hover { text-decoration: underline; }

/* ── Activity Feed ── */
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.activity-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }
.activity-text { font-size: 0.875rem; color: var(--text); line-height: 1.4; }
.activity-time { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* ── Search Input ── */
.search-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-family: var(--fh); font-size: 0.875rem; color: var(--muted);
  width: 220px;
}
.search-input svg { flex-shrink: 0; }

/* ── Mini Progress Bar ── */
.mini-bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 60px; }
.mini-bar__fill { height: 100%; background: var(--primary); border-radius: 3px; }

/* ── Auth Layout ── */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 32px 16px;
}
.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--primary);
  font-weight: 800; font-size: 1.125rem;
  letter-spacing: -0.025em;
  margin-bottom: 28px;
  text-decoration: none;
}
.auth-title {
  font-size: 1.25rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  text-align: center;
}
.auth-sub {
  font-size: 0.875rem; color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
}

/* ── Form Elements ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.875rem; font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--fh); font-size: 0.9375rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31,98,142,0.1);
}
.form-input.has-error { border-color: var(--danger); }
.form-error {
  font-size: 0.8125rem; color: var(--danger);
  margin-top: 5px;
}
.form-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0;
  color: var(--muted); font-size: 0.8125rem;
}
.form-divider::before, .form-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}
.btn-block { width: 100%; }

/* ── Alert / Flash Messages ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.alert-danger  { background: #fdf2f2; color: var(--danger); border: 1px solid #f8c5c5; }
.alert-success { background: #f0faf0; color: #2d8a37; border: 1px solid #b4e6b8; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .site-header__inner { padding: 0 16px; gap: 16px; }
  .topnav { display: none; }
  .main-content { padding: 20px 16px; }
  .auth-card { padding: 28px 20px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .site-header__inner { padding: 0 24px; }
  .main-content { padding: 24px; }
}
