/* =====================================================
   PORTAL.CSS — ACI Teacher Attendance Portal
   Apple-style visual system (see DESIGN-apple.md)

   NOTE: the original file stacked three separate redesigns
   on top of each other with !important overrides (the last
   one — "compact" — is what actually rendered, since it's
   what index.html's markup targets: <div class="form-wrap
   compact-portal">...). This file keeps that exact same
   markup contract (every class/id index.html and app.js use
   is still styled here) but as one clean, non-conflicting
   stylesheet instead of three layered ones. Nothing that
   was visually rendering has changed in structure — only
   color / type / radius / shadow tokens moved to match
   DESIGN-apple.md. A stray debug rule (body outline) from
   the old file has been removed.
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap');

:root{
  --primary:#0066cc;
  --primary-focus:#0071e3;
  --primary-on-dark:#2997ff;
  --ink:#1d1d1f;
  --ink-muted-80:#333333;
  --ink-muted-48:#7a7a7a;
  --canvas:#ffffff;
  --canvas-parchment:#f5f5f7;
  --surface-pearl:#fafafc;
  --hairline:#e3e6ea;
  --divider-soft:#eef0f3;
  --danger:#d6362b;
  --danger-bg:#fdeceb;
  --danger-border:#f4c3bf;
  --success:#1a8f4c;
  --success-bg:#eaf7ef;

  /* legacy names some rules below reuse for compactness */
  --aci:var(--primary);
  --ink2:#182033;
  --muted:var(--ink-muted-48);
  --line:var(--hairline);
  --page:var(--canvas-parchment);
  --ok:var(--success);
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{min-height:100%}
body{
  font-family: 'Vazirmatn','Noto Sans Arabic',sans-serif;
  background:var(--page);
  color:var(--ink);
  -webkit-font-smoothing:antialiased;
}

/* ── HEADER ─────────────────────────────────────────── */
.site-header{
  position:sticky;top:0;z-index:100;
  min-height:54px;height:54px;
  padding:7px 16px;
  display:flex;align-items:center;gap:10px;
  background:#000000;border-bottom:none;
}
.logo-badge{
  width:36px;height:36px;min-width:36px;
  border-radius:10px;background:var(--primary);
  display:flex;align-items:center;justify-content:center;
  font-size:13px;font-weight:700;color:#fff;flex-shrink:0;
}
.header-text{min-width:0;line-height:1}
.header-text h1{
  font-family: 'Vazirmatn','Noto Sans Arabic',sans-serif;
  font-size:14px;line-height:1.15;font-weight:600;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#fff;
}
.header-text p{display:none}
#hYear{display:none}

.lang-switcher{margin-inline-start:auto;display:flex;align-items:center;gap:4px}
.lang-btn{
  background:rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.16);
  color:#fff;border-radius:999px;padding:6px 9px;
  font-size:10px;line-height:1;font-weight:600;cursor:pointer;
  font-family:inherit;transition:background .2s;
}
.lang-btn:hover{background:rgba(255,255,255,.2)}
.lang-btn.active{background:var(--primary);border-color:var(--primary)}

.header-user{display:flex;align-items:center;gap:6px}
.user-pill{display:none}
.user-pill .dot{width:8px;height:8px;background:var(--success);border-radius:50%;animation:pulse 2s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}
.btn-logout{
  background:transparent;border:1px solid rgba(255,255,255,.28);
  color:#fff;border-radius:999px;padding:7px 10px;
  font-size:11px;cursor:pointer;font-family:inherit;transition:background .2s;
  white-space:nowrap;
}
.btn-logout:hover{background:var(--danger);border-color:var(--danger)}

