@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #2563eb;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --grey-soft: #f1f5f9;
  --bg: #f5f7fb;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #cfd8e3;
  --sidebar-bg: linear-gradient(180deg, #172554 0%, #1e3a8a 55%, #4f46e5 100%);
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow-sm: 0 8px 20px rgba(15, 23, 42, 0.06);
  --transition: 0.22s ease;
  --sidebar-width: 270px;
  --topbar-height: 76px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f6f8fc;
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ---------------------------------------------------------
   GENERIC TABLE STYLING
   Applies to #timetable, #fullTimetable, #rosterTable,
   the history table, and any other plain <table> in the app.
   Fixes: centered headers, misaligned columns, no borders.
   --------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

table thead th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #6b7280;
  background: #f9fafb;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table tbody td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
  font-size: 0.92rem;
  color: var(--text);
  vertical-align: middle;
}

table tbody tr:last-child td {
  border-bottom: none;
}

table tbody tr:hover {
  background: #e1edf6;
}

/* Radio/checkbox cells (roster table Present/Absent/OD columns)
   should be centered, not left-aligned like text columns */
table td.radio-cell {
  text-align: center;
}

table td.radio-cell input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

#app {
  min-height: 100vh;
  display: flex;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: var(--transition);
  z-index: 80;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 90;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition);
}

.sidebar.open {
  transform: translateX(0);
}

.logo {
  padding: 12px 12px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 18px;
}

.logo h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.logo small {
  display: inline-block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.75);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  transition: var(--transition);
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.main {
  flex: 1;
  margin-left: 0;
  padding: 24px;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 16px;
  z-index: 20;
  height: var(--topbar-height);
  margin-bottom: 24px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #eef2f7;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.topbar h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
}

#topbarUser {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  color: #4b5563 !important;
  font-weight: 600;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 22px;
}

.card h3 {
  margin: 0 0 16px;
  font-size: 1.02rem;
  font-weight: 800;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.info-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.value {
  font-size: 1.1rem;
  font-weight: 800;
}

.btn {
  border: none;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

input[type="date"],
input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-bar,
.mark-toolbar,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mark-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 240px;
}

.mark-field label {
  font-size: 0.84rem;
  color: #4b5563;
  font-weight: 700;
}

.mark-toolbar {
  align-items: flex-end;
}

.mark-action {
  display: flex;
  align-items: flex-end;
}

.mark-action .btn {
  width: auto;
  padding: 10px 24px;
}

@media (max-width: 860px) {
  .sidebar {
    width: min(84vw, 290px);
  }

  .main {
    padding: 14px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .search-bar,
  .mark-toolbar,
  .history-actions {
    flex-direction: column;
  }

  .roster-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .roster-head {
    display: none;
  }

  .roster-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .radio-chip,
  .chip,
  .save-attendance-btn {
    width: 100%;
  }

  .attendance-radios {
    flex-direction: column;
  }

  table {
    font-size: 0.85rem;
  }

  table thead th,
  table tbody td {
    padding: 8px 10px;
  }
}

#markRosterWrap {
  margin-top: 16px;
}

/* SIMPLE STUDENT LIST */
.roster-shell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.roster-row {
  border-bottom: 1px solid #eef2f7;
}

.roster-row:hover {
  background: #ad656b;
}

.roster-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.roster-count {
  font-size: 0.96rem;
  font-weight: 800;
}

.roster-subtext {
  font-size: 0.82rem;
  color: var(--muted);
}

.roster-bulk {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: none;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.chip-present {
  background: var(--success-soft);
  color: #166534;
}

.chip-absent {
  background: var(--danger-soft);
  color: #991b1b;
}

.chip-od {
  background: var(--warning-soft);
  color: #92400e;
}

.roster-list {
  display: flex;
  flex-direction: column;
}

.roster-head,
.roster-row {
  display: grid;
  grid-template-columns: 90px 1fr 360px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.roster-head {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 800;
  color: #6b7280;
  text-transform: uppercase;
}

.roster-row {
  border-bottom: 1px solid #eef2f7;
}

.roster-row:last-child {
  border-bottom: none;
}

.roster-roll {
  font-size: 0.88rem;
  font-weight: 700;
  color: #475569;
}

.roster-name {
  font-size: 0.94rem;
  font-weight: 700;
  color: #111827;
}

.attendance-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
}

.radio-chip input[type="radio"] {
  margin: 0;
  accent-color: var(--primary);
}

.radio-chip.present-option:has(input:checked) {
  background: var(--success-soft);
  border-color: #86efac;
  color: #166534;
}

.radio-chip.absent-option:has(input:checked) {
  background: var(--danger-soft);
  border-color: #fca5a5;
  color: #991b1b;
}

.radio-chip.od-option:has(input:checked) {
  background: var(--warning-soft);
  border-color: #fcd34d;
  color: #92400e;
}

.roster-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.save-attendance-btn {
  width: auto;
  min-height: 44px;
  padding: 0 18px;
}

.msg {
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  margin-bottom: 12px;
}

.msg-info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.msg-error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.msg-empty {
  background: #f8fafc;
  color: #64748b;
  border-color: #e5e7eb;
}

#historyList,
#historyEditWrap {
  background: #fafcff;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 16px;
  color: var(--muted);
}

/* When history/timetable tables render inside these dashed containers,
   drop the dashed border/padding so the table's own styling shows cleanly */
#historyList:has(table),
#timetable,
#fullTimetable {
  border-style: solid;
  border-color: var(--border);
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
}

