/* =========================================================================
   design-tokens.css
   Shared design-system foundation for the visual redesign.
   Plain CSS only (no Tailwind dependency) - safe to load on every page,
   including tinyfilemanager.php / imagefilemanager.php where the Tailwind
   CDN script is intentionally disabled.

   Source of truth: admin_template.html + student_template.html mockups.
   RTL Hebrew, font 'Assistant'.

   Sections:
     1. CSS custom properties (colors, typography, radius, shadow, spacing)
     2. Base helpers (page backgrounds)
     3. Component classes: card, buttons, badges, grid-table, form inputs
     4. Tab-nav component (used by layout/tabnav.php)
   ========================================================================= */

:root {
  /* ---- Colors: surfaces & text ---- */
  --color-bg: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --border: #e5e7eb;

  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  /* ---- Colors: brand & semantic ---- */
  --brand-blue: #2563eb;
  --brand-blue-hover: #1d4ed8;
  --brand-blue-active: #1e40af;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;

  --success: #16a34a;
  --success-light: #22c55e;
  --success-50: #f0fdf4;
  --success-100: #dcfce7;

  --destructive: #dc2626;
  --red-50: #fef2f2;
  --red-100: #fee2e2;

  --accent-orange: #f97316; /* student app only */
  --gray-300: #d1d5db;

  /* ---- Backgrounds (page-level) ---- */
  --bg-admin: radial-gradient(circle at top, #f8fafc 0%, #eef2f7 100%);
  --bg-student: linear-gradient(180deg, #f6f9ff 0%, #eef3fb 100%);
  --bg-student-header: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);

  /* ---- Typography ---- */
  --font-family: 'Assistant', system-ui, sans-serif;
  --fs-h1: 24px;
  --fs-h2: 22px;
  --fs-card-title: 16px;
  --fs-body: 14px;
  --fs-caption: 12px;
  --fw-heading: 700;
  --fw-semibold: 600;
  --fw-regular: 400;

  /* ---- Radius ---- */
  --radius-card: 16px;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* ---- Shadows ---- */
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 0 0 1px var(--border);
  --shadow-card-blue: 0 1px 2px rgba(16, 24, 40, .04), 0 0 0 1px var(--blue-100);
  --shadow-cta: 0 16px 34px -10px rgba(37, 99, 235, .55);
  --focus-ring: 0 0 0 2px var(--blue-100);

  /* ---- Spacing scale ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
}

/* =========================================================================
   2. Base page-level helpers
   ========================================================================= */

.page-bg-admin {
  background: var(--bg-admin);
  min-height: 100vh;
}

.page-bg-student {
  background: var(--bg-student);
  min-height: 100vh;
}

.font-assistant {
  font-family: var(--font-family);
}

/* =========================================================================
   3. Components
   ========================================================================= */

/* ---- Card ---- */
.card {
  background: var(--surface-1);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 28px;
  font-family: var(--font-family);
}

.card-title {
  font-size: var(--fs-card-title);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--space-2) 0;
}

.section-title {
  font-size: var(--fs-h2);
  font-weight: var(--fw-heading);
  color: var(--text-primary);
  margin: 0 0 var(--space-4) 0;
}

.page-title {
  font-size: var(--fs-h1);
  font-weight: var(--fw-heading);
  color: var(--text-primary);
  margin: 0 0 var(--space-2) 0;
  font-family: var(--font-family);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-family);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s ease, box-shadow .15s ease, border-color .15s ease, color .15s ease;
}

.btn-primary {
  background: var(--brand-blue);
  color: #ffffff;
  box-shadow: var(--shadow-cta);
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--brand-blue-hover);
  color: #ffffff;
}

.btn-ghost {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: var(--surface-2);
  color: var(--text-primary);
}

.btn-destructive {
  background: var(--red-50);
  color: var(--destructive);
  border-color: transparent;
}
.btn-destructive:hover,
.btn-destructive:focus-visible {
  background: var(--red-100);
  color: var(--destructive);
}

.btn:disabled,
.btn[disabled] {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---- Status badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-family);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  line-height: 1.6;
  white-space: nowrap;
}

.badge-active {
  color: var(--success);
}
.badge-inactive {
  color: var(--text-muted);
}
.badge-pending {
  color: var(--accent-orange);
}
.badge-danger {
  color: var(--destructive);
}
.badge-info {
  color: var(--brand-blue);
}

/* ---- Grid-based "table" ----
   Usage:
     <div class="grid-table" style="--grid-table-cols: 2fr 1fr 1fr 1fr;">
       <div class="grid-table-row grid-table-header"> ...cells... </div>
       <div class="grid-table-row"> ...cells... </div>
     </div>
*/
.grid-table {
  display: flex;
  flex-direction: column;
  width: 100%;
  font-family: var(--font-family);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.grid-table-row {
  display: grid;
  grid-template-columns: var(--grid-table-cols, 1fr 1fr 1fr 1fr);
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-body);
  color: var(--text-secondary);
}

.grid-table-row:last-child {
  border-bottom: none;
}

