@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;600;700;800;900&display=swap');

/* ═══ RESET ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; font-size: 16px; }
body {
  font-family: 'Heebo', sans-serif;
  direction: rtl;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text1);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; direction: rtl; }

/* ═══ DESIGN TOKENS ════════════════════════════════════════════════════════ */
:root {
  /* Colors */
  --bg:           #F8FAFC;
  --surface:      #FFFFFF;
  --surface2:     #F1F5F9;
  --surface3:     #E8F0FE;
  --border:       #E2E8F0;
  --border2:      #CBD5E1;

  --text1:        #0F172A;
  --text2:        #334155;
  --text3:        #64748B;
  --text4:        #94A3B8;

  --accent:       #2563EB;
  --accent-light: #EFF6FF;
  --accent-mid:   #BFDBFE;
  --accent-dark:  #1D4ED8;

  --success:      #16A34A;
  --success-light:#F0FDF4;
  --success-mid:  #BBF7D0;

  --danger:       #DC2626;
  --danger-light: #FEF2F2;
  --danger-mid:   #FECACA;

  --warning:      #D97706;
  --warning-light:#FFFBEB;
  --warning-mid:  #FDE68A;

  --purple:       #7C3AED;
  --purple-light: #F5F3FF;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md:  0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg:  0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.04);

  /* Radius */
  --r-sm:   8px;
  --r:      12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* Spacing */
  --page-pad: 16px;

  /* Bottom nav height */
  --nav-h: 64px;
}

/* ═══ DOT GRID BACKGROUND ══════════════════════════════════════════════════ */
.dot-bg {
  background-image: radial-gradient(circle, #CBD5E1 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: 0 0;
}

/* ═══ PAGES ════════════════════════════════════════════════════════════════ */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; flex-direction: column; }

/* ═══ TYPOGRAPHY ════════════════════════════════════════════════════════════ */
.t-display { font-size: 28px; font-weight: 800; line-height: 1.2; letter-spacing: -0.5px; }
.t-title   { font-size: 20px; font-weight: 700; line-height: 1.3; }
.t-heading { font-size: 17px; font-weight: 700; line-height: 1.4; }
.t-body    { font-size: 15px; font-weight: 400; line-height: 1.6; }
.t-small   { font-size: 13px; font-weight: 400; line-height: 1.5; }
.t-tiny    { font-size: 11px; font-weight: 500; line-height: 1.4; }
.t-label   { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text3); }

/* ═══ BUTTONS ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 20px; height: 48px;
  border-radius: var(--r-full); font-size: 15px; font-weight: 700;
  border: none; cursor: pointer; transition: all 0.15s ease;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
  background: var(--surface); color: var(--accent);
  border: 1.5px solid var(--accent-mid);
}
.btn-secondary:hover { background: var(--accent-light); }

.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); }

.btn-danger {
  background: var(--danger); color: #fff;
  box-shadow: 0 2px 8px rgba(220,38,38,0.25);
}

.btn-success {
  background: var(--success); color: #fff;
  box-shadow: 0 2px 8px rgba(22,163,74,0.25);
}

.btn-lg { height: 56px; font-size: 17px; padding: 0 28px; }
.btn-sm { height: 36px; font-size: 13px; padding: 0 14px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--r); }
.btn-icon-sm { width: 32px; height: 32px; padding: 0; border-radius: var(--r-sm); }
.btn-full { width: 100%; }

/* ═══ INPUTS ════════════════════════════════════════════════════════════════ */
.input-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.input-label { font-size: 13px; font-weight: 600; color: var(--text2); }
.input {
  width: 100%; height: 52px; padding: 0 16px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r); font-size: 16px; color: var(--text1);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.input::placeholder { color: var(--text4); }
.input-error { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(220,38,38,0.1) !important; }
.field-error { font-size: 12px; color: var(--danger); font-weight: 500; display: none; }
.field-error.show { display: block; }

.textarea {
  width: 100%; padding: 14px 16px; min-height: 90px; resize: vertical;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r); font-size: 15px; color: var(--text1);
  transition: border-color 0.15s; outline: none; line-height: 1.6;
}
.textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

