/* ============================================================
   LDCE Chemical Department Portal — STYLES (mobile-first)
   ============================================================ */

:root {
  --teal:        #0e7c86;
  --teal-dark:   #0a5b63;
  --teal-light:  #e6f4f5;
  --navy:        #16314a;
  --green:       #2e9e5b;
  --red:         #d9534f;
  --amber:       #e0a106;
  --bg:          #f4f6f8;
  --card:        #ffffff;
  --line:        #e2e8ee;
  --text:        #1f2d3d;
  --muted:       #6b7b8c;
  --radius:      14px;
  --shadow:      0 2px 10px rgba(22,49,74,.08);
  --shadow-lg:   0 8px 28px rgba(22,49,74,.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
}

#app {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  background: var(--bg); position: relative; padding-bottom: 84px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; box-shadow: var(--shadow);
}
.topbar .back {
  background: rgba(255,255,255,.14); border: none; color: #fff; width: 34px; height: 34px;
  border-radius: 9px; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; flex: 1; min-width: 0; }
.topbar h1 .sub { font-size: 12px; opacity: .8; font-weight: 400; display:block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logout {
  background: var(--red); border: none; color: #fff; padding: 8px 13px; border-radius: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer; flex: none;
}
.topbar .logout:active { background: #b3322e; }

/* ---------- Content ---------- */
.page { padding: 16px; animation: fade .18s ease; }
/* opacity-only (no transform) so fixed children like the + button don't jump */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.card.tap { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.card.tap:active { transform: scale(.99); box-shadow: var(--shadow-lg); }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Menu tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tile { display: flex; align-items: center; gap: 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .1s; }
.tile:active { transform: scale(.985); }
.tile .ic { width: 46px; height: 46px; border-radius: 12px; flex: none; display: flex;
  align-items: center; justify-content: center; font-size: 22px; background: var(--teal-light); color: var(--teal-dark); }
.tile .t-main { font-weight: 600; font-size: 15px; }
.tile .t-sub  { font-size: 12.5px; color: var(--muted); }
.tile .chev { margin-left: auto; color: var(--muted); font-size: 20px; }

/* ---------- Attendance ---------- */
.att-pct { font-weight: 700; font-size: 15px; }
.bar { height: 8px; border-radius: 6px; background: #eef1f4; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; border-radius: 6px; background: var(--teal); }

.subrow { padding: 10px 0; border-top: 1px dashed var(--line); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--teal-light); color: var(--teal-dark); font-weight: 600; }
.pill.lab { background: #fdeede; color: #9a6b04; }
.pill.tut { background: #eae6fb; color: #5b46b0; }

/* ---------- Status badges (tasks) ---------- */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.green { color: #1d7a3e; background: #e3f5ea; }
.badge.red   { color: #b3322e; background: #fdeaea; }
.badge.blue  { color: #1d5fb8; background: #e6effb; }

/* ---------- Collapsible ---------- */
.collapse { overflow: hidden; max-height: 0; transition: max-height .28s ease; }
.collapse.open { max-height: 1600px; }
.chev-ic { transition: transform .2s; display:inline-block; color: var(--muted); }
.chev-ic.open { transform: rotate(90deg); }

.datelist { margin-top: 10px; }
.dateitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #f7f9fb; margin-top: 6px; font-size: 13.5px; }
.dateitem .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dateitem .dot.p { background: var(--green); }
.dateitem .dot.a { background: var(--red); }

/* ---------- Forms ---------- */
label.fld { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 600; color: var(--navy); }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px;
  font-size: 16px; background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
textarea { min-height: 90px; resize: vertical; }

/* password field with eye toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-wrap .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 18px; width: 38px; height: 38px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--muted); padding: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 14px; border: none; border-radius: 12px; background: var(--teal); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 16px; }
.btn:active { background: var(--teal-dark); }
.btn.ghost { background: #fff; color: var(--teal-dark); border: 1.5px solid var(--teal); }
.btn.sm { width: auto; padding: 9px 16px; font-size: 14px; margin: 0; }
.btn.danger { background: var(--red); }
.btn.danger:active { background: #b3322e; }

/* equal-size selectable group-method buttons */
.seg-group { display: flex; gap: 10px; margin-top: 8px; }
.seg-btn { flex: 1 1 0; min-height: 66px; padding: 12px 8px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; font-weight: 600; color: var(--navy); cursor: pointer;
  text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.seg-btn small { font-weight: 400; color: var(--muted); font-size: 11px; line-height: 1.2; }
.seg-btn.sel { border-color: var(--teal); background: var(--teal-light); color: var(--teal-dark); }
.seg-btn.sel small { color: var(--teal-dark); }

/* ---------- Checkbox attendance list ---------- */
.stu-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.stu-row:last-child { border-bottom: none; }
.stu-row .checkbox { width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--line);
  flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; transition: .12s; }
.stu-row.on .checkbox { background: var(--green); border-color: var(--green); }
.stu-row .enr { font-weight: 600; font-size: 14.5px; }
.stu-row .nm  { font-size: 12.5px; color: var(--muted); }

/* ---------- Bottom nav ---------- */
.bottomnav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%;
  max-width: 480px; background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 60;
  box-shadow: 0 -2px 12px rgba(0,0,0,.05); }
.bottomnav button { flex: 1; background: none; border: none; padding: 8px 4px; margin: 6px 4px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10.5px; cursor: pointer; min-width: 0; }
.bottomnav button .ic { font-size: 21px; }
/* active section is highlighted with a grey pill so you can see where you are */
.bottomnav button.active { color: var(--teal-dark); background: #e7ebef; font-weight: 600; }
.bottomnav button .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- Login / home ---------- */
.home-hero { min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 28px; text-align: center; background: linear-gradient(160deg, var(--navy), var(--teal-dark)); color: #fff; }
.home-hero .logo { width: 84px; height: 84px; border-radius: 22px; background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center; font-size: 42px; margin-bottom: 18px; border: 1px solid rgba(255,255,255,.2); }
.home-hero h1 { font-size: 22px; margin: 0 0 4px; }
.home-hero p { opacity: .85; font-size: 14px; margin: 0 0 30px; }
.home-hero .choice { width: 100%; max-width: 340px; }
.home-hero .choice button { width: 100%; padding: 18px; border-radius: 14px; border: none; margin-bottom: 14px;
  font-size: 17px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 14px; justify-content: center; }
.choice .stu { background: #fff; color: var(--navy); }
.choice .fac { background: rgba(255,255,255,.15); color: #fff; border: 1.5px solid rgba(255,255,255,.4); }

/* single login card */
.login-card { background: #fff; color: var(--text); width: 100%; max-width: 360px;
  border-radius: 16px; padding: 20px; box-shadow: var(--shadow-lg); text-align: left; }
.login-hint { opacity: .82; font-size: 12.5px; margin-top: 18px; max-width: 340px; }

.login-wrap { padding: 24px; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.login-wrap .lhead { text-align: center; margin-bottom: 8px; }
.login-wrap .lhead .ic { font-size: 40px; }
.login-wrap h2 { text-align: center; margin: 4px 0 2px; color: var(--navy); }
.login-wrap .hint { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.err { background: #fdeaea; color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-top: 12px; display: none; }
.err.show { display: block; }

/* ---------- Sem chooser (vertical) ---------- */
.sem-list { display: flex; flex-direction: column; gap: 12px; }
.sem-list button { padding: 18px 20px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff;
  font-size: 17px; font-weight: 700; color: var(--navy); cursor: pointer; text-align: left;
  display: flex; align-items: center; justify-content: space-between; }
.sem-list button:active { border-color: var(--teal); background: var(--teal-light); }
.sem-list button .chev { color: var(--muted); font-weight: 400; }

/* ---------- Floating add button ---------- */
.fab { position: fixed; bottom: 96px; left: 50%; transform: translateX(calc(-50% + 175px));
  width: 56px; height: 56px; border-radius: 50%; background: var(--teal); color: #fff; border: none;
  font-size: 30px; box-shadow: var(--shadow-lg); cursor: pointer; z-index: 65; display: flex; align-items: center; justify-content: center; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .ic { font-size: 40px; opacity: .4; }
.tag-link { color: var(--teal); text-decoration: none; font-weight: 600; word-break: break-all; }
.note { background: #fff8e6; border: 1px solid #f3e3b3; color: #8a6d12; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.marks-input { width: 76px; text-align: center; padding: 9px; }
.grade-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.grade-row:last-child { border-bottom: none; }
.icon-btn { background: var(--teal-light); border: none; width: 38px; height: 38px; border-radius: 10px; color: var(--teal-dark); font-size: 16px; cursor: pointer; flex: none; }
.icon-btn.del { background: #fdeaea; color: var(--red); }

.xtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.xtable th, .xtable td { border: 1px solid var(--line); padding: 4px 4px; text-align: left; }
.xtable th { background: var(--teal-light); color: var(--teal-dark); }
.xtable td input { border: none; padding: 7px 6px; border-radius: 0; font-size: 13px; }
.xtable td input:focus { outline: 1.5px solid var(--teal); }
.xtable td.x { width: 34px; text-align: center; }
.xscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }

.toast { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); background: var(--navy);
  color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; z-index: 200; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; max-width: 90%; }
.toast.show { opacity: 1; }

/* "Saving…" busy overlay */
.busy { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center;
  background: rgba(22,49,74,.28); }
.busy.show { display: flex; }
.busy-box { background: #fff; color: var(--navy); padding: 16px 22px; border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 12px; }
.spin { width: 20px; height: 20px; border: 3px solid var(--teal-light); border-top-color: var(--teal);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 700px) and (max-width: 899px) { #app { box-shadow: 0 0 0 1px var(--line); } }

/* ============================================================
   DESKTOP / LAPTOP LAYOUT (>= 900px)
   Same app, rearranged: full width, header on top, student nav
   becomes a left sidebar, content is wider & centred, menus 2-col.
   ============================================================ */
@media (min-width: 900px) {
  body { background: #e9edf1; }
  #app { max-width: none; padding-bottom: 0; min-height: 100vh; background: var(--bg); }
  .toast { bottom: 28px; }

  /* shared desktop polish */
  .topbar { padding: 14px 30px; }
  .topbar h1 { font-size: 18px; }
  .topbar .logout { padding: 9px 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .login-card { max-width: 380px; }

  /* ---------- STUDENT: left-sidebar dashboard ----------
     (these screens contain a .bottomnav; faculty/admin don't) */
  #app:has(.bottomnav) {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-areas: "nav header" "nav main";
    align-items: start;
  }
  #app:has(.bottomnav) .topbar { grid-area: header; position: sticky; top: 0; z-index: 40; }
  #app:has(.bottomnav) .page   { grid-area: main; width: 100%; max-width: 1040px; margin: 0 auto; padding: 26px 34px; }
  #app:has(.bottomnav) .bottomnav {
    grid-area: nav; position: sticky; top: 0; left: auto; right: auto; bottom: auto;
    height: 100vh; width: auto; max-width: none; transform: none;
    flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 6px;
    border-top: none; border-right: 1px solid var(--line); box-shadow: none; background: #fff; padding: 16px 12px;
  }
  #app:has(.bottomnav) .bottomnav button {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
    width: 100%; padding: 13px 14px; font-size: 14.5px; border-radius: 10px; margin: 0;
  }
  #app:has(.bottomnav) .bottomnav button .ic { font-size: 20px; }
  #app:has(.bottomnav) .bottomnav button.active { background: var(--teal-light); color: var(--teal-dark); }
  #app:has(.bottomnav) .fab { left: auto; right: 40px; bottom: 40px; transform: none; }

  /* ---------- FACULTY / ADMIN: centred content ---------- */
  #app:not(:has(.bottomnav)) .topbar { position: sticky; top: 0; z-index: 40; }
  #app:not(:has(.bottomnav)) .page { max-width: 920px; margin: 0 auto; padding: 26px 30px; }
}
