/* ============================================================
   Course Folder Portal — Styles
   ============================================================ */
:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --border: #d8e1ec;
  --text: #172033;
  --text-muted: #637083;
  --primary: #082d5b;
  --primary-2: #0f477f;
  --accent: #0f477f;
  --gold: #f4bd22;
  --gold-2: #d9a70d;
  --gold-soft: #fff3c2;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(8, 45, 91, .07), 0 12px 30px rgba(8, 45, 91, .08);
  --shadow-lg: 0 22px 48px rgba(8, 45, 91, .17);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, #061f3f 0%, #0a376b 55%, #0f477f 100%);
  color: #fff;
  padding: 26px 24px 22px;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.uni-logo {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(255,255,255,.65);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  flex-shrink: 0;
  overflow: hidden;
}
.uni-logo img { width: 100%; height: 100%; object-fit: contain; }
.header-titles h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: .3px; }
.header-titles .sub { font-size: .95rem; opacity: .92; margin-top: 2px; }
.header-titles .sub2 { font-size: .8rem; opacity: .75; margin-top: 1px; }
.header-right {
  margin-left: auto;
  text-align: right;
  font-size: .8rem;
  opacity: .95;
}
.drive-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.35);
  padding: 7px 14px;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  font-size: .8rem;
  transition: background .18s;
}
.drive-badge:hover { background: rgba(255,255,255,.26); }
.drive-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #f4bd22; }
.header-right .semester-label { margin-top: 7px; font-weight: 600; font-size: .85rem; }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 22px 24px 60px; }

