/* ── Portal CSS — School Result Portal ─────────────────────────────────── */

:root {
  --primary:       #6B2E2E;
  --primary-dark:  #521f1f;
  --primary-light: #8a3d3d;
  --secondary:     #B08974;
  --secondary-light: #C9A898;
  --bg:            #F5F1EC;
  --bg-card:       #FFFFFF;
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --text-dark:     #2C2C2C;
  --text-muted:    #7A7A7A;
  --border:        #E2D9D0;
  --success:       #2E7D32;
  --warning:       #E65100;
  --danger:        #B71C1C;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(107,46,46,0.10);
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  margin: 0;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .nav-section,
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .topbar-title { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1.2rem 1.25rem;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.nav-section {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary-light);
  padding: 0.85rem 0.75rem 0.25rem;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  color: rgba(255,255,255,0.82);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.sidebar .nav-link i { font-size: 1rem; min-width: 1.1rem; }

.sidebar-footer {
  padding: 0.75rem 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.15);
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(107,46,46,0.07);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--bg); }

.topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
  color: var(--primary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed ~ .main-content { margin-left: 68px; }

.page-content {
  padding: 1.75rem;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(107,46,46,0.14); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
  flex-shrink: 0;
}

.stat-card.secondary { border-left-color: var(--secondary); }
.stat-card.secondary .stat-icon { color: var(--secondary); }

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-secondary-custom {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-portal thead th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: none;
}

.table-portal tbody tr:hover { background: rgba(176,137,116,0.08); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 0.2rem rgba(176,137,116,0.25);
}

.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
}

/* ── Role badges ─────────────────────────────────────────────────────────── */
.role-badge {
  font-size: 0.72rem;
  padding: 0.3em 0.7em;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-admin { background: var(--primary); color: #fff; }
.role-teacher { background: var(--secondary); color: #fff; }
.role-parent { background: #2E7D32; color: #fff; }

/* ── Grade badges ────────────────────────────────────────────────────────── */
.grade-badge {
  display: inline-block;
  width: 36px; height: 36px;
  border-radius: 50%;
  line-height: 36px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}
.grade-A { background: #E8F5E9; color: var(--success); }
.grade-B { background: #E3F2FD; color: #1565C0; }
.grade-C { background: #FFF3E0; color: var(--warning); }
.grade-D { background: #FFEBEE; color: var(--danger); }
.grade-F { background: #FCE4EC; color: #880000; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.login-logo {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--primary);
  margin: 0 auto 1.5rem;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

/* ── Report card print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0; }

  /* Prevent table-responsive from clipping columns */
  .table-responsive { overflow: visible !important; }

  /* Compact info header */
  #reportCard .card-body { padding: 0.75rem; }
  #reportCard .row.mb-3 { margin-bottom: 0.5rem !important; }
  #reportCard .p-2 { padding: 0.25rem 0.4rem !important; }
  #reportCard .fw-bold.fs-4 { font-size: 1rem !important; }
  #reportCard h5.mb-3 { margin-bottom: 0.4rem !important; font-size: 0.9rem; }

  /* Compact subject results table so all 11 columns fit on one page */
  #reportCard .table-portal {
    font-size: 0.68rem;
    width: 100%;
    table-layout: fixed;
  }
  #reportCard .table-portal th,
  #reportCard .table-portal td {
    padding: 0.18rem 0.22rem;
    vertical-align: middle;
    white-space: nowrap;
  }
  /* Let subject name wrap so numeric columns stay narrow */
  #reportCard .table-portal td:nth-child(2),
  #reportCard .table-portal th:nth-child(2) {
    white-space: normal;
    word-break: break-word;
    width: 18%;
  }
  /* Flatten grade badge — circles waste space in print */
  #reportCard .grade-badge {
    display: inline;
    width: auto;
    height: auto;
    border-radius: 3px;
    line-height: 1.4;
    padding: 1px 4px;
    font-size: 0.68rem;
  }
}

/* ── Overlay (mobile sidebar backdrop) ───────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1049;
}
.sidebar-overlay.active { display: block; }

/* ── Responsive — tablet & mobile (< 992px) ─────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    z-index: 1050;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: var(--sidebar-w); } /* ignore collapsed on mobile */
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 1.1rem 1rem; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.5rem; }
  .topbar { padding: 0 1rem; gap: 0.5rem; }
}

/* ── Responsive — small phones (< 576px) ────────────────────────────────── */
@media (max-width: 575.98px) {
  .topbar-user .fw-semibold { display: none; }
  .page-header h1 { font-size: 1.1rem; }
  .page-content { padding: 0.85rem 0.75rem; }

  /* Login / forgot-password card: reduce padding so form fits comfortably */
  .login-card { padding: 1.5rem 1.25rem; border-radius: 10px; }
  .login-logo { width: 52px; height: 52px; font-size: 1.6rem; margin-bottom: 1rem; }
}
