/* OSCE Nexus v2 – responsive stylesheet */
:root {
  --c-bg: #f4f6f8;
  --c-card: #ffffff;
  --c-text: #1f2933;
  --c-muted: #6b7280;
  --c-border: #e2e8f0;
  --c-primary: #2563eb;
  --c-primary-dark: #1d4ed8;
  --c-success: #16a34a;
  --c-danger: #dc2626;
  --c-warning: #d97706;
  --c-info: #0ea5e9;
  --c-topbar: #1e293b;
  --c-topbar-text: #f1f5f9;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 25px rgba(15,23,42,.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--c-topbar);
  color: var(--c-topbar-text);
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar .brand small { display: block; font-weight: 400; font-size: 11px; opacity: 0.75; }
.topbar .user-area { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .user-area a { color: var(--c-topbar-text); text-decoration: none; opacity: 0.9; }
.topbar .user-area a:hover { opacity: 1; text-decoration: underline; }

/* ---------- Nav ---------- */
.navbar {
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
  padding: 6px 12px;
  overflow-x: auto;
  white-space: nowrap;
}
.navbar a {
  display: inline-block;
  padding: 8px 12px;
  margin: 2px 2px;
  color: var(--c-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
}
.navbar a:hover { background: #eef2f7; }
.navbar a.active { background: var(--c-primary); color: #fff; }
.navbar a.danger { background: #fef2f2; color: var(--c-danger); }
.navbar a.danger:hover { background: var(--c-danger); color: #fff; }

/* ---------- Layout ---------- */
.container {
  max-width: 1200px;
  margin: 20px auto;
  background: var(--c-card);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.container.wide { max-width: 1400px; }
h1, h2, h3, h4 { margin-top: 0; }
hr { border: none; border-top: 1px solid var(--c-border); margin: 16px 0; }

/* ---------- Forms ---------- */
label { display: inline-block; margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; min-height: 60px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 14px;
  background: #f1f5f9;
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #e2e8f0; }
.btn-primary   { background: var(--c-primary);  color: #fff; border-color: var(--c-primary); }
.btn-primary:hover   { background: var(--c-primary-dark); }
.btn-success   { background: var(--c-success);  color: #fff; border-color: var(--c-success); }
.btn-danger    { background: var(--c-danger);   color: #fff; border-color: var(--c-danger); }
.btn-warning   { background: var(--c-warning);  color: #fff; border-color: var(--c-warning); }
.btn-live      { background: var(--c-danger);   color: #fff; border-color: var(--c-danger); font-weight: 700; }
.btn-sm        { padding: 4px 10px; font-size: 13px; }
.btn-lg        { padding: 12px 18px; font-size: 16px; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--c-border); }
table.data {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
table.data th, table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
}
table.data thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 13px;
  color: #475569;
  position: sticky;
  top: 0;
}
table.data tbody tr:hover { background: #f8fafc; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Alerts ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #f0f9ff; color: #075985; border-color: #bae6fd; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  background: #e2e8f0;
  color: #1e293b;
}
.badge-waiting     { background: #e2e8f0; color: #334155; }
.badge-checked-in  { background: #dbeafe; color: #1d4ed8; }
.badge-in-progress { background: #fef3c7; color: #92400e; }
.badge-submitted   { background: #dcfce7; color: #166534; }
.badge-timeout     { background: #fee2e2; color: #991b1b; }

/* ---------- Timer ---------- */
.timer-box {
  background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
  padding: 18px;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 700;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  margin: 12px 0;
  border: 1px solid #93c5fd;
  transition: background .25s;
}
.timer-box.warn-2  { background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%); border-color: #fcd34d; }
.timer-box.warn-1  { background: linear-gradient(135deg, #fed7aa 0%, #ffedd5 100%); border-color: #fb923c; }
.timer-box.done    { background: linear-gradient(135deg, #fee2e2 0%, #fef2f2 100%); border-color: #f87171; color: #991b1b; }

/* ---------- Grade view (mobile-friendly) ---------- */
.grade-table { width: 100%; border-collapse: collapse; }
.grade-table th, .grade-table td { padding: 10px; border-bottom: 1px solid var(--c-border); }
.grade-table input[type=number] { max-width: 80px; }
.grade-row { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.grade-row .label { font-weight: 500; }
.grade-row .max { color: var(--c-muted); font-size: 13px; }
.grade-row .score-input { display: flex; align-items: center; gap: 8px; }

.autosave-status {
  font-size: 12px;
  color: var(--c-muted);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}
.autosave-status.saving { color: var(--c-warning); }
.autosave-status.saved  { color: var(--c-success); }
.autosave-status.error  { color: var(--c-danger); }

/* ---------- KPI tiles ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.kpi {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label { color: var(--c-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .sub   { font-size: 12px; color: var(--c-muted); }

/* ---------- Print (barcode labels — 60mm × 40mm) ---------- */
@media print {
  @page {
    size: 60mm 40mm;
    margin: 0;
  }
  body { background: #fff; margin: 0; padding: 0; }
  .topbar, .navbar, .no-print, footer { display: none !important; }
  .container { box-shadow: none; padding: 0; margin: 0; max-width: none; }
  .barcode-grid {
    display: block;
  }
  .barcode-card {
    width: 60mm;
    height: 40mm;
    box-sizing: border-box;
    page-break-after: always;
    break-after: page;
    border: none;
    text-align: center;
    padding: 2mm;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .barcode-card svg {
    max-width: 54mm;
    height: 14mm;
  }
  .barcode-card .num  { font-size: 9pt; font-weight: 700; margin: 1mm 0 0; }
  .barcode-card .name { font-size: 7pt; margin: 0.5mm 0 0; }
  .barcode-card .muted { font-size: 6pt; margin: 0.5mm 0 0; }
}
.barcode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.barcode-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  text-align: center;
  padding: 14px;
}
.barcode-card .code { font-family: 'Libre Barcode 39', 'Courier New', monospace; font-size: 36px; letter-spacing: 1px; }
.barcode-card .num { font-weight: 700; margin-top: 6px; }
.barcode-card .name { color: var(--c-muted); font-size: 13px; }

/* ---------- Mobile tweaks ---------- */
@media (max-width: 720px) {
  .container { margin: 10px; padding: 14px; border-radius: 0; box-shadow: none; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border-bottom: 1px solid var(--c-border); padding: 8px 0; }
  table.data td {
    border: none;
    padding: 4px 0;
  }
  table.data td:before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--c-muted);
    letter-spacing: .04em;
  }
  .timer-box { font-size: 22px; padding: 12px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* ---------- Utility ---------- */
.muted { color: var(--c-muted); }
.right { text-align: right; }
.center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hidden { display: none !important; }
small.copyright { display:block; text-align:center; padding:14px 0; color: var(--c-muted); font-size:12px; }
