/* TEORINET design tokens — source of truth for a unified theme.
   Include this file on every page before page-specific CSS:
   <link rel="stylesheet" href="{% static 'css/theme.css' %}">
   See THEME.md for usage notes.
*/

:root {
  /* Brand palette */
  --tk-primary: #4361ee;
  --tk-secondary: #f72585;
  --tk-accent: #7209b7;
  --tk-success: #06d6a0;
  --tk-danger: #ef476f;
  --tk-warning: #ffd166;
  --tk-cta-red: #dc3545;
  --tk-countdown: #d44942;
  /* Driving / AI chat accent */
  --tk-cyan: #22d3ee;

  --tk-dark: #0f172a;
  --tk-dark-hover: #1e293b;
  --tk-muted: #64748b;
  --tk-light: #f8fafc;
  --tk-white: #ffffff;
  --tk-dot: #e2e8f0;
  --tk-surface-tint: #eef2ff;
  --tk-chat-user: #e9ecef;
  --tk-footer-link: #e2e8f0;

  /* Logo mark (from static/img/logo/colored.svg) */
  --tk-brand-green: #50be97;
  --tk-brand-gold: #f0bf77;

  /* RGB channels for rgba() */
  --tk-primary-rgb: 67, 97, 238;
  --tk-accent-rgb: 114, 9, 183;
  --tk-dark-rgb: 15, 23, 42;
  --tk-success-rgb: 6, 214, 160;
  --tk-danger-rgb: 239, 71, 111;
  --tk-cyan-rgb: 34, 211, 238;

  /* Gradients */
  --tk-gradient: linear-gradient(45deg, var(--tk-primary), var(--tk-accent));
  --tk-gradient-hero: linear-gradient(135deg, var(--tk-primary), var(--tk-accent));
  --tk-gradient-accent: linear-gradient(135deg, var(--tk-accent), var(--tk-secondary));
  --tk-gradient-overlay: linear-gradient(
    135deg,
    rgba(var(--tk-primary-rgb), 0.82),
    rgba(var(--tk-accent-rgb), 0.82)
  );

  /* Type — rem scale, 16px base. Sidebar 14px, labels 12px. */
  --tk-font: "Poppins", "Noto Sans Arabic", sans-serif;
  --tk-fs-xs: 0.75rem;
  --tk-fs-sm: 0.8125rem;
  --tk-fs-md: 0.875rem;
  --tk-fs-base: 1rem;
  --tk-fs-lg: 1.125rem;
  --tk-fs-xl: 1.25rem;
  --tk-fs-2xl: clamp(1.5rem, 1rem + 1.4vw, 2rem);
  --tk-lh-body: 1.55;
  --tk-lh-ui: 1.35;
  --tk-tracking-label: 0.06em;

  --tk-radius: 1.25rem;
  --tk-radius-pill: 999px;
  --tk-shadow: 0 10px 28px rgba(var(--tk-dark-rgb), 0.08);
  --tk-shadow-lg: 0 16px 40px rgba(var(--tk-dark-rgb), 0.12);

  /* Navbar / LMS shell */
  --tk-navbar-bg: rgba(15, 23, 42, 0.94);
  --tk-sidebar: 260px;

  /* Semantic tokens (Phase 5) — use these in new CSS instead of palette names. */
  --tk-color-primary: var(--tk-primary);
  --tk-color-primary-hover: #3651d4;
  --tk-color-secondary: var(--tk-accent);
  --tk-color-success: #047857;
  --tk-color-success-bg: #ecfdf5;
  --tk-color-warning: #92400e;
  --tk-color-warning-bg: #fffbeb;
  --tk-color-danger: #b91c1c;
  --tk-color-danger-bg: #fef2f2;
  --tk-color-info: #1d4ed8;
  --tk-color-info-bg: #eff6ff;
  --tk-color-background: var(--tk-light);
  --tk-color-surface: var(--tk-white);
  --tk-color-surface-muted: #f1f5f9;
  --tk-color-border: var(--tk-dot);
  --tk-color-text: var(--tk-dark);
  --tk-color-text-muted: #475569;
  --tk-color-text-disabled: #94a3b8;
  --tk-focus-ring: 0 0 0 3px rgba(var(--tk-primary-rgb), 0.35);

  /* Spacing scale (4px base) */
  --tk-space-1: 0.25rem;
  --tk-space-2: 0.5rem;
  --tk-space-3: 0.75rem;
  --tk-space-4: 1rem;
  --tk-space-5: 1.5rem;
  --tk-space-6: 2rem;
  --tk-space-7: 3rem;
  --tk-radius-sm: 0.5rem;
  --tk-radius-md: 0.75rem;
}