select.input { appearance: none; cursor: pointer; }

/* ═══ CARDS ═════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.card-interactive { cursor: pointer; }
.card-interactive:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card-interactive:active { transform: scale(0.99); }

/* ═══ BADGES ════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge-blue    { background: var(--accent-light); color: var(--accent); }
.badge-green   { background: var(--success-light); color: var(--success); }
.badge-red     { background: var(--danger-light); color: var(--danger); }
.badge-yellow  { background: var(--warning-light); color: var(--warning); }
.badge-purple  { background: var(--purple-light); color: var(--purple); }
.badge-gray    { background: var(--surface2); color: var(--text3); }

/* ═══ TOP BAR ═══════════════════════════════════════════════════════════════ */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--page-pad);
  background: rgba(248,250,252,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  min-height: 60px;
}
.top-bar-title { font-size: 17px; font-weight: 800; color: var(--text1); }
.top-bar-sub   { font-size: 12px; color: var(--text3); font-weight: 500; }

/* ═══ BOTTOM NAV ════════════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 1; padding: 8px 0; background: none; border: none; cursor: pointer;
  color: var(--text4); transition: color 0.15s;
  font-size: 10px; font-weight: 600;
}
.nav-btn.active { color: var(--accent); }
.nav-btn svg { width: 22px; height: 22px; }
.nav-indicator {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); margin-top: 1px;
  opacity: 0; transition: opacity 0.15s;
}
.nav-btn.active .nav-indicator { opacity: 1; }

/* ═══ SCROLLABLE CONTENT AREA ════════════════════════════════════════════ */
.scroll-area {
  flex: 1; overflow-y: auto; padding: var(--page-pad);
  padding-bottom: calc(var(--nav-h) + 24px);
  -webkit-overflow-scrolling: touch;
}

/* ═══ SECTION HEADER ════════════════════════════════════════════════════════ */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; margin-top: 8px;
}
.section-title {
  font-size: 13px; font-weight: 700; color: var(--text3);
  letter-spacing: 0.05em; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.section-dot {
  width: 6px; height: 6px; border-radius: 50%;
}

/* ═══ TASK CARD (STUDENT) ════════════════════════════════════════════════ */
.task-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.15s;
  animation: slideUp 0.3s ease both;
}
.task-card:active { transform: scale(0.99); }
.task-card.pending { border-right: 3px solid var(--accent); }
.task-card.submitted { border-right: 3px solid var(--success); }
.task-card.reviewed  { border-right: 3px solid var(--purple); }

.task-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.task-card-name { font-size: 16px; font-weight: 700; color: var(--text1); flex: 1; line-height: 1.3; }
.task-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-card-class { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-light); padding: 2px 8px; border-radius: var(--r-full); }
.task-card-due { font-size: 12px; color: var(--text3); display: flex; align-items: center; gap: 4px; }
.task-card-due.overdue { color: var(--warning); }
.task-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* Submit button inside card */
.btn-submit-task {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-full);
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
  transition: all 0.15s;
}
.btn-submit-task:active { transform: scale(0.97); }

