/* Kiosk — styled to match the Tuwaiq Academy (EduQuest) portal exactly */

:root {
  /* === Portal's exact design tokens === */
  --primary:        #4f29b7;
  --primary-dark:   #3d1f8f;
  --primary-light:  #c2adff;
  --primary-subtle: #f3f0ff;
  --primary-bg:     rgba(79, 41, 183, .1);

  /* Background / surface */
  --bg:      #F5F6FA;
  --bg-alt:  #f0f1f7;
  --surface: #FFFFFF;

  /* Text */
  --text:    #2f2f3b;
  --muted:   #6c757d;
  --faint:   #9aa0ac;

  /* Borders & shadows */
  --border:      rgba(0, 0, 0, .07);
  --border-hard: #dee2e6;
  --shadow-sm:   0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md:   0 2px 12px rgba(0, 0, 0, .08);
  --shadow-lg:   0 8px 25px rgba(0, 0, 0, .12);

  /* Semantic */
  --green:    #12a454;
  --green-bg: #d1fae5;
  --red:      #dc3545;
  --red-bg:   #ffe4e6;
  --amber:    #b45309;
  --amber-bg: #fef3c7;

  /* Subject palette — 8 pastel pairs (bg / text) matching portal card colors */
  --sc-0-bg: #ede9fe; --sc-0-tx: #5b21b6; --sc-0-bd: #c4b5fd;
  --sc-1-bg: #dbeafe; --sc-1-tx: #1e40af; --sc-1-bd: #93c5fd;
  --sc-2-bg: #d1fae5; --sc-2-tx: #065f46; --sc-2-bd: #6ee7b7;
  --sc-3-bg: #fce7f3; --sc-3-tx: #9d174d; --sc-3-bd: #f9a8d4;
  --sc-4-bg: #fef3c7; --sc-4-tx: #92400e; --sc-4-bd: #fcd34d;
  --sc-5-bg: #ffe4e6; --sc-5-tx: #9f1239; --sc-5-bd: #fca5a5;
  --sc-6-bg: #ecfdf5; --sc-6-tx: #047857; --sc-6-bd: #a7f3d0;
  --sc-7-bg: #fff7ed; --sc-7-tx: #9a3412; --sc-7-bd: #fdba74;

  /* Banner gradient — matches the real portal's lighter blue-purple */
  --banner-grad: linear-gradient(120deg, #6d83f2 0%, #7c5fea 40%, #8b5cf6 100%);

  --font: "IBM Plex Sans Arabic", "IBM Plex Sans", "Segoe UI", Tahoma, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  direction: rtl;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* ─────────────── Sidebar ─────────────── */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-inline-start: 1px solid var(--border-hard);
  overflow: hidden;
}

/* Logo block */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  flex: none; width: 40px; height: 40px;
  background: var(--primary); border-radius: 10px;
  display: grid; place-items: center;
}
.brand-icon svg { width: 22px; height: 22px; fill: #fff; }
.brand-text strong { display: block; font-size: 1rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.brand-text span   { font-size: .75rem; color: var(--muted); }

/* School / class info */
.class-badge {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--primary-subtle);
}
.class-letter {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--primary); color: #fff;
  font-size: 1.4rem; font-weight: 700;
}
.class-name { font-weight: 600; font-size: .92rem; }
.class-school { font-size: .78rem; color: var(--muted); }

/* Nav tabs */
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; flex: 1; }
.tab {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted); text-align: start;
  font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab svg { width: 20px; height: 20px; flex: none; stroke: currentColor; }
.tab-label { flex: 1; }
.tab:hover { background: var(--bg); color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 600;
}
.tab[aria-selected="true"]::before {
  content: "";
  position: absolute;
  inset-inline-start: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
  display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700;
}

/* Status line */
.status {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 12px 18px 16px;
  color: var(--faint); font-size: .75rem; line-height: 1.5;
  border-top: 1px solid var(--border);
}
.dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok    { background: var(--green); }
.dot.error { background: var(--red); }

/* ─────────────── Main area ─────────────── */
.main {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 22px 20px 20px;
  min-height: 0; min-width: 0;
  overflow: hidden;
}

/* Hero banner — matches portal's page header */
.banner {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 22px 28px;
  border-radius: 18px;
  background: var(--banner-grad);
  color: #fff;
  flex-shrink: 0;
}
/* Subtle light-blob decoration (portal-style) */
.banner::after {
  content: ""; position: absolute;
  width: 320px; height: 320px; border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  left: -80px; top: -100px;
  pointer-events: none;
}
.banner-text { position: relative; z-index: 1; }
.banner h1 { font-size: 1.55rem; font-weight: 700; line-height: 1.3; }
.banner p  { opacity: .85; font-size: .92rem; margin-top: 3px; }

.clock {
  position: relative; z-index: 1;
  min-width: 210px;
  padding: 14px 20px;
  text-align: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
}
.clock-time {
  display: flex; align-items: center; justify-content: center; gap: 8px; direction: ltr;
}
.clock-time span { font-size: 2.2rem; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.clock-time small {
  padding: 2px 7px; border-radius: 6px;
  background: rgba(255, 255, 255, .2);
  font-size: .8rem; font-weight: 600;
}
.clock-date { font-size: .8rem; opacity: .88; margin-top: 2px; }

/* ─────────────── Panel (white card) ─────────────── */
.panel {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title { display: flex; align-items: center; gap: 12px; }
.panel-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--primary-subtle); color: var(--primary);
}
.panel-icon svg { width: 20px; height: 20px; stroke: currentColor; }
.panel-head h2 { font-size: 1.05rem; font-weight: 700; }
.panel-head p  { font-size: .8rem; color: var(--muted); margin-top: 1px; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 12px; scrollbar-width: thin; scrollbar-color: var(--border-hard) transparent; }
.fade-in { animation: fade 200ms ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* Segmented control (filter bar) */
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border-hard);
}
.segmented button {
  min-height: 34px; min-width: 56px; padding: 0 14px;
  border-radius: 8px; color: var(--muted); font-size: .85rem; font-weight: 500;
}
.segmented button[aria-pressed="true"] {
  background: var(--primary); color: #fff; font-weight: 700;
}

