/* =============================================================================
   Tussenuur.info — Central Theme System (v4.0 — rebuilt)
   Single source of truth for ALL colors, gradients, spacing, typography.
   No hardcoded colors anywhere in markup or component CSS.
   ============================================================================= */

/* ---------- CSS Custom Properties (Dark Mode Default) ---------- */
:root,
.theme-dark {
  /* ── Page Background ── */
  --page-bg: #0a0a1a;
  --page-gradient: linear-gradient(135deg, #0a0a1a 0%, #0f0f2e 30%, #1a1040 60%, #0d0d2b 100%);

  /* ── Card / Surface ── */
  --surface-bg: rgba(255, 255, 255, 0.03);
  --surface-border: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --surface-raised: rgba(255, 255, 255, 0.05);

  /* ── Input ── */
  --input-bg: rgba(0, 0, 0, 0.35);
  --input-border: rgba(255, 255, 255, 0.08);
  --input-focus-border: rgba(255, 255, 255, 0.18);
  --input-placeholder: rgba(255, 255, 255, 0.2);
  --input-text: #ffffff;

  /* ── Text ── */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-tertiary: rgba(255, 255, 255, 0.35);
  --text-muted: rgba(255, 255, 255, 0.2);
  --text-inverse: #0d0d0d;

  /* ── Accent / Brand ── */
  --accent-primary: #818cf8;
  --accent-primary-hover: #a5b4fc;
  --accent-secondary: #6366f1;
  --accent-secondary-hover: #818cf8;
  --accent-tertiary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --brand-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  /* ── Semantic ── */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-border: rgba(16, 185, 129, 0.25);
  --warning: #a78bfa;
  --warning-bg: rgba(167, 139, 250, 0.1);
  --warning-border: rgba(167, 139, 250, 0.25);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.25);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  --info-border: rgba(59, 130, 246, 0.25);

  /* ── Status Colors ── */
  --status-tussenuur: #a78bfa;
  --status-tussenuur-bg: rgba(167, 139, 250, 0.12);
  --status-pauze: #10b981;
  --status-pauze-bg: rgba(16, 185, 129, 0.12);
  --status-vrij: #6366f1;
  --status-vrij-bg: rgba(99, 102, 241, 0.12);
  --status-les: rgba(255, 255, 255, 0.15);
  --status-les-bg: rgba(255, 255, 255, 0.04);

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);

  /* ── Backdrop / Overlay ── */
  --backdrop-bg: rgba(0, 0, 0, 0.7);
  --backdrop-blur: blur(8px);

  /* ── Radii ── */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* ── Spacing Scale ── */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* ── Typography ── */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  /* ── Transitions ── */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* ── Z-index scale ── */
  --z-dropdown: 50;
  --z-modal-backdrop: 60;
  --z-modal: 65;
  --z-toast: 70;
  --z-tooltip: 80;
}

/* ---------- Light Mode Overrides ---------- */
.theme-light {
  --page-bg: #f3f4f6;
  --page-gradient: linear-gradient(135deg, #eef2ff 0%, #faf5ff 30%, #ede9fe 60%, #e0e7ff 100%);

  --surface-bg: #ffffff;
  --surface-border: rgba(0, 0, 0, 0.08);
  --surface-hover: rgba(0, 0, 0, 0.04);
  --surface-raised: rgba(0, 0, 0, 0.02);

  --input-bg: #ffffff;
  --input-border: rgba(0, 0, 0, 0.12);
  --input-focus-border: rgba(0, 0, 0, 0.22);
  --input-placeholder: rgba(0, 0, 0, 0.3);
  --input-text: #111827;

  --text-primary: #111827;
  --text-secondary: rgba(0, 0, 0, 0.6);
  --text-tertiary: rgba(0, 0, 0, 0.4);
  --text-muted: rgba(0, 0, 0, 0.2);
  --text-inverse: #ffffff;

  --status-les: rgba(0, 0, 0, 0.08);
  --status-les-bg: rgba(0, 0, 0, 0.02);

  --backdrop-bg: rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
}

/* ---------- Responsive overrides (auto-detected, no class needed) ---------- */
@media (prefers-color-scheme: light) {
  :root:not(.theme-dark):not(.theme-light) {
    --page-bg: #f3f4f6;
    --page-gradient: linear-gradient(135deg, #eef2ff 0%, #faf5ff 30%, #ede9fe 60%, #e0e7ff 100%);
    --surface-bg: #ffffff;
    --surface-border: rgba(0, 0, 0, 0.08);
    --surface-hover: rgba(0, 0, 0, 0.04);
    --surface-raised: rgba(0, 0, 0, 0.02);
    --input-bg: #ffffff;
    --input-border: rgba(0, 0, 0, 0.12);
    --input-focus-border: rgba(0, 0, 0, 0.22);
    --input-placeholder: rgba(0, 0, 0, 0.3);
    --input-text: #111827;
    --text-primary: #111827;
    --text-secondary: rgba(0, 0, 0, 0.6);
    --text-tertiary: rgba(0, 0, 0, 0.4);
    --text-muted: rgba(0, 0, 0, 0.2);
    --text-inverse: #ffffff;
    --status-les: rgba(0, 0, 0, 0.08);
    --status-les-bg: rgba(0, 0, 0, 0.02);
    --backdrop-bg: rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
  }
}

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

html {
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
  background: var(--page-bg);
}

body {
  min-height: 100dvh;
  background: var(--page-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
}

/* ---------- Utility Classes ---------- */
.surface {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
}

.surface-raised {
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
}

.input-field {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--input-text);
  font-size: var(--text-sm);
  font-family: var(--font-family);
  transition: border-color var(--transition-fast);
}

.input-field::placeholder {
  color: var(--input-placeholder);
}

.input-field:focus {
  outline: none;
  border-color: var(--input-focus-border);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 20px;
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 20px;
  background: var(--brand-gradient);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn-brand:hover {
  opacity: 0.9;
}

.btn-brand:active {
  transform: scale(0.97);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn-danger:hover {
  opacity: 0.8;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
}

.badge-tussenuur {
  background: var(--status-tussenuur-bg);
  color: var(--status-tussenuur);
}

.badge-pauze {
  background: var(--status-pauze-bg);
  color: var(--status-pauze);
}

.badge-vrij {
  background: var(--status-vrij-bg);
  color: var(--status-vrij);
}

.badge-les {
  background: var(--status-les-bg);
  color: var(--text-tertiary);
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-brand {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Modal System ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: var(--backdrop-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

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

.modal-card {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 28rem;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: var(--z-modal);
}

.modal-card-wide {
  max-width: 36rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  border-radius: var(--radius-full);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.modal-body {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
}

.modal-footer-end {
  justify-content: flex-end;
}

.modal-footer-between {
  justify-content: space-between;
}

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface-bg);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  max-width: 90vw;
  text-align: center;
  pointer-events: auto;
}

.toast.toast-error {
  border-color: var(--danger-border);
  color: var(--danger);
}

.toast.toast-success {
  border-color: var(--success-border);
  color: var(--success);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Avatar ---------- */
.avatar-circle {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 800;
  color: #ffffff;
  overflow: hidden;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 40px;
  height: 40px;
  font-size: var(--text-sm);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ---------- Focus Visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-primary);
  color: var(--text-inverse);
}