/* ═══ SUBMISSION STATUS ═════════════════════════════════════════════════════ */
.status-row { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.pending   { background: var(--accent); }
.status-dot.submitted { background: var(--success); }
.status-dot.reviewed  { background: var(--purple); }
.status-dot.rejected  { background: var(--danger); }

/* ═══ SUMMARY STATS ═════════════════════════════════════════════════════════ */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 10px; text-align: center;
  box-shadow: var(--shadow-xs);
}
.stat-card.clickable { cursor: pointer; transition: all 0.15s; }
.stat-card.clickable:active { transform: scale(0.97); }
.stat-card.active { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card.active.blue   { border-color: var(--accent);   background: var(--accent-light); }
.stat-card.active.green  { border-color: var(--success);  background: var(--success-light); }
.stat-card.active.red    { border-color: var(--danger);   background: var(--danger-light); }
.stat-card.active.purple { border-color: var(--purple);   background: var(--purple-light); }
.stat-num  { font-size: 24px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-lbl  { font-size: 11px; font-weight: 600; color: var(--text3); }
.stat-card.blue   .stat-num { color: var(--accent); }
.stat-card.green  .stat-num { color: var(--success); }
.stat-card.red    .stat-num { color: var(--danger); }
.stat-card.purple .stat-num { color: var(--purple); }

/* Wide stats (5 col) */
.stats-row-5 { grid-template-columns: repeat(5, 1fr); }

/* ═══ TEACHER SUBMISSION CARD ═══════════════════════════════════════════════ */
.sub-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  margin-bottom: 8px; cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all 0.15s;
  animation: slideUp 0.25s ease both;
  display: flex; align-items: center; gap: 12px;
}
.sub-card:active { transform: scale(0.99); }
.sub-card.reviewed  { border-right: 3px solid var(--purple); }
.sub-card.pending   { border-right: 3px solid var(--warning); }
.sub-card.rejected  { border-right: 3px solid var(--danger); }
.sub-card.missing   { border-right: 3px solid var(--border2); opacity: 0.7; cursor: default; }

.sub-card-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #fff;
}
.sub-card-body { flex: 1; min-width: 0; }
.sub-card-name { font-size: 15px; font-weight: 700; color: var(--text1); }
.sub-card-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ═══ GROUP HEADER ══════════════════════════════════════════════════════════ */
.group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 0 8px; 
}
.group-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.group-label { font-size: 11px; font-weight: 700; color: var(--text3); letter-spacing: 0.06em; text-transform: uppercase; flex: 1; }
.group-count { font-size: 11px; font-weight: 700; color: var(--text4); background: var(--surface2); padding: 1px 8px; border-radius: var(--r-full); }

/* ═══ TEACHER TASK CARD ═════════════════════════════════════════════════════ */
.teacher-task-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  margin-bottom: 8px; box-shadow: var(--shadow-xs);
  animation: slideUp 0.25s ease both;
  transition: all 0.15s;
}
.teacher-task-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border2); }

.ttc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.ttc-name { font-size: 16px; font-weight: 700; color: var(--text1); flex: 1; }
.ttc-desc { font-size: 13px; color: var(--text3); line-height: 1.5; margin-bottom: 10px; }
.ttc-footer { display: flex; justify-content: space-between; align-items: center; }
.ttc-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.ttc-due { font-size: 12px; color: var(--text3); display: flex; align-items: center; gap: 4px; }
.ttc-due.overdue { color: var(--warning); }
.ttc-actions { display: flex; gap: 6px; }
.ttc-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm); border: 1.5px solid;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.15s; background: transparent;
}
.ttc-btn.edit { border-color: var(--accent-mid); color: var(--accent); }
.ttc-btn.edit:hover { background: var(--accent-light); }
.ttc-btn.del  { border-color: var(--danger-mid); color: var(--danger); }
.ttc-btn.del:hover  { background: var(--danger-light); }

/* ═══ REVIEW MODE (TEACHER) ════════════════════════════════════════════════ */
.review-screen {
  position: fixed; inset: 0; background: #fff; z-index: 500;
  display: none; flex-direction: column;
}
.review-screen.active { display: flex; }

.review-header {
  padding: 12px var(--page-pad);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
}
.review-progress-bar {
  height: 3px; background: var(--border);
  position: relative; overflow: hidden;
}
.review-progress-fill {
  height: 100%; background: var(--accent);
  transition: width 0.3s ease;
  border-radius: var(--r-full);
}
.review-student-info {
  padding: 12px var(--page-pad) 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.review-name { font-size: 17px; font-weight: 700; color: var(--text1); }
.review-meta { font-size: 12px; color: var(--text3); margin-top: 2px; display: flex; align-items: center; gap: 8px; }

.review-images {
  flex: 1; overflow-y: auto; padding: var(--page-pad);
  background: #F8FAFC;
  display: flex; flex-direction: column; gap: 10px;
}
.review-img-item {
  position: relative; border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow-sm); cursor: zoom-in;
}
.review-img-item img { width: 100%; display: block; }

