/*
 * portal.css — Student & Parent Portal
 *
 * Extends the ERP design system (tokens.css + base.css).
 * Loads AFTER tokens.css and base.css so it inherits all CSS variables.
 * Does NOT redefine tokens — uses --accent, --surface-card, etc. directly.
 */

/* ================================================================
   PORTAL AUTH SHELL (login, OTP, profile gateway, forgot password)
   These pages don't use .app-shell — they are full-screen centred.
   ================================================================ */

.portal-auth-page {
  min-height: 100vh;
  background: var(--surface-canvas);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
}

/* Top accent band */
.portal-auth-page::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, #6E8BFF 100%);
  z-index: 10;
}

.portal-auth-card {
  background: var(--surface-card);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-2);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  animation: portal-slide-up 0.25s ease;
}

@keyframes portal-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Auth logo / brand ---- */
.portal-auth-logo {
  text-align: center;
  margin-bottom: var(--s-6);
}
.portal-auth-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-3);
  background: linear-gradient(135deg, var(--accent) 0%, #6E8BFF 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: white;
  margin-bottom: var(--s-3);
}
.portal-auth-title {
  font-size: var(--fs-20);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text-1);
  margin-bottom: 4px;
}
.portal-auth-subtitle {
  font-size: var(--fs-13);
  color: var(--text-3);
}

/* ---- Step indicator ---- */
.portal-steps {
  display: flex;
  align-items: center;
  margin-bottom: var(--s-5);
}
.portal-step {
  display: flex;
  align-items: center;
  flex: 1;
}
.portal-step__circle {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1.5px solid var(--border-2);
  background: var(--surface-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--text-3);
  flex-shrink: 0;
  transition: all 0.2s;
}
.portal-step__line {
  flex: 1;
  height: 1.5px;
  background: var(--border-1);
  transition: background 0.2s;
}
.portal-step--done .portal-step__circle {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.portal-step--done .portal-step__line { background: var(--success); }
.portal-step--active .portal-step__circle {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ---- OTP digit inputs ---- */
.portal-otp-inputs {
  display: flex;
  gap: var(--s-2);
  justify-content: center;
  margin: var(--s-4) 0;
}
.portal-otp-digit {
  width: 46px;
  height: 52px;
  border: 1.5px solid var(--border-1);
  border-radius: var(--r-2);
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-1);
  background: var(--surface-sunk);
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}
.portal-otp-digit:focus {
  border-color: var(--accent);
  background: var(--surface-card);
  box-shadow: 0 0 0 2px var(--accent-weak);
}

/* ---- Profile gateway cards ---- */
.portal-profiles-grid {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin: var(--s-4) 0;
}
.portal-profile-card {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  cursor: pointer;
  background: var(--surface-card);
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
}
.portal-profile-card:hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}
.portal-profile-card:active { transform: scale(0.99); }
.portal-profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-13);
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.portal-profile-avatar--parent  { background: var(--warn); }
.portal-profile-avatar--student { background: var(--accent); }
.portal-profile-info { flex: 1; }
.portal-profile-name { font-size: var(--fs-14); font-weight: 600; color: var(--text-1); }
.portal-profile-meta { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }
.portal-profile-arrow { color: var(--text-3); }

/* ================================================================
   PORTAL APP SHELL (authenticated pages)
   Uses the same .app-shell grid as the ERP but with a portal-specific
   top bar. Left rail is replaced with a bottom nav on mobile.
   ================================================================ */

/* Top bar — reuses .topbar classes from base.css */
.portal-topbar-brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, #6E8BFF 100%);
}

/* Role badge — uses existing .pill classes */
.portal-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 var(--s-2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.portal-role-chip--parent  { background: var(--warn-weak);    color: var(--warn); }
.portal-role-chip--student { background: var(--accent-weak);  color: var(--accent); }

/* Ward switcher banner */
.portal-ward-bar {
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--border-1);
  padding: 6px var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  font-size: var(--fs-12);
  color: var(--text-3);
}
.portal-ward-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 var(--s-3);
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: 500;
  border: 1px solid var(--border-2);
  background: var(--surface-card);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-decoration: none;
}
.portal-ward-chip:hover { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }
.portal-ward-chip--active { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }
.portal-ward-chip__dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* ---- Bottom navigation (mobile) ---- */
.portal-bottom-nav {
  display: none; /* shown below 720px */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface-card);
  border-top: 1px solid var(--border-1);
  height: 60px;
  box-shadow: 0 -2px 12px rgba(14,15,18,.06);
}
.portal-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.12s;
  position: relative;
}
.portal-bottom-nav__item svg { width: 20px; height: 20px; }
.portal-bottom-nav__item--active { color: var(--accent); }
.portal-bottom-nav__item--active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}

@media (max-width: 720px) {
  .portal-bottom-nav { display: flex; }
  .portal-main { padding-bottom: calc(60px + var(--s-5)) !important; }
}

/* ================================================================
   PORTAL CONTENT AREA
   Inside .content — same padding as ERP
   ================================================================ */

.portal-main {
  /* inherits .content padding from base.css */
}