/* ---------- Curriculum CTA ---------- */
.curriculum-cta {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #061f3f, #0f477f);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 16px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.curriculum-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.curriculum-cta .cta-icon { font-size: 1.8rem; flex-shrink: 0; }
.curriculum-cta .cta-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.curriculum-cta .cta-text strong { font-size: 1rem; letter-spacing: .2px; }
.curriculum-cta .cta-text small { font-size: .78rem; opacity: .85; }
.curriculum-cta .cta-arrow { font-size: 1.4rem; opacity: .9; }
.curriculum-cta.cta-blue { background: linear-gradient(135deg, #0f477f, #2f6ba3); }
.curriculum-cta.cta-amber { background: linear-gradient(135deg, #f4bd22, #d9a70d); color: var(--primary); }

/* ---------- Stats row ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Server banner ---------- */
.server-banner {
  background: rgba(220, 38, 38, .08);
  border: 1px solid rgba(220, 38, 38, .3);
  color: var(--danger);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: .86rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}
.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .92rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244,189,34,.3); }
.search-box .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.toolbar select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: .9rem;
  color: var(--text);
  cursor: pointer;
}

/* ---------- Batch tabs ---------- */
.batch-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.batch-tab {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all .15s;
  display: flex; align-items: center; gap: 8px;
}
.batch-tab .count {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .72rem;
  padding: 1px 8px;
  color: var(--text-muted);
}
.batch-tab:hover { border-color: var(--accent); color: var(--text); }
.batch-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.batch-tab.active .count { background: rgba(255,255,255,.2); border-color: transparent; color: #fff; }

/* ---------- Batch section ---------- */
.batch-section { margin-bottom: 34px; }
.batch-heading {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--batch-bg, var(--surface-2));
  border: 1px solid var(--batch-border, var(--border));
  border-left: 6px solid var(--batch-color, var(--accent));
  box-shadow: var(--shadow);
}
.batch-heading .bar { display: none; }
.batch-heading h2 { font-size: 1.15rem; color: var(--batch-color, var(--text)); }
.batch-heading .sem { color: var(--text-muted); font-size: .85rem; font-weight: 600; }

/* ---------- Course grid ---------- */
.course-grid {
  display: grid;
  gap: 18px 18px;
  align-items: stretch;
  grid-template-columns: 1fr;
}
.course-card {
  --course-accent: #d30000;
  --course-accent-soft: #ff1818;
  --course-title-accent: #d30000;
  --course-left-shift: -78px;
  --course-text: #2f3439;
  --course-muted: #6d747c;
  background: linear-gradient(180deg, #ffffff 0%, #f2f5f5 100%);
  border: 5px solid var(--course-accent);
  border-radius: 26px;
  padding: 14px 18px 12px 106px;
  box-shadow: 0 10px 18px rgba(22, 43, 58, .12);
  color: var(--course-text);
  cursor: pointer;
  transition: transform .16s, box-shadow .16s, border-color .16s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: visible;
  min-height: 148px;
  height: 100%;
}
.course-card.is-complete {
  --course-accent: #059669;
  --course-accent-soft: #17b26a;
  --course-title-accent: #059669;
}
.course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(22, 43, 58, .16);
}
.course-card:focus-visible {
  outline: 3px solid rgba(8, 45, 91, .32);
  outline-offset: 3px;
}
.course-card-tab {
  position: absolute;
  top: -5px;
  left: 28px;
  width: 72px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--course-accent-soft) 0%, var(--course-accent) 100%);
  color: #ffffff;
  border-radius: 0 0 2px 2px;
  box-shadow: 0 8px 13px rgba(22, 43, 58, .14);
  font-size: 1.62rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: .02em;
}
.course-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.course-card-head > div { min-width: 0; }
.course-kicker {
  color: #16a6d6;
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.course-title {
  color: var(--course-title-accent);
  font-size: .86rem;
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: 0;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.course-title-type {
  color: inherit;
  white-space: nowrap;
}
.course-card-body {
  display: grid;
  gap: 3px;
  margin-left: var(--course-left-shift);
  padding-top: 3px;
}
.course-line {
  display: grid;
  grid-template-columns: minmax(82px, .3fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}
.course-line span {
  color: var(--course-muted);
  font-size: .82rem;
  font-weight: 400;
}
.course-line strong {
  color: var(--course-text);
  font-size: .92rem;
  font-weight: 400;
  line-height: 1.22;
  overflow-wrap: anywhere;
}
.course-card .course-line:last-child strong {
  color: var(--course-accent);
  font-size: 1rem;
}
.course-card-footer {
  margin-top: auto;
  margin-left: var(--course-left-shift);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--course-muted);
  font-size: .86rem;
  font-weight: 400;
}
.progress-counter {
  color: var(--course-text);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: .02em;
}
.course-progress {
  margin-left: var(--course-left-shift);
  height: 7px;
  background: rgba(47, 52, 57, .16);
  border-radius: 999px;
  overflow: hidden;
}
.course-progress span {
  display: block;
  height: 100%;
  background: var(--course-accent);
  border-radius: inherit;
}

@media (min-width: 720px) {
  .course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .course-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Folder workflow (N/A, remove, certify) ---------- */
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .74rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.na-badge {
  font-size: .64rem; font-weight: 800; letter-spacing: .5px;
  background: rgba(244,189,34,.2); color: #7a5c00;
  padding: 2px 8px; border-radius: 999px; vertical-align: middle;
}
.na-row {
  display: flex; align-items: center; gap: 8px;
  font-size: .76rem; color: var(--text-muted);
  margin-top: 6px; cursor: pointer;
}
.na-row input { accent-color: var(--gold-2); width: 15px; height: 15px; }
.btn-del-file { padding: 3px 9px; font-size: .7rem; }
.certify-box {
  margin-top: 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--surface-2);
}
.certify-box.done { border: 2px solid rgba(5,150,105,.4); background: rgba(5,150,105,.06); }
.certify-box .cb-title { font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.certify-box.done .cb-title { color: var(--ok); }
.certify-box .cb-note { font-size: .82rem; color: var(--text-muted); margin-bottom: 10px; }
.certify-box .cb-row { display: flex; gap: 10px; flex-wrap: wrap; }
.certify-box .cb-row input {
  flex: 1; min-width: 220px;
  padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: .9rem; background: var(--surface); color: var(--text);
}
.certify-box .cb-row input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244,189,34,.3); }
.certify-box .cb-row input:disabled { opacity: .55; }
.certify-box .cb-err { color: var(--danger); font-size: .8rem; font-weight: 600; min-height: 1.1em; margin-top: 8px; }

/* ---------- Modal (course detail) ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 860px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .22s ease;
}
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  padding: 22px 26px 18px;
  background: linear-gradient(135deg, #061f3f, #0a376b);
  color: #fff;
  position: relative;
}
.modal-header h3 { font-size: 1.2rem; line-height: 1.35; padding-right: 40px; }
.modal-header .meta { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.modal-header .chip { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.15);
  border: none; color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background .15s;
}
.modal-close:hover { background: rgba(255,255,255,.3); }

.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 26px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
  color: var(--text-muted);
}
.modal-toolbar .btn-drive {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s;
}
.modal-toolbar .btn-drive:hover { background: var(--primary-2); }
.modal-toolbar .btn-drive.disabled { background: #94a3b8; cursor: not-allowed; }

.checklist { padding: 10px 26px 26px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 10px;
  border-bottom: 1px solid var(--border);
}
.check-item:last-child { border-bottom: none; }
.check-item .item-icon { font-size: 1.25rem; width: 34px; text-align: center; flex-shrink: 0; }
.check-item .item-body { flex: 1; min-width: 0; }
.check-item .item-title { font-weight: 600; font-size: .92rem; }
.check-item .item-note { font-size: .76rem; color: var(--text-muted); }
.check-item .item-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
/* 3+ buttons (e.g. the four batch templates + Upload) — stack vertically instead of
   spilling past the right margin */
.check-item .item-actions:has(> :nth-child(3)) {
  flex-direction: column;
  align-items: stretch;
  max-width: none;
}
.check-item .item-actions:has(> :nth-child(3)) .btn { justify-content: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--primary); font-weight: 800; }
.btn.primary:hover { background: var(--gold-2); color: var(--primary); }
.btn.primary.is-uploaded { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.primary.is-uploaded:hover { background: #047857; border-color: #047857; color: #fff; }
.btn.muted { opacity: .55; cursor: not-allowed; }
.btn.fmt-ok { color: var(--primary-2); font-weight: 800; border-color: rgba(244,189,34,.8); background: rgba(244,189,34,.07); }
.btn.fmt-ok:hover { background: rgba(244,189,34,.18); color: var(--primary); border-color: var(--gold); }
.btn.muted:hover { border-color: var(--border); color: var(--text); }

.item-status { font-size: 1.05rem; width: 26px; text-align: center; flex-shrink: 0; }

.file-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: .8rem;
  margin-top: 4px;
}
.file-row a { color: var(--primary); text-decoration: none; font-weight: 600; word-break: break-all; }
.file-row a:hover { text-decoration: underline; }
.file-row .file-meta { color: var(--text-muted); font-size: .72rem; white-space: nowrap; }

/* ---------- Admin ---------- */
.admin-login {
  display: flex;
  justify-content: center;
  padding: 60px 0;
}
.admin-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.admin-login-card h2 { margin-bottom: 8px; }
.admin-login-card p { color: var(--text-muted); font-size: .88rem; margin-bottom: 18px; }
.login-row { display: flex; gap: 10px; }
.login-row input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  outline: none;
}
.login-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244,189,34,.3); }
.login-error { color: var(--danger); font-size: .84rem; margin-top: 12px; font-weight: 600; min-height: 1.2em; }