.review-ai-banner {
  margin: 0 var(--page-pad) 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #EFF6FF, #F5F3FF);
  border: 1px solid var(--accent-mid);
  border-radius: var(--r);
  display: flex; align-items: flex-start; gap: 10px;
}
.review-ai-banner.uncertain {
  background: linear-gradient(135deg, var(--warning-light), #FFFBEB);
  border-color: var(--warning-mid);
}

.review-actions {
  padding: 12px var(--page-pad);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.review-verdict-row { display: flex; gap: 10px; margin-bottom: 12px; }
.verdict-btn {
  flex: 1; height: 52px; border-radius: var(--r);
  font-size: 16px; font-weight: 700; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s;
}
.verdict-btn.approve {
  background: var(--success-light); color: var(--success);
  border: 2px solid var(--success-mid);
}
.verdict-btn.approve.selected {
  background: var(--success); color: #fff;
  box-shadow: 0 2px 12px rgba(22,163,74,0.3);
}
.verdict-btn.reject {
  background: var(--danger-light); color: var(--danger);
  border: 2px solid var(--danger-mid);
}
.verdict-btn.reject.selected {
  background: var(--danger); color: #fff;
  box-shadow: 0 2px 12px rgba(220,38,38,0.3);
}

.feedback-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.feedback-chip {
  padding: 6px 14px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--surface2); color: var(--text2);
  border: 1.5px solid var(--border);
  transition: all 0.15s; white-space: nowrap;
}
.feedback-chip.selected {
  background: var(--accent-light); color: var(--accent);
  border-color: var(--accent-mid);
}

.review-note-input {
  width: 100%; padding: 10px 14px;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--r); font-size: 14px; color: var(--text1);
  outline: none; resize: none; min-height: 64px;
  transition: border-color 0.15s;
  margin-bottom: 10px;
}
.review-note-input:focus { border-color: var(--accent); background: var(--surface); }

.grade-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.grade-input {
  width: 90px; height: 46px; text-align: center;
  font-size: 20px; font-weight: 800; color: var(--accent);
  background: var(--accent-light); border: 1.5px solid var(--accent-mid);
  border-radius: var(--r); outline: none;
}

.review-nav { display: flex; gap: 10px; }
.review-nav .btn { flex: 1; }

/* ═══ CAMERA SCREEN ══════════════════════════════════════════════════════ */
.camera-screen {
  position: fixed; inset: 0; background: #000; z-index: 600;
  display: none; flex-direction: column;
}
.camera-screen.active { display: flex; }

.camera-video-wrap { flex: 1; position: relative; overflow: hidden; }
#camera-video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Crop overlay */
#crop-mask { position: absolute; inset: 0; pointer-events: none; }
#crop-rect {
  position: absolute; border: 2px solid rgba(255,255,255,0.9);
  border-radius: 4px; cursor: move; touch-action: none;
  pointer-events: all;
}
.crop-corner {
  position: absolute; width: 22px; height: 22px;
  background: #fff; border-radius: 3px;
  touch-action: none; pointer-events: all;
}
.crop-corner.tl { top: -6px; right: -6px; cursor: nwse-resize; border-radius: 3px 0 3px 0; }
.crop-corner.tr { top: -6px; left: -6px;  cursor: nesw-resize; border-radius: 0 3px 0 3px; }
.crop-corner.bl { bottom: -6px; right: -6px; cursor: nesw-resize; border-radius: 0 3px 0 3px; }
.crop-corner.br { bottom: -6px; left: -6px;  cursor: nwse-resize; border-radius: 3px 0 3px 0; }

.camera-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); color: #fff; font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: var(--r-full);
  pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(4px);
}