.grid-table-header {
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  text-transform: none;
}

.grid-table-row.is-hoverable:hover,
.grid-table-row.grid-table-body:hover {
  background: rgba(239, 246, 255, .3); /* blue-50 @ ~30% */
}

.grid-table-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Forms ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-family: var(--font-family);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}

.form-input {
  font-family: var(--font-family);
  font-size: var(--fs-body);
  color: var(--text-primary);
  background: #ffffff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.form-input::placeholder {
  color: var(--text-faint);
}

.form-input:focus,
.form-input:focus-visible {
  border-color: var(--blue-500);
  box-shadow: var(--focus-ring);
}

.form-input:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea.form-input {
  resize: vertical;
  min-height: 90px;
}

/* =========================================================================
   4. App bar + tab navigation (used by layout/header.php + layout/tabnav.php)

   The app bar is fixed to the top of every admin page and is 110px tall
   (64px brand row + 46px tab row). Admin pages reserve >= 120px of top
   padding for it - keep those two numbers in sync when changing heights.
   ========================================================================= */

.appbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-family);
}

.appbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: 64px;
  padding: 0 var(--space-6);
}

.appbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.appbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background: var(--brand-blue);
  color: #fff;
  flex: none;
}

.appbar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.appbar-brand-title {
  font-size: 15px;
  font-weight: var(--fw-heading);
  color: var(--text-primary);
}

.appbar-brand-sub {
  font-size: 11px;
  color: var(--text-faint);
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.appbar-link {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  color: var(--brand-blue);
  text-decoration: none;
  padding: 0 var(--space-2);
  white-space: nowrap;
}

.appbar-link:hover {
  color: var(--brand-blue-hover);
}

.appbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-1);
}

.appbar-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--blue-100);
  color: #1d4ed8;
  font-size: 13px;
  font-weight: var(--fw-heading);
  flex: none;
}

.appbar-username {
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.appbar-iconbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-faint);
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.appbar-iconbtn:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}

.appbar-iconbtn-danger:hover {
  background: var(--red-50);
  color: var(--destructive);
}

@media (max-width: 640px) {
  .appbar-username,
  .appbar-link { display: none; }
  .appbar-row { padding: 0 var(--space-4); }
}

/* ---- Student top-bar actions -------------------------------------------
   The student portal keeps the legacy blue bar from layout/header.php, but
   the user/logout cluster follows the mockup: a translucent avatar pill
   plus an icon-only logout button with an accessible tooltip. */

.st-appbar-actions {
  position: fixed;
  top: 0;
  left: 14px;
  height: 3.5rem; /* matches the student top bar in layout/header.php */
  z-index: 60;    /* the bar itself sits at z-index 50 */
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-family);
}

.st-appbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}

.st-appbar-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: #1d4ed8;
  font-size: var(--fs-caption);
  font-weight: var(--fw-heading);
  flex: none;
}

.st-appbar-username {
  font-size: 13px;
  font-weight: var(--fw-semibold);
  color: #ffffff;
  white-space: nowrap;
  padding-inline-end: var(--space-1);
}

.st-appbar-iconbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--blue-100);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.st-appbar-iconbtn:hover {
  background: rgba(255, 255, 255, .18);
  color: #ffffff;
}

.st-appbar-iconbtn:focus-visible {
  background: rgba(255, 255, 255, .18);
  color: #ffffff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .7);
}

@media (max-width: 640px) {
  .st-appbar-username { display: none; }
  .st-appbar-actions { left: 8px; }
}

.tabnav-wrap {
  background: var(--surface-1);
  width: 100%;
  font-family: var(--font-family);
}

.tabnav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-4) var(--space-2);
  overflow-x: auto;
  list-style: none;
  scrollbar-width: thin;
}

.tabnav-item {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  transition: color .15s ease, background-color .15s ease;
}

.tabnav-item:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

.tabnav-item.is-active {
  color: var(--brand-blue);
  background: var(--blue-50);
  font-weight: var(--fw-heading);
}


/* =========================================================================
   5. Public top bar - the two area entry points (layout/header.php)
   Shown to signed-out visitors. Replaces the single hard-coded yellow
   "אזור תלמידים" button that used to sit there on its own.
   ========================================================================= */

.hdr-areas {
  position: absolute;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-family);
}

.hdr-area-btn {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-caption);
  font-weight: var(--fw-heading);
  text-decoration: none;
  color: #fff;
  transition: background-color .15s ease;
}

.hdr-area-btn:hover,
.hdr-area-btn:focus-visible {
  text-decoration: none;
  color: #fff;
}

/* Translucent on the blue bar, so neither entry point shouts over the other. */
.hdr-area-btn--mentor  { background: rgba(255, 255, 255, .18); }
.hdr-area-btn--mentor:hover,
.hdr-area-btn--mentor:focus-visible { background: rgba(255, 255, 255, .3); }

.hdr-area-btn--student { background: var(--accent-orange); }
.hdr-area-btn--student:hover,
.hdr-area-btn--student:focus-visible { background: #ea580c; }