@media (max-width: 1100px) {
  .info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
    width: min(84vw, 290px);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 14px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .search-bar,
  .mark-toolbar,
  .history-actions {
    flex-direction: column;
  }

  .roster-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .roster-head {
    display: none;
  }

  .roster-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .radio-chip,
  .chip,
  .save-attendance-btn {
    width: 100%;
  }

  .attendance-radios {
    flex-direction: column;
  }

  table {
    font-size: 0.85rem;
  }

  table thead th,
  table tbody td {
    padding: 8px 10px;
  }
}
/* =========================================================
   MY CLASS STATUS — Faculty Dashboard "Today's Timetable"
   status pills + per-class actions (added for My Class
   status feature; does not change any existing rules above)
   ========================================================= */
.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-green  { background: var(--success-soft); color: #166534; }
.status-red    { background: var(--danger-soft);  color: #991b1b; }
.status-grey   { background: var(--grey-soft);    color: var(--muted); }
.status-orange { background: var(--warning-soft); color: #92400e; }
.status-blue   { background: var(--info-soft);    color: #075985; }

.myclass-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.myclass-actions .btn {
  width: auto;
  min-height: 34px;
  padding: 6px 14px;
  font-size: 0.82rem;
}

.myclass-actions .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--grey-soft);
  color: var(--muted);
}

.myclass-actions .btn-overdue {
  background: var(--warning);
}

.btn-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: underline;
}

/* =========================================================
   RESPONSIVE PASS — audited against dashboard.php + app.js
   Adds: scrollable-table min-width + edge fade, reminder/
   covering banner row wrapping, topbar collision fix at very
   narrow widths, chip/button wrap safety, fluid type.
   Everything above this block is untouched.
   ========================================================= */

/* ---- Scrollable table wrapper -----------------------------
   app.js now wraps every dynamically-rendered table (roster,
   test roster, IA roster, edit roster, history tables) in
   <div class="table-scroll" style="overflow-x:auto;">, and
   dashboard.php does the same for #timetable/#fullTimetable.
   Without a min-width the table just shrinks to fit instead of
   scrolling, crushing columns — this forces the scroll to
   actually trigger, then adds a soft edge-fade so users notice
   there's more to scroll. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  scrollbar-width: thin;
}

.table-scroll table {
  min-width: 560px;
}

#rosterTable,
#editRosterTable {
  min-width: 480px;
}

#testRosterTable,
#iaRosterTable {
  min-width: 640px;
}

#timetable,
#fullTimetable {
  min-width: 720px;
}

@media (max-width: 768px) {
  .table-scroll {
    -webkit-mask-image: linear-gradient(
      to right,
      transparent 0,
      #000 12px,
      #000 calc(100% - 24px),
      transparent 100%
    );
    mask-image: linear-gradient(
      to right,
      transparent 0,
      #000 12px,
      #000 calc(100% - 24px),
      transparent 100%
    );
  }
}

/* ---- Unmarked-reminder banner + "covering today" rows -----
   The reminder <li> is display:flex;justify-content:space-between
   with the "Mark now" btn-link inline. On narrow screens a long
   class/subject string had nowhere to shrink, so it pushed the
   button off the right edge instead of wrapping under it. */
#unmarkedReminderBox li {
  flex-wrap: wrap;
}

