/* JJKCC Design Tokens & Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --navy: #0f1f3d;
  --navy-light: #1a3260;
  --navy-muted: rgba(255, 255, 255, 0.08);
  --amber: #f59e0b;
  --amber-light: #fcd34d;
  --amber-pale: #fffbeb;
  --surface: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --present: #10b981;
  --absent: #ef4444;
  --low: #f59e0b;
  --sidebar-w: 230px;
  --topbar-h: 56px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--navy-muted);
}

.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.sidebar-brand span {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
}

.sidebar-section-label {
  color: rgba(255, 255, 255, .4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 16px 16px 6px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, .75);
  padding: 9px 16px;
  text-decoration: none;
  font-size: 13.5px;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: var(--navy-muted);
  color: #fff;
}

.sidebar nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--amber);
  border-radius: 0 3px 3px 0;
}

.sidebar nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Topbar ───────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title span {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 8px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy-light);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text);
}

/* ── Main content ─────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px 28px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

/* ── Stat cards ───────────────────────────────────────────────────── */
.stat-card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}

.btn-primary:hover {
  background: var(--navy-light);
}

.btn-amber {
  background: var(--amber);
  color: #000;
}

.btn-amber:hover {
  background: var(--amber-light);
}

.btn-success {
  background: var(--present);
  color: #fff;
}

.btn-danger {
  background: var(--absent);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--surface);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(15, 31, 61, .08);
}

.form-control.error {
  border-color: var(--absent);
}

.form-error {
  color: var(--absent);
  font-size: 12px;
  margin-top: 4px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.form-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ── Tables ───────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--navy);
  color: #fff;
  padding: 11px 14px;
  font-size: 13px;
  text-align: left;
}

td {
  padding: 10px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8fafc;
}

.table-hover tbody tr {
  transition: background-color 0.15s ease;
}

.table-hover tbody tr:hover td {
  background-color: var(--surface);
}

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.badge-present {
  background: #d1fae5;
  color: #065f46;
}

.badge-absent {
  background: #fee2e2;
  color: #991b1b;
}

.badge-low {
  background: #fef3c7;
  color: #92400e;
}

.badge-navy {
  background: #dbeafe;
  color: #1e40af;
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

/* ── Flash messages ───────────────────────────────────────────────── */
.flash {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flash-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.flash-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.flash-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ── Circle Progress ─────────────────────────────────────────────── */
.circle-progress {
  position: relative;
  display: inline-block;
}

.circle-progress svg {
  transform: rotate(-90deg);
}

.circle-progress .pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

/* ── Auth layout ──────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: 100%;
  padding: 48px 40px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Student layout ───────────────────────────────────────────────── */
.student-topnav {
  background: var(--navy);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.student-topnav .brand {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.student-topnav nav a {
  color: rgba(255, 255, 255, .75);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.student-topnav nav a:hover,
.student-topnav nav a.active {
  background: var(--navy-muted);
  color: #fff;
}

.student-content {
  max-width: 100%;
  margin: 0 auto;
  padding: 28px 20px;
}

/* ── Bottom nav (mobile student) ─────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 200;
}

.bottom-nav a,
.bottom-nav form {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bottom-nav a {
  padding: 10px 4px;
  text-decoration: none;
  font-size: 10px;
  color: var(--text-muted);
}

.bottom-nav a.active {
  color: var(--navy);
}

.bottom-nav a svg,
.bottom-nav-button svg {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
}

.bottom-nav-button {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  min-width: 0;
}

.bottom-nav-button:hover {
  color: var(--navy);
}

.bottom-nav-logout {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.bottom-nav-logout button {
  padding: 10px 4px;
  font-size: 10px;
  color: var(--text-muted);
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.bottom-nav-logout button:hover {
  color: var(--navy);
}

/* ── Page header ──────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.page-header .sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    left: 0;
  }

  .hamburger {
    display: flex;
  }

  .form-grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
    gap: 8px;
  }

  .topbar-role {
    display: none;
  }

  .student-topnav nav {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .student-content {
    padding-bottom: 80px;
  }

  /* iOS Safari auto-zooms focused inputs under 16px; also bump touch target height */
  .form-control {
    font-size: 16px;
    padding: 11px 13px;
  }

  .page-header {
    flex-wrap: wrap;
    gap: 12px;
  }
}

/* ── Print styles ──────────────────────────────────────────────── */
@media print {

  .sidebar,
  .topbar,
  .hamburger,
  .bottom-nav,
  .btn,
  form,
  [data-print],
  [data-confirm],
  .flash,
  .page-header>div:last-child {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }

  table {
    font-size: 11px !important;
  }

  th {
    background: #333 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .page-header {
    margin-bottom: 12px !important;
  }

  .page-header h2 {
    font-size: 16px !important;
  }

  body {
    font-size: 12px !important;
    background: #fff !important;
  }

  @page {
    margin: 15mm;
  }
}

/* ── Utility: Spinners ────────────────────────────────────────────── */
.spinner-sm {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}

/* ── Photo zoom-on-click (student profile pictures) ────────────────── */
.zoomable-photo {
  cursor: zoom-in;
}

.photo-zoom-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.photo-zoom-overlay.open {
  display: flex;
}

.photo-zoom-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  object-fit: contain;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}