/* Eng. Kiro Adel Ghobrial: shared look for the student app and the teacher panel.
   Colors come from his "Our Books" banner: midnight → indigo, plus the book colors. Built phone-first. */
:root {
  --ink: #14123a;
  --ink-2: #3c3a63;
  --muted: #6c6a8e;
  --line: #e4e3f0;
  --bg: #f4f4fb;
  --card: #ffffff;
  --brand: #3b30d9;
  --brand-2: #ecebff;
  --night: #0b0a26;
  --hero: linear-gradient(115deg, #05051a 0%, #17135a 48%, #3b30d9 100%);
  --accent: #f2a516;      /* orange book */
  --green: #1f9d55;       /* practice book 1 */
  --sky: #1aa3d9;         /* practice book 2 */
  --purple: #7d2d91;      /* notes part 2 */
  --ok: #148049;
  --ok-bg: #e3f6ea;
  --warn: #9a5a00;
  --warn-bg: #fff2d8;
  --bad: #c0262d;
  --bad-bg: #fde8e8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 18, 58, .05), 0 6px 18px rgba(20, 18, 58, .07);
  --display: "Oswald", "Bebas Neue", Impact, "Arial Narrow", sans-serif;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; font-size: 15px; line-height: 1.5; }
img { max-width: 100%; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-family: var(--display); font-weight: 700; font-size: 1.75rem; letter-spacing: .01em; }
h2 { font-family: var(--display); font-weight: 600; font-size: 1.25rem; letter-spacing: .01em; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 1rem; }
.section { margin-top: 1.4rem; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; min-width: 0; }
.card.tight { padding: .8rem 1rem; }
.card h2, .card h3 { margin-bottom: .6rem; }
.stat { display: flex; flex-direction: column; gap: .1rem; }
.stat b { font-family: var(--display); font-size: 1.85rem; font-weight: 600; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .82rem; }
a.stat { text-decoration: none; color: inherit; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.owes { color: var(--bad); font-weight: 700; }
.credit { color: var(--ok); font-weight: 700; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: .6rem 1rem; border-radius: 10px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  text-decoration: none; line-height: 1.2; white-space: nowrap; min-height: 40px;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand); border-color: #cfcbf6; }
button.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
button.ghost:hover { background: var(--brand-2); }
button.danger, .btn.danger { background: #fff; color: var(--bad); border-color: #f2c4c6; }
button.ok, .btn.ok, .btn.wa { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.wa { background: #1fa855; border-color: #1fa855; }
button.small, .btn.small { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; min-height: 34px; }
button.big, .btn.big { padding: .85rem 1.4rem; font-size: 1.05rem; min-height: 50px; }
.block { width: 100%; white-space: normal; text-align: center; }
input[type="file"] { max-width: 100%; }

label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; color: var(--ink-2); }
input, select, textarea {
  font: inherit; width: 100%; padding: .6rem .75rem; border: 1px solid #cfcde3; border-radius: 10px; background: #fff; color: var(--ink); min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c3bdfb; border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.field { margin-bottom: .85rem; }
.fields { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; min-height: 34px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; font-weight: 400; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #fafafe; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f6ff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.table-wrap table th:first-child, .table-wrap table td:first-child { padding-left: 1rem; }

.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: .14rem .55rem; border-radius: 99px; background: #eeedf6; color: var(--ink-2); white-space: nowrap; }
.pill.ok, .pill.present, .pill.active, .pill.submitted, .pill.attended, .pill.purchased, .pill.open, .pill.approved, .pill.delivered, .pill.paid { background: var(--ok-bg); color: var(--ok); }
.pill.late, .pill.pending, .pill.upcoming, .pill.in_progress, .pill.makeup, .pill.free, .pill.owes { background: var(--warn-bg); color: var(--warn); }
.pill.absent, .pill.bad, .pill.rejected, .pill.disabled, .pill.missed, .pill.cancelled { background: var(--bad-bg); color: var(--bad); }
.pill.excused { background: #e6f1fb; color: #2a5ea8; }

.alert { padding: .75rem .95rem; border-radius: 12px; background: var(--brand-2); color: var(--ink); margin-bottom: 1rem; }
.alert.warn { background: var(--warn-bg); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* his picture */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); background: var(--green); flex: none; }
.avatar.lg { width: 72px; height: 72px; border-width: 3px; }
.brand { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.brand .name { font-family: var(--display); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; line-height: 1.1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-family: system-ui, sans-serif; font-weight: 600; font-size: .72rem; letter-spacing: .03em; text-transform: none; opacity: .75; }

/* book covers */
.covers { display: flex; gap: .8rem; overflow-x: auto; scroll-snap-type: x mandatory; padding: .2rem .1rem .6rem; scrollbar-width: none; }
.covers::-webkit-scrollbar { display: none; }
.cover { flex: none; width: 112px; scroll-snap-align: start; text-align: center; color: inherit; text-decoration: none; }
.cover img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; box-shadow: 0 6px 16px rgba(0, 0, 0, .3); display: block; }
.cover span { display: block; font-family: var(--display); font-weight: 600; font-size: .8rem; letter-spacing: .03em; text-transform: uppercase; margin-top: .45rem; }

/* toast + modal */
#toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
#toast div { background: var(--night); color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; text-align: center; }
#toast div.bad { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(11, 10, 38, .5); z-index: 900; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 1rem; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; padding: 1.3rem 1.4rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }

/* login pages */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; gap: 3rem; padding: 2rem 1rem; background: var(--hero); color: #fff; }
.auth .card { width: 100%; max-width: 420px; padding: 1.6rem; color: var(--ink); }
.hero-side { max-width: 460px; }
.hero-pic { width: 190px; aspect-ratio: 384 / 328; border-radius: 22px; object-fit: cover; border: 4px solid rgba(255, 255, 255, .9); box-shadow: 0 14px 40px rgba(0, 0, 0, .45); display: block; margin-bottom: 1.1rem; }
.hero-name { font-family: var(--display); font-weight: 700; font-size: 2.6rem; line-height: 1; text-transform: uppercase; letter-spacing: .01em; margin: 0 0 .5rem; }
.hero-tag { color: #cfd0ff; font-weight: 600; margin-bottom: 1.4rem; }
.auth .covers { margin-top: .2rem; }
.tabs { display: flex; gap: .3rem; background: #efeef8; padding: .25rem; border-radius: 12px; margin-bottom: 1.1rem; }
.tabs button { flex: 1; background: transparent; color: var(--ink-2); border: 0; min-height: 38px; }
.tabs button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

.progress { height: 8px; background: #e7e6f3; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .2s; }
.spinner { width: 24px; height: 24px; border: 3px solid #dad8f3; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- phones ---------- */
@media (max-width: 860px) {
  .auth { flex-direction: column; justify-content: flex-start; gap: 1.2rem; padding: 1.4rem 1rem 2rem; }
  .hero-side { text-align: center; max-width: 420px; width: 100%; }
  .hero-pic { width: 128px; border-radius: 18px; margin: 0 auto .8rem; border-width: 3px; }
  .hero-name { font-size: 1.9rem; }
  .hero-tag { margin-bottom: .2rem; }
  .auth .hero-books { display: none; }
  .auth .books-below { display: block !important; width: 100%; max-width: 420px; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  input, select, textarea { font-size: 16px; } /* stops iPhone from zooming into fields */
  .card { padding: .95rem 1rem; border-radius: 14px; }
  h1 { font-size: 1.5rem; }
  .grid, .grid.two { grid-template-columns: 1fr; }
  .grid.stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat b { font-size: 1.55rem; }
  .fields { grid-template-columns: 1fr; }
  /* dialogs slide up from the bottom like a phone sheet */
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding: 1.1rem 1rem calc(1.1rem + env(safe-area-inset-bottom)); }
  .modal-foot { position: sticky; bottom: calc(-1.1rem - env(safe-area-inset-bottom)); background: #fff; padding: .7rem 0 .2rem; margin-bottom: -.2rem; }
  .modal-foot > * { flex: 1; }
  .cover { width: 104px; }
}