.portal-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
  gap: var(--s-4);
}
.portal-page-title {
  font-size: var(--fs-28);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text-1);
  margin: 0;
}
.portal-page-subtitle {
  font-size: var(--fs-13);
  color: var(--text-3);
  margin-top: 2px;
}

/* ================================================================
   STAT TILES — mirrors .kpi from dashboard.css
   ================================================================ */

.portal-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
@media (max-width: 1100px) { .portal-stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .portal-stat-grid { grid-template-columns: repeat(2, 1fr); } }

.portal-stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  position: relative;
  overflow: hidden;
}
.portal-stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-weak);
  color: var(--accent);
}
.portal-stat-icon svg { width: 14px; height: 14px; }
.portal-stat-icon--success { background: var(--success-weak); color: var(--success); }
.portal-stat-icon--warn    { background: var(--warn-weak);    color: var(--warn); }
.portal-stat-icon--danger  { background: var(--danger-weak);  color: var(--danger); }
.portal-stat-icon--info    { background: var(--info-weak);    color: var(--info); }

.portal-stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text-1);
  line-height: 1;
  font-feature-settings: "tnum" 1;
}
.portal-stat-label {
  font-size: var(--fs-12);
  color: var(--text-3);
}

/* Progress bar — reuses .progress from dashboard.css */
.portal-att-bar {
  height: 6px;
  background: var(--surface-rail);
  border-radius: 999px;
  overflow: hidden;
}
.portal-att-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.portal-att-bar__fill--success { background: var(--success); }
.portal-att-bar__fill--warn    { background: var(--warn); }
.portal-att-bar__fill--danger  { background: var(--danger); }

/* ================================================================
   PORTAL FORM ELEMENTS
   Extends .input/.select/.textarea from base.css with label styling
   ================================================================ */

.p-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: var(--s-4);
}
.p-label {
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--text-2);
}
/* Inputs inherit .input from base.css — just add full-width */
.p-input {
  width: 100%;
  height: 34px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-card);
  font: inherit;
  font-size: var(--fs-13);
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s;
}
.p-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}
.p-input::placeholder { color: var(--text-3); }

.p-select {
  width: 100%;
  height: 34px;
  padding: 0 var(--s-8) 0 var(--s-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-card);
  font: inherit;
  font-size: var(--fs-13);
  color: var(--text-1);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6F76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.p-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }

.p-textarea {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  background: var(--surface-card);
  font: inherit;
  font-size: var(--fs-13);
  color: var(--text-1);
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s;
}
.p-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }

/* Portal buttons — full-width variants of .btn */
.p-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 34px;
  padding: 0 var(--s-3);
  border-radius: var(--r-2);
  border: 1px solid var(--border-1);
  background: var(--surface-card);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.p-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.p-btn--primary { background: var(--accent); color: white; border-color: var(--accent); width: 100%; }
.p-btn--primary:hover { background: var(--accent-hover); }
.p-btn--ghost { background: transparent; border-color: var(--border-1); }
.p-btn--ghost:hover { background: var(--surface-rail); }
.p-btn--danger { background: var(--danger); color: white; border-color: var(--danger); }
.p-btn--danger:hover { background: #b02d15; }
.p-btn--success { background: var(--success-weak); color: var(--success); border-color: var(--success-weak); }
.p-btn--success:hover { border-color: var(--success); }
.p-btn--sm { height: 28px; padding: 0 var(--s-2); font-size: var(--fs-12); }
.p-btn:active { transform: scale(0.98); }

/* ================================================================
   TABLE — same style as ERP data tables
   ================================================================ */

.p-table-wrap { overflow-x: auto; }
.p-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.p-table th {
  text-align: left;
  padding: var(--s-2) var(--s-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--border-1);
  white-space: nowrap;
}
.p-table td {
  padding: 10px var(--s-3);
  border-bottom: 1px solid var(--border-1);
  color: var(--text-2);
  vertical-align: middle;
}
.p-table tr:last-child td { border-bottom: none; }
.p-table tr:hover td { background: var(--surface-sunk); }

/* ================================================================
   ATTENDANCE
   ================================================================ */

.portal-att-summary-bar {
  height: 8px;
  background: var(--surface-rail);
  border-radius: 999px;
  overflow: hidden;
  margin: var(--s-2) 0;
}
.portal-att-summary-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #6E8BFF);
  transition: width 0.4s ease;
}

/* ================================================================
   FEE CARDS
   ================================================================ */

.portal-fee-row {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-1);
}
.portal-fee-row:last-child { border-bottom: none; }
.portal-fee-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.portal-fee-icon svg { width: 16px; height: 16px; }
.portal-fee-icon--paid    { background: var(--success-weak); color: var(--success); }
.portal-fee-icon--pending { background: var(--warn-weak);    color: var(--warn); }
.portal-fee-info { flex: 1; min-width: 0; }
.portal-fee-desc { font-size: var(--fs-13); font-weight: 500; color: var(--text-1); }
.portal-fee-term { font-size: var(--fs-12); color: var(--text-3); }
.portal-fee-due  { font-size: var(--fs-12); color: var(--text-3); }
.portal-fee-amount {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--text-1);
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  text-align: right;
}
.portal-fee-amount-label { font-size: var(--fs-12); color: var(--text-3); font-weight: 400; font-family: var(--font-ui); }