.admin-section { margin-bottom: 36px; }
.admin-h2 { font-size: 1.1rem; margin-bottom: 10px; }
.admin-hint { color: var(--text-muted); font-size: .83rem; margin-bottom: 10px; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}
.admin-table th {
  text-align: left;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.course-row { cursor: pointer; transition: background .12s; }
.course-row:hover { background: var(--surface-2); }
.course-row .expander { width: 24px; color: var(--text-muted); font-size: .7rem; }
.subj-cell { font-weight: 600; padding-left: 12px; }
.row-warn td { color: var(--danger); }

.mini-progress {
  display: inline-block;
  width: 90px;
  height: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 8px;
}
.mini-fill { height: 100%; background: linear-gradient(90deg, var(--warn), #fbbf24); }
.mini-fill.full { background: linear-gradient(90deg, var(--gold), #ffd964); }
.mini-pct { font-size: .76rem; color: var(--text-muted); font-weight: 600; }

.detail-row td { background: var(--surface-2); padding: 14px 18px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px 22px;
}
.detail-item { padding: 6px 0; }
.detail-title { font-weight: 600; font-size: .84rem; }
.btn.danger { color: var(--danger); border-color: rgba(220,38,38,.35); padding: 4px 9px; font-size: .72rem; }
.btn.danger:hover { background: rgba(220,38,38,.08); border-color: var(--danger); color: var(--danger); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 26px 16px 34px;
  color: var(--text-muted);
  font-size: .8rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.site-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: .95rem;
}
.empty-state .big { font-size: 2.4rem; margin-bottom: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .header-right { margin-left: 0; text-align: left; }
  .check-item { flex-wrap: wrap; }
  .check-item .item-actions { width: 100%; justify-content: flex-start; padding-left: 48px; }
}

/* ---------- Print ---------- */
@media print {
  .toolbar, .batch-tabs, .site-header .header-right { display: none; }
  .course-card {
    break-inside: avoid;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