/* ─────────────── Shared pieces ─────────────── */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card {
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 99px; white-space: nowrap;
  font-size: .78rem; font-weight: 600;
  color: var(--amber); background: var(--amber-bg);
}
.chip.urgent    { color: var(--red);   background: var(--red-bg); }
.chip.soft      { color: var(--muted); background: var(--bg); font-weight: 500; }
.chip.new-badge { color: #047857;      background: #d1fae5; margin-inline-start: 6px; font-size: .72rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: .82rem; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty strong { display: block; color: var(--text); font-size: 1rem; margin-bottom: 6px; }

/* ─────────────── Weekly schedule grid ─────────────── */
.wk-wrap {
  display: flex; flex-direction: column; gap: 0;
  min-height: 0;
  flex: 1;
}

.wk-wrap .wk-grid {
  flex: 1;
  min-height: 860px;
}

.wk-grid {
  display: flex;
  gap: 0;
  direction: ltr;
  overflow-x: auto;
  scrollbar-width: thin;
}

.wk-time-col {
  flex: none; width: 52px;
  display: flex; flex-direction: column;
}

.wk-col {
  flex: 1; min-width: 130px;
  display: flex; flex-direction: column;
  border-inline-end: 1px solid var(--border);
}
.wk-col:last-child { border-inline-end: 0; }

.wk-col.wk-today { background: rgba(79, 41, 183, .03); }

.wk-day-header {
  height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem; color: var(--muted);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
  padding: 0 4px;
}
.wk-day-header .day-num { font-size: .75rem; font-weight: 400; color: var(--faint); }
.wk-today .wk-day-header {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.wk-time-col .wk-day-header { border-bottom: 2px solid var(--border); }

.wk-periods {
  position: relative;
  flex: 1;
}

.wk-time-label {
  position: absolute;
  right: 0; left: 0;
  text-align: center;
  font-size: .7rem;
  color: var(--faint);
  transform: translateY(-50%);
  padding-top: 2px;
}

.wk-rule {
  position: absolute;
  right: 0; left: 0;
  height: 1px;
  background: var(--border);
}

.wk-card {
  position: absolute;
  left: 3px; right: 3px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 5px 8px;
  overflow: hidden;
  font-size: .78rem;
  display: flex; flex-direction: column; justify-content: flex-start; gap: 1px;
  cursor: default;
  direction: rtl;
  transition: box-shadow .15s;
}
.wk-card:hover { box-shadow: var(--shadow-md); z-index: 1; }
.wk-subj { font-weight: 700; line-height: 1.25; word-break: break-word; }
.wk-card-time { font-size: .7rem; opacity: .75; direction: ltr; text-align: right; }

.wk-card.wk-now {
  box-shadow: 0 0 0 2px var(--primary), var(--shadow-sm);
  z-index: 2;
}
.wk-card.wk-now .wk-subj::after {
  content: " ●";
  font-size: .55rem;
  vertical-align: middle;
  color: var(--primary);
}

/* Now-line (current time indicator) */
.wk-now-line {
  position: absolute;
  right: 0; left: 0;
  height: 2px;
  background: var(--red);
  z-index: 3;
}
.wk-now-line::before {
  content: "";
  position: absolute;
  right: -4px; top: -4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
}

/* ─────────────── Homework ─────────────── */
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.item.high { border-inline-start: 3px solid var(--red); }
.item.past { opacity: .65; }
.subject-tag { color: var(--primary); font-weight: 600; font-size: .82rem; margin-bottom: 3px; }
.item h3 { font-size: 1rem; font-weight: 600; line-height: 1.4; }
.item p  { color: var(--muted); font-size: .88rem; max-width: 65ch; margin-top: 3px; }
.hw-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Two-column layout for homework cards */
.hw-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: start; }
.hw-left  { display: flex; flex-direction: column; gap: 3px; }
.hw-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; text-align: end; min-width: 130px; }

/* Status chips */
.chip.hw-ok      { color: var(--green);   background: var(--green-bg); }
.chip.hw-overdue { color: var(--red);     background: var(--red-bg); }
.chip.hw-status  { font-size: .78rem; padding: 3px 9px; }

/* ─────────────── Responsive ─────────────── */
@media (max-width: 900px) {
  body { grid-template-columns: minmax(0, 1fr); overflow: auto; height: auto; min-height: 100%; }
  .sidebar { border: 0; border-bottom: 1px solid var(--border-hard); }
  .tabs { flex-direction: row; padding: 0 6px 8px; }
  .tab { flex: 1; min-width: 0; flex-direction: column; justify-content: center; gap: 2px;
         padding: 6px 4px; text-align: center; font-size: .75rem; line-height: 1.3; }
  .tab[aria-selected="true"]::before { display: none; }
  .badge { position: absolute; top: 3px; left: 3px; }
  .main { padding: 12px; gap: 12px; }
  .banner { flex-direction: column; align-items: stretch; padding: 18px; }
  .banner h1 { font-size: 1.25rem; }
  .clock { min-width: 0; }
  .panel-body { overflow: visible; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .clock-time span { font-size: 1.8rem; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1; padding: 0 4px; font-size: .8rem; }
  .item { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .due { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .wk-col { min-width: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