/* ── LOADING / TOAST ────────────────────────────────── */
.loading-overlay{
  position:fixed;inset:0;z-index:200;
  background:rgba(0,0,0,.45);
  display:none;align-items:center;justify-content:center;
  backdrop-filter:blur(6px);
}
.loading-overlay.show{display:flex}
.loading-box{background:#fff;border-radius:16px;padding:26px 34px;text-align:center;box-shadow:0 16px 40px rgba(0,0,0,.14)}
.loading-box p{margin-top:12px;font-size:13px;color:var(--muted)}
.spinner{width:36px;height:36px;border:3px solid var(--divider-soft);border-top-color:var(--primary);border-radius:50%;animation:spin .8s linear infinite;margin:0 auto}
@keyframes spin{to{transform:rotate(360deg)}}

.toast{
  position:fixed;bottom:20px;left:50%;
  transform:translateX(-50%) translateY(120px);
  background:#000;color:#fff;padding:11px 20px;
  border-radius:999px;font-size:13px;font-weight:600;z-index:300;
  transition:transform .3s cubic-bezier(.22,1,.36,1);
  box-shadow:0 10px 26px rgba(0,0,0,.2);pointer-events:none;
}
.toast.show{transform:translateX(-50%) translateY(0)}
.toast.success{background:var(--success)}
.toast.error{background:var(--danger)}

/* ── LAYOUT ─────────────────────────────────────────── */
main{
  max-width:860px;
  min-height:calc(100vh - 54px);
  padding:12px 12px 90px;
  margin:0 auto;
  display:block;
}
.form-wrap.compact-portal{max-width:820px;margin:0 auto}

/* status strip */
.portal-status{
  min-height:56px;margin:0 0 10px;padding:9px 12px;
  border:1px solid var(--hairline);border-radius:14px;background:#fff;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
}
.portal-status-main{display:flex;align-items:center;gap:9px;min-width:0}
.status-avatar{
  width:34px;height:34px;min-width:34px;border-radius:10px;
  display:flex;align-items:center;justify-content:center;
  background:#eaf1fb;color:var(--primary);font-size:15px;font-weight:700;
}
.status-copy{min-width:0}
.status-title{font-size:14px;font-weight:600;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.status-sub{display:none}
.status-meta{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:11px;font-weight:600}
.status-date{color:var(--muted)}
.status-date strong{color:var(--primary);font-size:12px}
.working-status{font-size:11px;font-weight:700;padding:4px 10px;border-radius:999px;background:var(--success-bg);color:var(--success)}

/* ── CONFIRM DIALOG ─────────────────────────────────── */
.confirm-overlay{
  position:fixed;inset:0;z-index:400;
  background:rgba(0,0,0,.45);backdrop-filter:blur(4px);
  display:none;align-items:center;justify-content:center;
}
.confirm-overlay.show{display:flex}
.confirm-box{
  background:#fff;border-radius:18px;padding:30px 26px;
  max-width:360px;width:90%;text-align:center;
  box-shadow:0 20px 48px rgba(0,0,0,.2);
}
.confirm-icon{font-size:2.2rem;margin-bottom:12px}
.confirm-box h3{font-size:1rem;font-weight:600;margin-bottom:8px}
.confirm-box p{font-size:.86rem;color:var(--muted);margin-bottom:20px;line-height:1.55}
.confirm-btns{display:flex;gap:10px;justify-content:center}
.btn-conf-cancel{
  padding:11px 22px;background:none;border:1px solid var(--line);
  border-radius:999px;font-family:inherit;font-size:.86rem;
  color:var(--muted);cursor:pointer;min-height:44px;
}
.btn-conf-delete{
  padding:11px 22px;background:var(--danger);border:none;
  border-radius:999px;font-family:inherit;font-size:.86rem;
  font-weight:600;color:#fff;cursor:pointer;min-height:44px;
}
.btn-conf-delete:hover{background:#b52c22}

/* ── CARDS ──────────────────────────────────────────── */
/* Base rule on plain .card so every card gets this chrome, whether it
   also carries .compact-card (lesson-card / students-card) or not
   (recent-card only carries .card + .compact-recent). */
.card{
  margin:0 0 10px;border:1px solid var(--hairline);border-radius:14px;
  background:#fff;box-shadow:none;overflow:visible;
}
.compact-section-title{
  min-height:42px;padding:9px 14px;display:flex;align-items:center;gap:9px;
  border-bottom:1px solid var(--divider-soft);background:transparent;
  border-radius:14px 14px 0 0;
}
.section-icon{
  width:24px;height:24px;min-width:24px;border-radius:7px;
  display:flex;align-items:center;justify-content:center;
  background:var(--primary);color:#fff;font-size:11px;font-weight:700;
}
.compact-section-title h3{font-size:13px;font-weight:600;margin:0;color:var(--ink)}
.compact-card-body{padding:12px 14px}

/* ── LESSON FIELDS ──────────────────────────────────── */
.lesson-fields{display:grid;grid-template-columns:1fr;gap:10px}
.form-group{margin-bottom:0;min-width:0}
.form-group label{font-size:12px;font-weight:600;margin-bottom:6px;display:block;color:var(--ink-muted-80)}
.req{color:var(--danger);margin-inline-end:2px}
.form-control{
  width:100%;min-height:46px;height:46px;padding:0 14px;
  border:1px solid var(--line);border-radius:12px;background:#fff;
  color:var(--ink);font-size:15px;font-weight:500;line-height:46px;
  outline:none;font-family:inherit;transition:border-color .2s,box-shadow .2s;
}
select.form-control{appearance:auto;cursor:pointer;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}
.form-control:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(0,102,204,.14)}
#fLecture{font-weight:600;text-align:center;text-align-last:center}

/* ── STUDENTS AREA ──────────────────────────────────── */
.students-title-row{justify-content:space-between}
.students-title-left{display:flex;align-items:center;gap:8px;min-width:0}
.students-title-left h3{margin:0}
.students-title-row .students-count{margin-inline-start:auto}
.students-count{
  padding:4px 10px;border-radius:999px;font-size:11px;font-weight:700;
  background:var(--danger);color:#fff;white-space:nowrap;
}
.students-body{padding:10px 12px}
.students-area{border:0;border-radius:0;background:transparent;padding:0}
.students-area-header{margin:0 0 8px;padding:0;background:transparent;border:0}
.students-area-header h4{font-size:12px;font-weight:700;color:var(--ink-muted-80);margin:0}
.student-hint{font-size:10.5px;color:var(--muted);margin-top:2px}

.student-search{
  display:block;width:100%;height:40px;min-height:40px;margin:0 0 8px;
  padding:0 14px;border-radius:10px;font-size:13px;font-weight:500;
  border:1px solid var(--line);font-family:inherit;outline:none;
}
.student-search:focus{border-color:var(--primary)}

.students-grid{display:flex;flex-direction:column;gap:7px;padding:0}

.student-check{
  position:relative;display:flex;align-items:center;gap:10px;
  min-height:52px;padding:9px 12px;
  border:1px solid var(--line);border-radius:12px;background:#fff;
  cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;
  transition:background .12s,border-color .12s;
}
.student-check input{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}
.student-no{font-size:11px;color:#a7adb6;min-width:24px;text-align:center;font-weight:700;flex:none}
.student-check .sname{
  font-size:14px;font-weight:600;flex:1;line-height:1.3;margin-inline-start:2px;
  white-space:normal;overflow:visible;overflow-wrap:anywhere;word-break:normal;
}
.student-check::after{
  content:'✓';margin-inline-start:auto;width:26px;height:26px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:var(--success-bg);color:var(--success);font-weight:700;font-size:13px;flex:none;
}
.student-check.checked{background:var(--danger-bg);border-color:var(--danger-border)}
.student-check.checked::after{content:'×';background:#fbdedb;color:var(--danger)}
.student-check.checked .sname{color:var(--danger)}

.no-students{padding:26px 14px;text-align:center;color:var(--muted);font-size:13px}
.no-students .icon{font-size:2rem;margin-bottom:8px;display:block}

/* ── ABSENT PREVIEW ─────────────────────────────────── */
.absent-preview{display:none;height:0;margin:0;padding:0}
.absent-preview.show{
  display:block;height:auto;margin:0 0 8px;
  padding:9px 11px;border:1px solid var(--danger-border);border-radius:12px;
  background:var(--danger-bg);animation:fadeUp .2s ease;
}
.absent-preview h5{font-size:11px;color:var(--muted);font-weight:700;margin:0 0 6px}
.absent-pills{display:flex;flex-direction:column;gap:6px;overflow-x:auto;padding-bottom:2px;-webkit-overflow-scrolling:touch}
.absent-pills::-webkit-scrollbar{height:4px}
.absent-pill{
  display:flex;align-items:center;gap:6px;flex:none;
  background:#fff;border:1px solid var(--danger-border);color:var(--danger);
  font-size:12px;font-weight:600;padding:6px 10px;border-radius:999px;white-space:nowrap;
}
.absent-pill .remove-pill{cursor:pointer;opacity:.7;font-weight:700}
.absent-pill .remove-pill:hover{opacity:1}
@keyframes fadeUp{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}

/* ── ACTION ROW ─────────────────────────────────────── */
.action-row.compact-actions{
  position:sticky;bottom:0;z-index:80;
  margin:0 0 10px;padding:9px;min-height:58px;
  display:flex;align-items:center;gap:8px;
  background:rgba(255,255,255,.94);backdrop-filter:blur(10px);
  border:1px solid var(--hairline);border-radius:14px;
  box-shadow:0 -6px 20px rgba(0,0,0,.06);
}
.btn-secondary,.btn-submit{
  height:46px;min-height:46px;border-radius:999px;font-size:14px;font-weight:600;
  padding:0 16px;font-family:inherit;cursor:pointer;transition:background .2s,transform .1s;
  display:flex;align-items:center;justify-content:center;gap:8px;border:none;
}
.btn-secondary{
  min-width:96px;background:#fff;border:1px solid var(--line);color:#6d7785;
}
.btn-secondary:hover{border-color:var(--danger);color:var(--danger)}
.btn-submit{
  flex:1;background:var(--primary);color:#fff;justify-content:center;
}
.btn-submit:hover{background:var(--primary-focus)}
.btn-submit:active,.btn-secondary:active{transform:scale(.97)}
.btn-submit:disabled{background:#c7c7cc;cursor:not-allowed;transform:none}

/* ── RECENT SUBMISSIONS ─────────────────────────────── */
.compact-recent{margin-top:0}
.recent-title-row .recent-count-badge{
  margin-inline-start:auto;background:var(--primary);color:#fff;
  border-radius:999px;padding:3px 9px;font-size:10px;font-weight:700;
}
.compact-recent .card-body{padding:0}
.recent-table-wrap{overflow:visible}
.recent-table{width:100%;font-size:12px;border-collapse:collapse}
.recent-table th{background:transparent;display:none}
.recent-table,
.recent-table tbody,
.recent-table tr,
.recent-table td{display:block;width:100%}
.recent-table tr{
  padding:11px 12px;border:1px solid var(--hairline);border-radius:12px;
  margin-bottom:8px;background:#fff;
}
.recent-table tr:last-child{margin-bottom:0}
.recent-table td{padding:3px 0;border:0;font-size:12px}
.recent-table td:nth-child(1)::before{content:'Lecture: ';font-weight:700;color:var(--muted)}
.recent-table td:nth-child(2)::before{content:'Subject: ';font-weight:700;color:var(--muted)}
.recent-table td:nth-child(3)::before{content:'Class: ';font-weight:700;color:var(--muted)}
.recent-table td:nth-child(4)::before{content:'Absent: ';font-weight:700;color:var(--muted)}
.recent-table td:nth-child(4){padding-top:6px}
.recent-table td:nth-child(5){margin-top:8px}

.rt-lecture{
  display:inline-block;background:var(--ink);color:#fff;
  border-radius:999px;padding:2px 10px;font-size:11px;font-weight:700;white-space:nowrap;
}
.rt-class{
  display:inline-block;background:var(--divider-soft);color:var(--ink-muted-80);
  border-radius:999px;padding:2px 10px;font-size:11px;font-weight:700;white-space:nowrap;
  border:1px solid var(--hairline);
}
.rt-pills{display:flex;flex-wrap:wrap;gap:5px}
.rt-name-pill{
  background:var(--danger-bg);color:var(--danger);border:1px solid var(--danger-border);
  border-radius:999px;padding:2px 9px;font-size:11px;font-weight:600;white-space:nowrap;
}
.rt-none{color:var(--muted);font-size:12px;font-style:italic}
.rt-actions{display:flex;gap:6px;flex-wrap:wrap;width:100%}
.btn-rt-edit,.btn-rt-delete{
  flex:1;min-height:34px;padding:5px 10px;font-size:11px;font-weight:700;
  border-radius:999px;cursor:pointer;font-family:inherit;transition:background .2s,color .2s;
}
.btn-rt-edit{background:none;border:1px solid #b8d4ff;color:#2563eb}
.btn-rt-edit:hover{background:#2563eb;color:#fff}
.btn-rt-delete{background:none;border:1px solid var(--danger-border);color:var(--danger)}
.btn-rt-delete:hover{background:var(--danger);color:#fff}

/* ── SUCCESS SCREEN ─────────────────────────────────── */
.success-wrap{width:100%;max-width:460px;margin:24px auto;animation:fadeUp .3s ease both}
.success-card{
  background:#fff;border-radius:18px;border:1px solid var(--hairline);
  box-shadow:0 20px 48px rgba(0,0,0,.1);padding:32px 26px;text-align:center;
}
.success-icon{
  width:66px;height:66px;background:var(--success-bg);border-radius:50%;
  display:flex;align-items:center;justify-content:center;font-size:30px;margin:0 auto 16px;
  animation:popIn .4s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes popIn{from{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}
.success-card h2{font-family: 'Vazirmatn','Noto Sans Arabic',sans-serif;font-size:1.2rem;font-weight:600;color:var(--success);margin-bottom:8px}
.success-card p{font-size:.9rem;color:var(--muted);line-height:1.6}
.success-details{background:var(--page);border-radius:12px;padding:12px 16px;margin:14px 0}
.detail-row{display:flex;justify-content:space-between;align-items:center;padding:5px 0;border-bottom:1px solid var(--hairline);font-size:12px}
.detail-row:last-child{border-bottom:none}
.detail-row .label{color:var(--muted)}
.detail-row .val{font-weight:700;color:var(--ink)}
.btn-new{
  margin-top:16px;padding:11px 26px;background:var(--primary);color:#fff;border:none;
  border-radius:999px;font-family:inherit;font-size:.9rem;font-weight:600;cursor:pointer;
  transition:background .2s;min-height:44px;
}
.btn-new:hover{background:var(--primary-focus)}

/* ── MOBILE FINE-TUNING (≤700px) ────────────────────── */
@media(max-width:700px){
  .site-header{height:52px;min-height:52px;padding:6px 9px;gap:7px}
  .logo-badge{width:32px;height:32px;min-width:32px;font-size:11px;border-radius:8px}
  .header-text h1{font-size:12px;max-width:150px}
  .lang-btn{padding:5px 6px;font-size:9px}
  .btn-logout{padding:6px 8px;font-size:10px}
  main{padding:8px 8px 84px}
  .portal-status{min-height:50px;margin-bottom:8px;padding:7px 9px;border-radius:12px;gap:7px}
  .status-avatar{width:29px;height:29px;min-width:29px;font-size:12px;border-radius:8px}
  .status-title{font-size:12px}
  .status-meta{gap:5px;font-size:9px}
  .status-date strong{font-size:10px}
  .working-status{font-size:9px;padding:3px 7px}
  .compact-section-title{min-height:38px;padding:7px 10px}
  .compact-section-title h3{font-size:12px}
  .compact-card-body{padding:10px}
  .form-control{height:44px;min-height:44px;line-height:44px;font-size:14px}
  .students-grid{gap:6px}
  .student-check{min-height:48px;padding:8px 10px}
  .student-check .sname{font-size:13px}
  .student-search{height:38px;min-height:38px;font-size:12px}
  .student-hint{display:none}
  .action-row.compact-actions{margin:0 0 8px;padding:7px;min-height:52px}
  .btn-secondary,.btn-submit{height:44px;min-height:44px;font-size:13px}
  .btn-secondary{min-width:84px}
}

/* ── TABLET (≥701px) ────────────────────────────────── */
@media(min-width:701px){
  .lesson-fields{grid-template-columns:1fr 1fr}
  .students-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .student-check:hover{background:#fafafc}
}

/* ── DESKTOP (≥851px) ─────────────────────────────────
   Layout, top to bottom:
   1. portal-status — full width
   2. lesson-card — full width, 3-wide fields
   3. students-card + compact-recent side by side
      (grid placement drives position, not DOM order, so
      it flips automatically for RTL vs LTR — column 1
      renders on the right in RTL / left in LTR)
   4. action-row — full width
   ────────────────────────────────────────────────────── */
@media(min-width:851px){
  main{max-width:1300px;padding:24px 20px 60px}
  .form-wrap.compact-portal{
    display:grid;grid-template-columns:1.9fr 1fr;max-width:none;
    grid-template-rows:auto auto auto;gap:16px;align-items:start;
  }
  .portal-status{grid-column:1/-1;grid-row:1}
  .lesson-card{grid-column:1/-1;grid-row:2}
  .students-card{grid-column:1;grid-row:3}
  .compact-recent{grid-column:2;grid-row:3;margin:0;align-self:start}
  .action-row.compact-actions{grid-column:1/-1;grid-row:4}

  .compact-section-title h3{font-size:15px}
  .compact-card-body{padding:18px 20px}
  .lesson-fields{grid-template-columns:repeat(3,1fr);gap:16px}
  .form-control{height:48px;min-height:48px;line-height:48px;font-size:15px}
  .form-group label{font-size:12px}

  .students-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 10px}
  .student-check{min-height:52px;padding:9px 12px}
  .student-check .sname{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .btn-secondary,.btn-submit{height:48px;font-size:14px}

  /* "recent submissions" sits in a narrow sidebar next to the
     student list, so it keeps the stacked-card layout used on
     phones rather than switching to a wide table. */
  .compact-recent .recent-table tr{padding:10px 12px;margin-bottom:8px}
  .compact-recent .rt-actions{gap:6px}
}

/* One web font for every device (iOS / Android / desktop) — no native system fonts */
button, input, select, textarea { font-family: inherit; }
