/* ── Reset & Variables ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Avantika University brand ──────────────────────────────────────────── */
  --brand:        #C8202A;   /* AU crimson — outer petals */
  --brand-dark:   #9B191E;   /* hover / pressed */
  --brand-light:  #FEF2F2;   /* tinted bg */

  /* Accent gold from mandala centre */
  --gold:         #F5A100;
  --gold-dark:    #7a4700;
  --gold-light:   #FFF8EC;

  /* Success */
  --green:        #34C759;
  --green-dark:   #1a7a36;
  --green-light:  #F0FFF4;

  /* Informational / approved badge (kept blue so it's distinct from brand red) */
  --blue:         #0071E3;
  --blue-dark:    #004fb3;
  --blue-light:   #EBF5FF;

  /* Destructive — a brighter red, visually distinct from brand crimson */
  --red:          #EF4444;
  --red-light:    #FFF5F5;

  /* Grays */
  --gray-50:   #F9FAFB;
  --gray-100:  #F5F5F5;
  --gray-200:  #E8E8E8;
  --gray-400:  #AEAEB2;
  --gray-500:  #777777;   /* matches "UNIVERSITY" text in AU logo */
  --gray-600:  #555555;
  --gray-700:  #374151;
  --gray-800:  #1C1C1E;

  /* Geometry */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-md: 0 4px 20px rgba(0,0,0,.1), 0 2px 6px rgba(0,0,0,.06);

  /* Typography — Inter is clean, highly legible at all sizes */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Material Symbols helper ──────────────────────────────────────────────── */