/* ================================================================
   LEAVE CARDS
   ================================================================ */

.portal-leave-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-1);
}
.portal-leave-item:last-child { border-bottom: none; }
.portal-leave-type  { font-size: var(--fs-13); font-weight: 500; color: var(--text-1); }
.portal-leave-dates { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }
.portal-leave-reason { font-size: var(--fs-13); color: var(--text-2); margin-top: 4px; }
.portal-leave-meta  { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Pending approval block (parent view) */
.portal-approval-block {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-2);
  padding: var(--s-3);
  border-radius: var(--r-2);
  border: 1px solid var(--border-1);
  background: var(--surface-card);
  margin-bottom: var(--s-2);
}
.portal-approval-block:last-child { margin-bottom: 0; }
.portal-approval-actions { display: flex; gap: 6px; align-items: flex-start; }

/* ================================================================
   EXAM CARDS
   ================================================================ */

.portal-exam-row {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-1);
}
.portal-exam-row:last-child { border-bottom: none; }
.portal-exam-date-box {
  width: 44px;
  height: 48px;
  border-radius: var(--r-2);
  background: var(--accent-weak);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.portal-exam-date-box .day  { font-size: 10px; color: var(--accent); font-weight: 600; text-transform: uppercase; }
.portal-exam-date-box .date { font-size: 18px; font-weight: 700; color: var(--accent); line-height: 1; font-family: var(--font-mono); }
.portal-exam-subject { font-size: var(--fs-13); font-weight: 500; color: var(--text-1); }
.portal-exam-meta    { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }

/* Result rows */
.portal-result-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px var(--s-5);
  border-bottom: 1px solid var(--border-1);
}
.portal-result-row:last-child { border-bottom: none; }
.portal-result-subject { flex: 1; font-size: var(--fs-13); color: var(--text-1); }
.portal-result-marks {
  font-size: var(--fs-13);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
}
.portal-result-grade {
  width: 28px;
  height: 28px;
  border-radius: var(--r-1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-12);
  font-weight: 700;
}
.portal-result-grade--ap { background: var(--success-weak); color: var(--success); }
.portal-result-grade--a  { background: var(--info-weak);    color: var(--info); }
.portal-result-grade--bp { background: var(--neutral-weak); color: var(--text-2); }
.portal-result-grade--b  { background: var(--warn-weak);    color: var(--warn); }
.portal-result-grade--c  { background: var(--danger-weak);  color: var(--danger); }

/* ================================================================
   NOTICE BOARD
   ================================================================ */

.portal-notice-item {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-1);
}
.portal-notice-item:last-child { border-bottom: none; }
.portal-notice-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.portal-notice-icon svg { width: 14px; height: 14px; }
.portal-notice-icon--school { background: var(--accent-weak); color: var(--accent); }
.portal-notice-icon--class  { background: var(--warn-weak);   color: var(--warn); }
.portal-notice-title { font-size: var(--fs-13); font-weight: 500; color: var(--text-1); margin-bottom: 3px; }
.portal-notice-body  { font-size: var(--fs-13); color: var(--text-2); line-height: var(--lh-normal); }
.portal-notice-meta  { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ================================================================
   ALERTS
   ================================================================ */

.p-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: 10px var(--s-4);
  border-radius: var(--r-2);
  border: 1px solid transparent;
  font-size: var(--fs-13);
  font-weight: 500;
  margin-bottom: var(--s-3);
}
.p-alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.p-alert--success { background: var(--success-weak); color: var(--success); border-color: var(--success-weak); }
.p-alert--error   { background: var(--danger-weak);  color: var(--danger);  border-color: var(--danger-weak); }
.p-alert--info    { background: var(--info-weak);    color: var(--info);    border-color: var(--info-weak); }
.p-alert--warning { background: var(--warn-weak);    color: var(--warn);    border-color: var(--warn-weak); }

/* ================================================================
   UTILITIES
   ================================================================ */

.p-divider { height: 1px; background: var(--border-1); margin: var(--s-4) 0; }
.p-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.p-link:hover { text-decoration: underline; }
.p-text-muted { color: var(--text-3); font-size: var(--fs-12); }
.p-text-center { text-align: center; }

.p-empty-state {
  text-align: center;
  padding: var(--s-10) var(--s-5);
  color: var(--text-3);
}
.p-empty-state svg { width: 40px; height: 40px; margin: 0 auto var(--s-3); opacity: 0.35; }
.p-empty-state p { font-size: var(--fs-13); }

/* password strength bar */
.pw-strength-bar { display: flex; align-items: center; gap: var(--s-2); margin-top: 5px; }
.pw-strength-track { flex: 1; height: 3px; border-radius: 999px; background: var(--border-1); overflow: hidden; }
.pw-strength-fill  { height: 100%; border-radius: 999px; transition: width 0.2s, background 0.2s; width: 0; }
.pw-strength-label { font-size: 11px; color: var(--text-3); width: 38px; }