#unmarkedReminderBox li > span:first-child {
  flex: 1 1 220px;
  min-width: 0;
  word-break: break-word;
}

#unmarkedReminderBox li .btn-link,
#classesCoveringBox li .btn-link,
#mySubstituteClassesBox li .btn-link {
  white-space: nowrap;
}

#classesCoveringBox li,
#mySubstituteClassesBox li {
  word-break: break-word;
}

/* ---- Buttons / chips wrap safety --------------------------
   Toolbars already use flex-wrap in their inline styles; this
   just guarantees .btn/.chip never force a container wider than
   the viewport when several sit on one line. */
.btn,
.chip,
.btn-link {
  max-width: 100%;
  white-space: normal;
}

/* ---- Topbar collision at very narrow widths ---------------
   #pageTitle + #topbarUser can collide with the menu toggle
   below ~400px; let the title truncate instead of wrapping the
   whole bar to two lines, and shrink/hide the user pill's ID
   portion on the smallest phones. */
.topbar {
  min-width: 0;
}

.topbar h2 {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  #topbarUser {
    padding: 8px 10px;
    font-size: 0.78rem;
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .info-box {
    padding: 14px;
  }

  .value {
    font-size: 1rem;
  }

  .card {
    padding: 16px;
  }

  .roster-toolbar .roster-bulk .chip,
  #markContent .chip {
    flex: 1 1 auto;
  }
}

/* ---- Fluid type for headings/table text --------------------
   Keeps text from just shrinking the layout at small sizes;
   scales smoothly between the 480px and 1024px breakpoints. */
.card h3 {
  font-size: clamp(0.94rem, 2.6vw, 1.02rem);
}

.topbar h2 {
  font-size: clamp(1.05rem, 3.4vw, 1.25rem);
}

table thead th,
table tbody td {
  font-size: clamp(0.78rem, 2vw, 0.92rem);
}

/* =========================================================
   MARK-ENTRY NUMBER INPUTS — remove the spin/increment arrows
   Both the Unit Test grid (.test-co-input) and the Internal
   Assessment grid (.co-input) use type="number" for each CO
   mark. The native up/down spinner steals clicks near the
   right edge of a narrow (60px) cell and bumps the value by
   accident, so a teacher typing a mark and pressing Tab to move
   to the next column would sometimes see it silently increment
   instead. Hiding the spinner (and the matching wheel-blur in
   app.js's preventMarkInputWheelChange()) leaves typing + Tab
   as the only way to change or move between mark cells.
   ========================================================= */
.co-input::-webkit-outer-spin-button,
.co-input::-webkit-inner-spin-button,
.test-co-input::-webkit-outer-spin-button,
.test-co-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.co-input,
.test-co-input {
  -moz-appearance: textfield; /* Firefox */
  appearance: textfield;
}
/* Always show hamburger + collapsible sidebar, on every screen size */
.menu-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.sidebar {
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.sidebar.open {
  transform: translateX(0);
}

.main {
  margin-left: 0 !important;
  width: 100% !important;
}