.ms {
  font-family: 'Material Symbols Rounded';
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Typography ────────────────────────────────────────────────────────────── */
h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 1rem;    font-weight: 600; letter-spacing: -.01em; }
p  { line-height: 1.5; }
.text-sm    { font-size: .85rem; }
.text-muted { color: var(--gray-500); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
#app { flex: 1; display: flex; flex-direction: column; }

/* ── Top bar — Avantika brand crimson ────────────────────────────────────── */
.topbar {
  background: var(--brand);
  border-bottom: none;
  color: #fff;
  padding: .75rem 1rem;
  padding-top: calc(.75rem + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 8px rgba(200,32,42,.25);
}
.topbar-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; color: #fff; }
.topbar-sub   { font-size: .72rem; color: rgba(255,255,255,.78); margin-top: .05rem; }
.btn-topbar-icon {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: 8px;
  padding: .33rem .45rem;
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.btn-topbar-icon:hover { background: rgba(255,255,255,.25); }
.btn-topbar-icon .ms  { font-size: 1.1rem; }
.btn-logout {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: 8px;
  padding: .33rem .7rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.28); }

/* ── Bottom tab bar (iOS / Android style) ────────────────────────────────── */
.nav-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,.95);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0,0,0,.08);
  display: flex;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .18rem;
  padding: .45rem .2rem .5rem;
  font-size: .6rem;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: .01em;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-400);
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.nav-tab .ms { font-size: 1.55rem; transition: font-variation-settings .15s, transform .12s; }
.nav-tab.active { color: var(--brand); }
.nav-tab.active .ms { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.nav-tab:active .ms { transform: scale(.84); }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Badge on nav icon */
.nav-icon-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.nav-badge {
  position: absolute;
  top: -4px; right: -8px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: .58rem;
  padding: .05rem .35rem;
  font-weight: 700;
  line-height: 1.6;
  border: 1.5px solid #fff;
  min-width: 18px;
  text-align: center;
}

/* ── Content area ─────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: .75rem;
}
.card-title { font-size: .9rem; font-weight: 600; margin-bottom: .5rem; }

/* ── Form ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: .875rem; }
label {
  display: block;
  font-size: .68rem;
  color: var(--gray-600);
  margin-bottom: .3rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: .72rem .9rem;
  font-size: 1rem;
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23777' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}
::placeholder { color: var(--gray-400); opacity: 1; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(200,32,42,.12);
}
input:disabled, select:disabled, textarea:disabled {
  opacity: .5;
  cursor: not-allowed;
  background: var(--gray-100);
}
textarea { resize: vertical; min-height: 76px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: none;
  border-radius: 10px;
  padding: .72rem 1.25rem;
  font-size: .9rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  width: 100%;
  letter-spacing: -.01em;
  transition: opacity .12s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn .ms    { font-size: 1.15rem; }
.btn:active { transform: scale(.96); opacity: .85; }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn-primary  { background: var(--brand);  color: #fff; }
.btn-success  { background: var(--green);  color: #fff; }
.btn-danger   { background: var(--red);    color: #fff; }
.btn-outline  { background: var(--gray-100); color: var(--gray-800); border: 1.5px solid var(--gray-200); }
.btn-primary:hover:not(:disabled)  { background: var(--brand-dark); }
.btn-success:hover:not(:disabled)  { background: #2da44e; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }
.btn-outline:hover:not(:disabled)  { background: var(--gray-200); border-color: var(--gray-400); }
.btn-sm       { padding: .4rem .9rem; font-size: .8rem; width: auto; border-radius: 8px; gap: .28rem; min-height: 36px; }
.btn-sm .ms   { font-size: 1rem; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .22rem;
  padding: .22rem .65rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge .ms      { font-size: .8rem; font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20; }
.badge-pending  { background: var(--gold-light);  color: var(--gold-dark); }
.badge-approved { background: var(--blue-light);  color: var(--blue-dark); }  /* blue, distinct from brand */
.badge-out      { background: var(--green-light); color: var(--green-dark); }
.badge-closed   { background: var(--gray-100);    color: var(--gray-600); }
.badge-rejected { background: var(--red-light);   color: var(--red); }
.badge-overdue  { background: var(--red-light);   color: var(--red); border: 1px solid #fecaca; }

/* ── Request list item ────────────────────────────────────────────────────── */
.req-item {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .9rem;
  margin-bottom: .5rem;
  background: #fff;
  transition: box-shadow .15s, border-color .15s;
}
@media (hover: hover) {
  .req-item:hover { box-shadow: var(--shadow); border-color: var(--gray-400); }
}
.req-item.overdue      { border-left: 3px solid var(--red); }
.req-item.expired-pass { border-left: 3px solid var(--gray-400); opacity: .8; }
.req-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .25rem; }
.req-type   { font-size: .88rem; font-weight: 700; letter-spacing: -.01em; }
.req-meta   { font-size: .75rem; color: var(--gray-600); margin-top: .15rem; line-height: 1.55; }

/* ── Gate pass ────────────────────────────────────────────────────────────── */
.pass-card {
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  background: var(--brand-light);
}
.pass-qr    { margin: .75rem auto; }
.pass-token { font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace; font-size: .78rem; word-break: break-all; color: var(--gray-600); margin-top: .5rem; }

/* ── Summary counts ───────────────────────────────────────────────────────── */
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.count-box { background: #fff; border-radius: var(--radius); padding: .9rem .5rem; text-align: center; box-shadow: var(--shadow-sm); }
.count-num  { font-size: 1.9rem; font-weight: 800; letter-spacing: -.04em; color: var(--brand); line-height: 1; }
.count-lbl  { font-size: .62rem; color: var(--gray-500); margin-top: .25rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: .75rem;
  font-weight: 500;
  line-height: 1.5;
}
.alert-error   { background: var(--red-light);   color: var(--red);       border: 1px solid #fecaca; }
.alert-success { background: var(--green-light);  color: var(--green-dark); border: 1px solid #9ae6b4; }
.alert-info    { background: var(--blue-light);   color: var(--blue-dark);  border: 1px solid #bfdbfe; }
.alert-warning { background: var(--gold-light);   color: var(--gold-dark);  border: 1px solid #f5c842; }

/* ── Toast notifications ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(480px, 92vw);
  padding: .8rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  font-family: var(--font);
  z-index: 999;
  box-shadow: var(--shadow-md);
  transition: top .35s cubic-bezier(.34,1.4,.64,1);
  white-space: pre-line;
  text-align: center;
  pointer-events: none;
}
.toast.toast-show { top: calc(1rem + env(safe-area-inset-top, 0px)); }
.toast-success { background: #1a7a36;       color: #fff; }
.toast-error   { background: var(--red);    color: #fff; }
.toast-warning { background: var(--gold);   color: #fff; }
.toast-info    { background: var(--gray-800); color: #fff; }

/* ── Login screen ─────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: linear-gradient(175deg, var(--brand-light) 0%, #fff 55%);
}
/* Official AU logo image */
.login-brand   { text-align: center; margin-bottom: 1.25rem; }
.login-logoimg {
  width: 200px;
  height: auto;
  display: block;
  margin: 0 auto;
}
/* App name sits below the logo */
.login-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; color: var(--brand); margin-bottom: .2rem; text-align: center; }
.login-sub   { font-size: .875rem; color: var(--gray-500); margin-bottom: 1.75rem; text-align: center; }
.login-card  { background: #fff; border-radius: var(--radius-xl); padding: 1.75rem; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 3rem 1rem 2rem;
  color: var(--gray-400);
  font-size: .9rem;
  font-weight: 500;
}
.empty .ms { font-size: 2.75rem; opacity: .4; }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  width: 26px; height: 26px;
  animation: spin .65s linear infinite;
  margin: 2.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ms.spin { display: inline-block; animation: spin .65s linear infinite; }

/* ── Row actions ──────────────────────────────────────────────────────────── */
.row-actions { display: flex; gap: .4rem; margin-top: .6rem; flex-wrap: wrap; }

/* ── Analytics dashboard ──────────────────────────────────────────────────── */

/* Stat cards row */
.an-stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
  margin-bottom: .5rem;
}
.an-stat-card {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .75rem .65rem .6rem;
  text-align: center;
}
.an-stat-icon .ms { font-size: 1.3rem; color: var(--gray-400); }
.an-stat-val  { font-size: 1.75rem; font-weight: 800; line-height: 1.15; margin: .1rem 0 .15rem; }
.an-stat-lbl  { font-size: .68rem; color: var(--gray-500); font-weight: 600;
                text-transform: uppercase; letter-spacing: .04em; }

/* Section headings inside cards */
.an-section-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--gray-500);
  display: flex; align-items: center; gap: .3rem;
  margin-bottom: .6rem;
}
.an-section-title .ms { font-size: .95rem; }
.an-narrative { border-left: 3px solid var(--brand); }
.an-narrative .an-section-title { color: var(--brand-dark); }
.an-narrative .an-section-title .ms { color: var(--brand); }
.an-narrative-text {
  font-size: .88rem; line-height: 1.6; color: var(--gray-600);
  margin: 0;
}

/* Weekly bar chart */
.an-chart-wrap  { overflow-x: auto; }
.an-bar-chart   { display: flex; align-items: flex-end; gap: .3rem; height: 130px; min-width: 320px; }
.an-col         { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; }
.an-bar-val     { font-size: .62rem; font-weight: 700; color: var(--gray-600);
                  min-height: 14px; line-height: 14px; }
.an-bar         { width: 100%; border-radius: 4px 4px 0 0; flex-shrink: 0; transition: height .3s; }
.an-bar-lbl     { font-size: .58rem; color: var(--gray-500); margin-top: .2rem;
                  text-align: center; white-space: nowrap; }

/* Horizontal bar rows (type breakdown + destinations) */
.an-hbar-row    { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.an-hbar-label  { font-size: .75rem; font-weight: 600; color: var(--gray-700);
                  min-width: 5.5rem; flex-shrink: 0; }
.an-hbar-track  { flex: 1; height: 10px; background: var(--gray-100);
                  border-radius: 999px; overflow: hidden; }
.an-hbar-fill   { height: 100%; background: var(--brand); border-radius: 999px;
                  transition: width .4s; }
.an-hbar-num    { font-size: .73rem; font-weight: 700; color: var(--gray-600);
                  min-width: 2rem; text-align: right; }

/* Student frequency table */
.an-table-wrap  { overflow-x: auto; }
.an-table       { width: 100%; border-collapse: collapse; font-size: .78rem; }
.an-table thead th {
  text-align: left; font-size: .67rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--gray-500); padding: .3rem .4rem;
  border-bottom: 1.5px solid var(--gray-200);
}
.an-table tbody td  { padding: .4rem .4rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.an-table tbody .an-row-warn { background: var(--red-light); }
.an-rank        { color: var(--gray-400); font-weight: 700; font-size: .7rem; min-width: 1.2rem; }
.an-stu-name    { font-weight: 600; font-size: .78rem; }
.an-stu-id      { font-size: .65rem; color: var(--gray-500); }
.an-count       { font-weight: 700; text-align: center; }
.an-late        { text-align: center; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.hidden { display: none !important; }