.camera-bottom {
  background: rgba(0,0,0,0.85); backdrop-filter: blur(10px);
  padding: 16px var(--page-pad) calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

.camera-controls-row { display: flex; align-items: center; justify-content: space-between; }

.shutter-btn {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fff; border: 4px solid rgba(255,255,255,0.3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}
.shutter-btn:active { transform: scale(0.93); }
.shutter-inner { width: 56px; height: 56px; border-radius: 50%; background: #fff; }

.photo-strip {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none;
}
.photo-strip::-webkit-scrollbar { display: none; }
.photo-thumb {
  position: relative; flex-shrink: 0; width: 60px; height: 60px;
  border-radius: 8px; overflow: hidden; cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb-del {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none;
  font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-count-badge {
  position: absolute; bottom: 4px; left: 4px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: var(--r-full);
}

.quality-msg {
  text-align: center; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--r);
  display: none;
}
.quality-msg.ok  { background: rgba(22,163,74,0.15); color: #16A34A; }
.quality-msg.err { background: rgba(220,38,38,0.15); color: var(--danger); }

/* ═══ MODAL SYSTEM ══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px); z-index: 700;
  display: none; align-items: flex-end; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-overlay.active { display: flex; }
.modal-overlay.center { align-items: center; padding: var(--page-pad); }

.modal-sheet {
  background: var(--surface); width: 100%; max-width: 480px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-height: 92vh; overflow-y: auto;
  animation: sheetUp 0.25s cubic-bezier(0.32,0.72,0,1);
}
.modal-overlay.center .modal-sheet {
  border-radius: var(--r-xl); max-height: 85vh;
}
.modal-handle {
  width: 36px; height: 4px; background: var(--border2);
  border-radius: var(--r-full); margin: 10px auto 0;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 16px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
}

/* Tabs inside modal */
.modal-tabs { display: flex; border-bottom: 1px solid var(--border); }
.modal-tab {
  flex: 1; padding: 12px 8px; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--text3);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: all 0.15s;
}
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.modal-pane { display: none; padding: 20px; }
.modal-pane.active { display: block; }

/* ═══ WELCOME / AUTH SCREENS ════════════════════════════════════════════════ */
.auth-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px var(--page-pad);
}

.logo-mark {
  width: 72px; height: 72px; border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), #7C3AED);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; box-shadow: 0 8px 24px rgba(37,99,235,0.3);
  margin-bottom: 20px;
}
.logo-name { font-size: 32px; font-weight: 900; color: var(--text1); margin-bottom: 6px; }
.logo-sub  { font-size: 15px; color: var(--text3); margin-bottom: 40px; }

.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 28px 24px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-md);
}
.auth-title { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.auth-sub   { font-size: 14px; color: var(--text3); margin-bottom: 24px; }
.auth-divider { text-align: center; color: var(--text4); font-size: 13px; margin: 16px 0; position: relative; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.auth-divider span { background: var(--surface); padding: 0 12px; position: relative; }

.welcome-btns { display: flex; gap: 12px; width: 100%; max-width: 380px; }
.welcome-btn {
  flex: 1; height: 64px; border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all 0.15s;
  box-shadow: var(--shadow-xs);
  font-size: 15px; font-weight: 700; color: var(--text1);
}
.welcome-btn:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.welcome-btn span { font-size: 22px; }
.welcome-btn.teacher { border-color: var(--purple); }
.welcome-btn.teacher:hover { background: var(--purple-light); }

/* Step indicator */
.step-row { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border2); transition: background 0.2s; }
.step-dot.active { background: var(--accent); }
.step-back {
  background: none; border: none; color: var(--text3);
  font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 4px;
  font-weight: 600; padding: 4px 0;
}

/* ═══ STUDENT HOME FEED ══════════════════════════════════════════════════ */
.student-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #7C3AED);
  cursor: pointer;
}

.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-icon { width: 40px; height: 40px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px; }
.history-body { flex: 1; min-width: 0; }
.history-name { font-size: 14px; font-weight: 700; color: var(--text1); }
.history-class { font-size: 12px; color: var(--text3); margin-top: 1px; }
.history-right { text-align: left; flex-shrink: 0; }
.history-grade { font-size: 18px; font-weight: 800; color: var(--accent); }
.history-status { font-size: 11px; }

