/* ============================================================
   Exam Portal — shared theme
   Link this ONE file in your common header JSP and every page
   (dashboard included) gets the same background + card styles.

   <link rel="stylesheet" href="${pageContext.request.contextPath}/css/portal-theme.css">
   ============================================================ */

/* ---- Palette (change these to reskin the whole portal) ---- */
:root {
  --primary:        #1D4ED8;   /* buttons, headers, active links */
  --primary-hover:  #3B82F6;
  --primary-tint:   #DBEAFE;   /* light fills, selected rows */
  --page-bg:        #F1F5F9;   /* base page colour */
  --dot-color:      #CBD5E1;   /* dot-grid dots */
  --card-bg:        #FFFFFF;
  --border:         #E2E8F0;
  --text:           #0F172A;
  --text-muted:     #64748B;

  --success: #16A34A;
  --warning: #F59E0B;
  --danger:  #DC2626;

  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ---- Global reset-ish ---- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* ---- The background: applies to EVERY page ---- */
body {
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  color: var(--text);
  background-color: var(--page-bg);
  /* faint dot grid — pure CSS, no image request */
  background-image: radial-gradient(circle at 1px 1px, var(--dot-color) 1px, transparent 0);
  background-size: 18px 18px;
  background-attachment: fixed;   /* dots stay put while content scrolls */
  line-height: 1.6;
}

/* If you want a specific page (e.g. the exam-taking screen) to be
   flat white with NO dots, add class="plain" to its <body>:      */
body.plain {
  background-image: none;
  background-color: #FFFFFF;
}

/* ---- Page container ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ---- Cards (dashboard tiles, panels, forms) ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

/* Dashboard grid: auto-fits 1–4 columns by width */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

/* Stat / metric tile */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat-card .label { font-size: 13px; color: var(--text-muted); margin: 0; }
.stat-card .value { font-size: 28px; font-weight: 600; margin: 6px 0 0; color: var(--text); }

/* ---- Top navbar (optional, matches palette) ---- */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar a { color: #fff; text-decoration: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--primary-hover); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-tint); }

/* ---- Simple responsive helper ---- */
@media (max-width: 640px) {
  .container { padding: 16px 12px; }
  .card, .stat-card { padding: 16px; }
}

/* ---- Sitewide responsive baseline ----
   Pages share these class names for their forms/tables/toolbars.
   A page's own <style> block still loads after this file, so any
   page-specific media query here continues to take precedence. */

img, svg, video { max-width: 100%; }

/* Inputs inside a flex row (e.g. search bars) default to a min-width
   based on their content, which forces the row to overflow on narrow
   screens. This lets them shrink like any other flex item. */
input, select, textarea { min-width: 0; }

/* Any table falls back to horizontal scroll instead of overflowing
   the viewport (works without wrapping the table in a div). */
@media (max-width: 768px) {
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 640px) {
  .search-section form { flex-wrap: wrap; }
  .search-section input { flex: 1 1 100%; }
}

@media (max-width: 640px) {
  /* Two-column form layouts collapse to one column */
  .form-row,
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Button rows stack and go full-width for easier tapping */
  .button-group,
  .btn-container,
  .action-buttons,
  .header-actions {
    flex-direction: column;
  }

  .button-group > *,
  .btn-container > *,
  .action-buttons > *,
  .header-actions > * {
    width: 100%;
    text-align: center;
  }

  /* Page headers (title + actions side-by-side) stack instead of
     squeezing onto one row */
  .header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
    text-align: left;
  }

  /* Navbars without their own mobile rule stack instead of overflowing */
  .navbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}