/* ------------------------------------------------------------------ */
/* Access states (Phase 5). One visual language for every resource.    */
/* The state is decided server-side (authorization/access_states.py);  */
/* these classes only render it. Each badge carries an icon + text so  */
/* the state is never conveyed by colour alone.                        */
/* ------------------------------------------------------------------ */
.tk-state {
  display: inline-flex;
  align-items: center;
  gap: var(--tk-space-1);
  padding: 0.15rem 0.6rem;
  border-radius: var(--tk-radius-pill);
  border: 1px solid transparent;
  font-size: var(--tk-fs-xs);
  font-weight: 600;
  line-height: var(--tk-lh-ui);
  white-space: nowrap;
}
.tk-state i { font-size: 0.85em; }
.tk-state--available { color: var(--tk-color-success); background: var(--tk-color-success-bg); border-color: #a7f3d0; }
.tk-state--demo { color: var(--tk-color-info); background: var(--tk-color-info-bg); border-color: #bfdbfe; }
.tk-state--locked,
.tk-state--paid { color: var(--tk-color-text-muted); background: var(--tk-color-surface-muted); border-color: var(--tk-color-border); }
.tk-state--school { color: #6d28d9; background: #f5f3ff; border-color: #ddd6fe; }
.tk-state--completed { color: var(--tk-color-success); background: var(--tk-color-success-bg); border-color: #6ee7b7; }
.tk-state--progress { color: var(--tk-color-warning); background: var(--tk-color-warning-bg); border-color: #fde68a; }
.tk-state--soon { color: var(--tk-color-text-muted); background: var(--tk-color-surface); border-color: var(--tk-color-border); border-style: dashed; }

/* Locked item inside a list/grid: visible, readable, clearly not playable. */
.tk-is-locked { position: relative; }
.tk-is-locked .tk-locked-dim { color: var(--tk-color-text-muted); }

/* Locked content block (preview + lock + explanation + CTA). */
.tk-locked {
  display: flex;
  gap: var(--tk-space-4);
  align-items: flex-start;
  padding: var(--tk-space-4) var(--tk-space-5);
  margin: var(--tk-space-4) 0;
  border: 1px dashed var(--tk-color-border);
  border-radius: var(--tk-radius-md);
  background: var(--tk-color-surface-muted);
  color: var(--tk-color-text);
}
.tk-locked__icon {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--tk-color-surface);
  color: var(--tk-color-primary);
  border: 1px solid var(--tk-color-border);
}
.tk-locked__body { flex: 1 1 auto; min-width: 0; }
.tk-locked__title { font-size: var(--tk-fs-base); font-weight: 600; margin: 0 0 var(--tk-space-1); }
.tk-locked__text { font-size: var(--tk-fs-md); color: var(--tk-color-text-muted); margin: 0 0 var(--tk-space-3); }
.tk-locked__actions { display: flex; flex-wrap: wrap; gap: var(--tk-space-2); }
.tk-locked--compact { padding: var(--tk-space-3) var(--tk-space-4); margin: var(--tk-space-2) 0 0; }
.tk-locked--compact .tk-locked__icon { width: 2rem; height: 2rem; }
@media (max-width: 575.98px) {
  .tk-locked { flex-direction: column; padding: var(--tk-space-4); }
  .tk-locked__actions .btn { width: 100%; }
}

/* Upgrade CTA band: restrained, one per page. */
.tk-upgrade {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tk-space-4);
  align-items: center;
  justify-content: space-between;
  padding: var(--tk-space-4) var(--tk-space-5);
  margin-bottom: var(--tk-space-5);
  border-radius: var(--tk-radius-md);
  background: var(--tk-surface-tint);
  border: 1px solid rgba(var(--tk-primary-rgb), 0.18);
  color: var(--tk-color-text);
}
.tk-upgrade__title { font-weight: 600; margin: 0; font-size: var(--tk-fs-base); }
.tk-upgrade__text { margin: 0; font-size: var(--tk-fs-md); color: var(--tk-color-text-muted); }

/* Progress bar with an accessible text value next to it. */
.tk-progress { display: flex; align-items: center; gap: var(--tk-space-3); }
.tk-progress__bar { flex: 1 1 auto; height: 0.6rem; border-radius: var(--tk-radius-pill); background: var(--tk-color-surface-muted); overflow: hidden; }
.tk-progress__fill { height: 100%; background: var(--tk-gradient); border-radius: inherit; }
.tk-progress__value { font-size: var(--tk-fs-sm); font-weight: 600; min-width: 3ch; text-align: end; }

/* Stat tiles (demo dashboard, upgrade page). */
.tk-stat-grid { display: grid; gap: var(--tk-space-3); grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.tk-stat {
  padding: var(--tk-space-4);
  border-radius: var(--tk-radius-md);
  background: var(--tk-color-surface);
  border: 1px solid var(--tk-color-border);
}
.tk-stat__label { font-size: var(--tk-fs-xs); text-transform: uppercase; letter-spacing: var(--tk-tracking-label); color: var(--tk-color-text-muted); margin: 0 0 var(--tk-space-1); }
.tk-stat__value { font-size: var(--tk-fs-xl); font-weight: 700; margin: 0; }
.tk-stat__hint { font-size: var(--tk-fs-sm); color: var(--tk-color-text-muted); margin: var(--tk-space-1) 0 0; }

/* Empty state */
.tk-empty { text-align: center; padding: var(--tk-space-6) var(--tk-space-4); color: var(--tk-color-text-muted); }
.tk-empty i { font-size: 2rem; margin-bottom: var(--tk-space-3); color: var(--tk-color-text-disabled); }

/* Package cards on the upgrade page */
.tk-plan-grid { display: grid; gap: var(--tk-space-4); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.tk-plan {
  display: flex;
  flex-direction: column;
  gap: var(--tk-space-2);
  padding: var(--tk-space-5);
  border-radius: var(--tk-radius-md);
  background: var(--tk-color-surface);
  border: 1px solid var(--tk-color-border);
}
.tk-plan.is-featured { border-color: var(--tk-color-primary); box-shadow: var(--tk-shadow); }
.tk-plan__name { font-weight: 600; margin: 0; font-size: var(--tk-fs-lg); }
.tk-plan__price { font-size: var(--tk-fs-2xl); font-weight: 700; margin: 0; }
.tk-plan__meta { list-style: none; padding: 0; margin: 0 0 var(--tk-space-3); font-size: var(--tk-fs-md); color: var(--tk-color-text-muted); }
.tk-plan__meta li { display: flex; gap: var(--tk-space-2); align-items: baseline; }
.tk-plan .btn { margin-top: auto; }

/* Visible keyboard focus for shared components */
.tk-locked a:focus-visible,
.tk-upgrade a:focus-visible,
.tk-plan a:focus-visible,
.tk-toc a:focus-visible { outline: none; box-shadow: var(--tk-focus-ring); border-radius: var(--tk-radius-sm); }

.tk-font {
  font-family: var(--tk-font);
  color: var(--tk-dark);
}

.tk-gradient {
  background: var(--tk-gradient);
}

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

.tk-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.9rem;
  border-radius: var(--tk-radius-pill);
  background: var(--tk-white);
  color: var(--tk-dark);
  font-size: var(--tk-fs-sm);
  font-weight: 600;
  line-height: var(--tk-lh-ui);
  text-decoration: none;
  box-shadow: var(--tk-shadow);
}

.tk-chip.is-active,
.tk-chip--active {
  background: var(--tk-gradient);
  color: var(--tk-white);
}

.tk-crumb {
  --bs-breadcrumb-divider: ">";
}

.tk-input-sm {
  max-width: 12rem;
}

.tk-input-md {
  max-width: 20rem;
}

.tk-prose-narrow {
  max-width: 48rem;
}

.tk-figure-sm {
  max-width: 6.25rem;
}

.tk-figure-sm img {
  width: 100%;
  height: auto;
}

.tk-report-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.72rem;
  line-height: 1.2;
  color: inherit;
  opacity: 0.72;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.tk-report-link:hover,
.tk-report-link:focus-visible {
  opacity: 1;
}

.tk-footer .tk-report-link {
  color: var(--tk-footer-link);
}

.tk-report-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.tk-report-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.tk-report-modal[hidden] {
  display: none !important;
}

.tk-report-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(var(--tk-dark-rgb), 0.45);
}

.tk-report-modal__panel {
  position: relative;
  z-index: 1;
  width: min(22rem, calc(100% - 1.5rem));
  margin: 12vh auto 0;
  padding: 1.1rem 1.15rem 1rem;
  border-radius: 1rem;
  background: var(--tk-white);
  color: var(--tk-dark);
  box-shadow: var(--tk-shadow-lg);
  font-size: 0.875rem;
}

.tk-report-modal__x {
  position: absolute;
  top: 0.4rem;
  inset-inline-end: 0.5rem;
  border: 0;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--tk-muted);
  cursor: pointer;
}

.tk-report-modal__panel h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.tk-report-modal__lead {
  margin: 0 0 0.85rem;
  color: var(--tk-muted);
  font-size: 0.78rem;
}

.tk-report-label {
  display: block;
  margin: 0.55rem 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tk-report-modal__panel select,
.tk-report-modal__panel input,
.tk-report-modal__panel textarea {
  width: 100%;
  border: 1px solid var(--tk-dot);
  border-radius: 0.55rem;
  padding: 0.4rem 0.55rem;
  font: inherit;
}

.tk-report-status {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: var(--tk-success);
}

.tk-report-status.is-error {
  color: var(--tk-danger);
}

.tk-report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.tk-report-cancel,
.tk-report-send {
  border: 0;
  border-radius: var(--tk-radius-pill);
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.tk-report-cancel {
  background: transparent;
  color: var(--tk-muted);
}

.tk-report-send {
  background: var(--tk-dark);
  color: var(--tk-white);
}

body.tk-report-open {
  overflow: hidden;
}

html[dir="rtl"] .tk-report-actions {
  justify-content: flex-start;
}

.tk-reviews {
  background: var(--tk-light);
  padding: 2rem 0;
}

.tk-reviews .tk-band-head {
  max-width: none;
  margin-bottom: 0.75rem;
}

.tk-reviews .tk-band-head h2 {
  font-size: var(--tk-fs-2xl);
  font-weight: 750;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--tk-dark);
}

.tk-reviews .tk-band-head--split {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.85rem 1.25rem;
  flex-wrap: wrap;
}

.tk-reviews .tk-kicker {
  color: var(--tk-primary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.tk-score {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
}

.tk-score strong {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--tk-dark);
}

.tk-score__stars {
  color: var(--tk-brand-gold);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.tk-score__meta {
  color: var(--tk-muted);
  font-size: var(--tk-fs-sm);
}

.tk-reviews__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.55rem;
}

.tk-reviews .tk-reviews__nav {
  flex-shrink: 0;
}

.tk-reviews__hint {
  margin: 0;
  color: var(--tk-muted);
  font-size: var(--tk-fs-sm);
}

.tk-reviews__nav {
  display: flex;
  gap: 0.35rem;
}

.tk-rail-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid rgba(var(--tk-dark-rgb), 0.12);
  background: var(--tk-white);
  color: var(--tk-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tk-rail-btn:hover {
  border-color: var(--tk-primary);
  color: var(--tk-primary);
}

.tk-quote-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(16.5rem, 20.5rem);
  gap: 0.55rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}

.tk-quote {
  scroll-snap-align: start;
  background: var(--tk-white);
  border: 1px solid rgba(var(--tk-dark-rgb), 0.08);
  border-radius: 0.85rem;
  padding: 0.7rem 0.8rem 0.75rem;
}

.tk-quote__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.tk-quote__top > div {
  flex: 1;
  min-width: 0;
}

.tk-quote__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--tk-primary-rgb), 0.12);
  color: var(--tk-primary);
  font-size: 0.65rem;
  font-weight: 700;
}

.tk-quote__top strong {
  display: block;
  font-size: var(--tk-fs-sm);
  color: var(--tk-dark);
  line-height: 1.2;
  white-space: nowrap;
}

.tk-quote__top span {
  display: block;
  font-size: var(--tk-fs-xs);
  color: var(--tk-muted);
}

.tk-quote__stars {
  color: var(--tk-brand-gold);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  white-space: nowrap;
}

.tk-quote p {
  margin: 0;
  color: var(--tk-dark);
  font-size: var(--tk-fs-sm);
  line-height: 1.45;
  overflow-wrap: break-word;
}

.tk-reviews__more {
  margin: 0.65rem 0 0;
  text-align: center;
}

.tk-reviews__more a {
  color: var(--tk-primary);
  font-size: var(--tk-fs-sm);
  font-weight: 650;
  text-decoration: none;
}

html[dir="rtl"] .tk-rail-btn i {
  transform: scaleX(-1);
}