/* ═══ DATA / MATRIX TABLE ════════════════════════════════════════════════ */
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.matrix-table { border-collapse: collapse; min-width: 100%; }
.matrix-table th {
  background: var(--surface2); padding: 10px 12px;
  font-size: 11px; font-weight: 700; color: var(--text3);
  text-align: center; border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0;
}
.matrix-table th.sticky-col { right: 0; background: var(--surface2); z-index: 10; border-left: 1px solid var(--border); }
.matrix-table td {
  padding: 10px 12px; text-align: center; font-size: 13px;
  border-bottom: 1px solid var(--border); border-left: 1px solid var(--border);
  background: var(--surface);
}
.matrix-table td.sticky-col { right: 0; background: var(--surface); position: sticky; font-weight: 600; font-size: 13px; border-left: 2px solid var(--border2); }
.matrix-table tr:last-child td { border-bottom: none; }
.matrix-table tfoot td { background: var(--surface2); font-weight: 700; font-size: 12px; border-top: 2px solid var(--border2); }
.cell-ok   { color: var(--success); font-weight: 700; }
.cell-late { color: var(--warning); font-weight: 700; }
.cell-no   { color: var(--danger);  font-weight: 700; }

/* ═══ EMPTY STATE ═══════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 48px var(--page-pad);
  color: var(--text3);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.empty-sub { font-size: 14px; }

/* ═══ TOAST ══════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text1); color: #fff; padding: 10px 20px;
  border-radius: var(--r-full); font-size: 14px; font-weight: 600;
  z-index: 9999; opacity: 0; transition: all 0.25s;
  white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ═══ LOADING ════════════════════════════════════════════════════════════════ */
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  margin: 32px auto;
}
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px); z-index: 800;
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
}
.loading-overlay.active { display: flex; }

/* ═══ FULLSCREEN IMAGE VIEWER ════════════════════════════════════════════ */
.img-viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,0.97);
  z-index: 900; display: none; flex-direction: column;
  align-items: center; justify-content: center;
}
.img-viewer.active { display: flex; }
.img-viewer-img {
  max-width: 100%; max-height: 85vh; object-fit: contain;
  transition: transform 0.1s; touch-action: none;
  user-select: none;
}
.img-viewer-close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.15); color: #fff; border: none;
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.img-viewer-nav {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.img-viewer-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.4); transition: background 0.2s; }
.img-viewer-dot.active { background: #fff; }

/* ═══ CLASS SELECT CHIP ROW ═════════════════════════════════════════════════ */
.class-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin-bottom: 16px; }
.class-chips::-webkit-scrollbar { display: none; }
.class-chip {
  padding: 7px 16px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  background: var(--surface2); color: var(--text2);
  border: 1.5px solid var(--border); cursor: pointer;
  transition: all 0.15s; flex-shrink: 0;
}
.class-chip.active {
  background: var(--accent-light); color: var(--accent);
  border-color: var(--accent-mid);
}

/* ═══ PROFILE SCREEN ════════════════════════════════════════════════════════ */
.profile-avatar-big {
  width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #7C3AED);
  box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}
.profile-field { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.profile-field-label { font-size: 13px; font-weight: 600; color: var(--text3); width: 72px; flex-shrink: 0; text-align: right; }

/* ═══ SCHOOL SELECTOR ═══════════════════════════════════════════════════════ */
.school-search-wrap { position: relative; margin-bottom: 8px; }
.school-dropdown {
  position: absolute; top: 100%; right: 0; left: 0; z-index: 50;
  background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: var(--r); box-shadow: var(--shadow-md);
  max-height: 220px; overflow-y: auto;
  display: none;
}
.school-dropdown.open { display: block; }
.school-option {
  padding: 11px 16px; cursor: pointer; font-size: 14px;
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.school-option:hover { background: var(--accent-light); }
.school-option:last-child { border-bottom: none; }
.school-option-name { font-weight: 600; color: var(--text1); }
.school-option-city { font-size: 12px; color: var(--text3); }

/* ═══ PROGRESS / MISC ════════════════════════════════════════════════════════ */
.progress-ring { transform: rotate(-90deg); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ═══ ANIMATIONS ═════════════════════════════════════════════════════════════ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: 0.5; }
}

/* ═══ RESPONSIVE ═════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  :root { --page-pad: 24px; }
  .modal-sheet { border-radius: var(--r-xl); }
  .modal-overlay { align-items: center; padding: 24px; }
}

/* ═══ SAFE AREA ══════════════════════════════════════════════════════════════ */
.scroll-area { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
