/* RCCG GTP Learning Portal - shared design system (tokens, Bootstrap overrides, components).
   Brand: navy #000080 for structure, orange #FFA500 as the one accent (filled, with navy text: orange text on white
   is too faint to read). Type: Bricolage Grotesque for headings, Atkinson Hyperlegible Next for reading, its Mono for
   code. Radius follows hierarchy (panels 20, cards 14, controls 10); borders separate things, shadows only lift what
   floats (menus, dialogs, toasts). Mobile-first; every component works from 320px up.
   The --g-* names are historical (the first theme was green); they now hold the navy scale. */

:root {
  --g-900: #07073f;
  --g-800: #0b0b5e;
  --g-700: #000080;
  --g-600: #1c1ca8;
  --g-500: #3a3ac4;
  --g-200: #c9cbf0;
  --g-100: #e6e7f8;
  --g-50: #f3f4fc;
  --gold: #ffa500;
  --gold-600: #c77700;
  --gold-700: #8f5400;
  --gold-100: #fff1d6;
  --ink: #121433;
  --text: #23264a;
  --muted: #5b5f7a;
  --line: #dde0ee;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --success: #13804b;
  --success-100: #e2f4ea;
  --danger: #c2303f;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: none;
  --shadow: 0 12px 32px rgba(7, 7, 63, .14);
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font-code: "Atkinson Hyperlegible Mono", ui-monospace, Consolas, "Courier New", monospace;

  --bs-primary: #000080;
  --bs-primary-rgb: 0, 0, 128;
  --bs-success: #13804b;
  --bs-success-rgb: 19, 128, 75;
  --bs-warning: #ffa500;
  --bs-warning-rgb: 255, 165, 0;
  --bs-danger: #c2303f;
  --bs-danger-rgb: 194, 48, 63;
  --bs-body-font-family: var(--font);
  --bs-font-monospace: var(--font-code);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-link-color: #000080;
  --bs-link-hover-color: #0b0b5e;
  /* Bootstrap 5.3 colours links from these, not from --bs-link-color, so without them links showed Bootstrap blue. */
  --bs-link-color-rgb: 0, 0, 128;
  --bs-link-hover-color-rgb: 11, 11, 94;
  --bs-border-color: var(--line);
  --bs-border-radius: 10px;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; max-width: 100%; overflow-x: hidden; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; max-width: 100%; overflow-x: hidden; }
/* A safety net, not a fix: any element wider than the screen scrolls itself instead of stretching the whole page sideways.
   Tables are deliberately excluded — .table-responsive relies on a table being allowed to overflow its own wrapper. */
img, svg, video, canvas, iframe { max-width: 100%; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); color: var(--ink); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
h4, h5, h6 { letter-spacing: -.01em; line-height: 1.3; }
code, kbd, pre, samp { font-family: var(--font-code); }
a { text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; }
/* Keyboard focus: a dark-orange ring (3:1 against white and navy) with a white gap, visible on every surface. */
:focus-visible { outline: 3px solid var(--gold-600); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--g-800); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 9999; }
.skip-link:focus { left: 8px; }
::selection { background: var(--gold); color: var(--g-900); }

/* ---- Buttons ---- */
.btn { font-weight: 700; border-radius: var(--radius-sm); padding: .62rem 1.15rem; letter-spacing: 0; transition: background-color .15s, border-color .15s, color .15s; }
.btn-lg { padding: .82rem 1.5rem; font-size: 1.04rem; border-radius: 12px; }
.btn-sm { padding: .36rem .75rem; border-radius: 8px; font-size: .86rem; }
.btn-primary { --bs-btn-bg: var(--g-700); --bs-btn-border-color: var(--g-700); --bs-btn-hover-bg: var(--g-800); --bs-btn-hover-border-color: var(--g-800);
  --bs-btn-active-bg: var(--g-900); --bs-btn-active-border-color: var(--g-900); --bs-btn-disabled-bg: var(--g-700); --bs-btn-disabled-border-color: var(--g-700); }
.btn-outline-primary { --bs-btn-color: var(--g-700); --bs-btn-border-color: var(--g-700); --bs-btn-hover-bg: var(--g-700); --bs-btn-hover-border-color: var(--g-700); --bs-btn-active-bg: var(--g-800); }
/* The accent button: the one thing to do on a page (join, continue, pay). Navy text on orange for contrast. */
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--g-900); }
.btn-gold:hover, .btn-gold:focus-visible { background: #ffb733; border-color: #ffb733; color: var(--g-900); }
.btn-gold:active { background: #e89500 !important; border-color: #e89500 !important; color: var(--g-900) !important; }
.btn-soft { background: var(--g-100); border-color: var(--g-100); color: var(--g-800); }
.btn-soft:hover { background: var(--g-200); border-color: var(--g-200); color: var(--g-900); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--g-50); border-color: var(--g-200); }
.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }

/* ---- Forms ---- */
.form-label { font-weight: 700; font-size: .9rem; color: var(--ink); margin-bottom: .35rem; }
.form-control, .form-select { border-radius: var(--radius-sm); border: 1.5px solid #cfd3e6; padding: .66rem .9rem; background-color: #fff; font-size: 1rem; }
.form-control:hover, .form-select:hover { border-color: #b4b9d6; }
textarea.form-control { min-height: 96px; }
.form-control:focus, .form-select:focus { border-color: var(--g-700); box-shadow: 0 0 0 3px rgba(255, 165, 0, .45); }
.form-control::placeholder { color: #868aa6; }
.form-text { color: var(--muted); font-size: .84rem; }
.form-check-input { border: 1.5px solid #b4b9d6; }
.form-check-input:checked { background-color: var(--g-700); border-color: var(--g-700); }
.form-check-input:focus { border-color: var(--g-700); box-shadow: 0 0 0 3px rgba(255, 165, 0, .45); }
.field-error, .invalid-feedback { color: var(--danger); font-size: .86rem; margin-top: .3rem; }
.is-invalid { border-color: var(--danger) !important; }
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 3rem; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); width: 44px; height: 44px; border-radius: 10px; }
.pw-toggle:hover { color: var(--g-700); background: var(--g-50); }
.pw-meter { height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 8px; }
.pw-meter > i { display: block; height: 100%; width: 0; transition: width .25s, background .25s; }

/* ---- Cards / surfaces: a border, not a shadow ---- */
.g-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
.g-card-pad { padding: 1.25rem; }
.g-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.g-card-head h2, .g-card-head h3 { font-size: 1.05rem; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.g-card-body { padding: 1.25rem; }
.g-muted { color: var(--muted); }
.text-gold { color: var(--gold-600); }
.fw-800 { font-weight: 800; }
.rounded-16 { border-radius: var(--radius); }
.divider { height: 1px; background: var(--line); margin: 1rem 0; }

/* ---- Badges: tinted, with dark text for contrast ---- */
.badge { font-family: var(--font); font-weight: 700; letter-spacing: 0; padding: .4em .68em; border-radius: 999px; }
.badge.bg-success { background: var(--success-100) !important; color: #0d5c36 !important; }
.badge.bg-warning { background: var(--gold-100) !important; color: var(--gold-700) !important; }
.badge.bg-danger { background: #fbe5e8 !important; color: #8e1f2c !important; }
.badge.bg-secondary { background: #e8e9f2 !important; color: #43476a !important; }
.badge.bg-dark { background: var(--g-900) !important; color: #fff !important; }
.badge.bg-info { background: #e3ecfb !important; color: #1b3f86 !important; }
.badge.bg-primary { background: var(--g-100) !important; color: var(--g-800) !important; }

/* ---- Progress: orange is the colour of progress everywhere ---- */
.g-progress { height: 8px; background: var(--g-100); border-radius: 999px; overflow: hidden; }
.g-progress > span { display: block; height: 100%; border-radius: 999px; background: var(--gold); transition: width .5s ease; }
.g-progress.sm { height: 6px; }
.g-progress.gold > span { background: var(--gold); }

/* ---- Course cover (image or coloured placeholder) ---- */
.g-cover { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: linear-gradient(135deg, hsl(var(--h, 238) 70% 22%), hsl(calc(var(--h, 238) + 18) 62% 36%)); color: #fff; display: flex; align-items: flex-end; }
.g-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.g-cover .g-cover-glyph { position: absolute; right: -8px; top: -14px; font-size: 5.5rem; opacity: .16; }
.g-cover .g-cover-tag { position: relative; margin: 12px; background: rgba(255, 255, 255, .94); color: var(--g-900); font-size: .76rem; font-weight: 700; padding: .25rem .6rem; border-radius: 999px; }

/* ---- Empty states ---- */
.g-empty { text-align: center; padding: 2.5rem 1.25rem; color: var(--muted); }
.g-empty i { font-size: 2.2rem; color: var(--g-200); margin-bottom: .75rem; display: block; }
.g-empty h3 { font-size: 1.05rem; margin-bottom: .35rem; }

/* ---- Tables: real tables on desktop, stacked cards on phones (add data-label to each td) ---- */
.g-table { --bs-table-bg: transparent; margin: 0; }
.g-table thead th { font-size: .84rem; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); background: var(--g-50); white-space: nowrap; padding: .75rem 1rem; }
.g-table td { padding: .85rem 1rem; vertical-align: middle; border-color: var(--line); }
.g-table tbody tr:hover { background: var(--g-50); }
@media (max-width: 767.98px) {
  .g-table.stack thead { display: none; }
  .g-table.stack, .g-table.stack tbody, .g-table.stack tr, .g-table.stack td { display: block; width: 100%; }
  .g-table.stack tr { padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
  .g-table.stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; border: 0; text-align: right; }
  .g-table.stack td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: .8rem; text-align: left; flex: 0 0 38%; }
  .g-table.stack td.actions { justify-content: flex-end; padding-top: .6rem; }
  .g-table.stack td.actions::before, .g-table.stack td.no-label::before { display: none; }
}

/* ---- Alerts / callouts ---- */
.alert { border-radius: 12px; border: 0; }
.alert-danger { background: #fde6ea; color: #8f2035; }
.alert-success { background: var(--success-100); color: #0b4f2e; }
.alert-info { background: #e2f1fa; color: #0b4d6f; }
.alert-warning { background: var(--gold-100); color: #6b4a00; }
.callout { border-left: 4px solid var(--gold); background: var(--gold-100); padding: .85rem 1rem; border-radius: 0 12px 12px 0; font-size: .9rem; }

/* ---- Modals / SweetAlert / Toastr polish ---- */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-size: 1.05rem; }
.swal2-popup { border-radius: 20px !important; font-family: var(--font) !important; }
.swal2-styled.swal2-confirm { background: var(--g-700) !important; border-radius: 12px !important; }
.swal2-styled.swal2-cancel { border-radius: 12px !important; }
#toast-container > div { border-radius: 12px; box-shadow: var(--shadow); font-family: var(--font); opacity: 1; }
#toast-container > .toast-success { background-color: var(--g-800); }
#toast-container > .toast-error { background-color: var(--danger); }
#toast-container > .toast-info { background-color: #1f6f95; }
#toast-container > .toast-warning { background-color: var(--gold-600); }

/* ---- PWA: install banner + offline bar ---- */
.g-install { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 1080; max-width: 460px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; box-shadow: 0 18px 48px rgba(7, 7, 63, .28); transform: translateY(140%); transition: transform .35s ease; }
.g-install.in { transform: none; }
.g-install img { border-radius: 10px; }
.g-install .txt { flex: 1; min-width: 0; line-height: 1.3; }
.g-install .txt strong { display: block; font-size: .92rem; color: var(--ink); }
.g-install .txt span { font-size: .8rem; color: var(--muted); }
.g-install .go { border: 0; background: var(--g-700); color: #fff; font-weight: 700; padding: .5rem .95rem; border-radius: 10px; }
.g-install .x { border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); padding: 0 4px; }
.g-offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 2000; background: #3a2a00; color: #fff; text-align: center; font-size: .85rem; padding: .4rem; }

@media print { .no-print, .g-install, .g-offline-bar { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Upload progress (upload-progress.js) ---------- */
.upx-lock, .upx-lock body { overflow: hidden; }
.upx-overlay { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(7, 7, 63, .45); backdrop-filter: blur(4px); opacity: 0; transition: opacity .2s; }
.upx-overlay.show { opacity: 1; }
.upx-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; box-shadow: 0 24px 60px rgba(7, 7, 63, .28); padding: 28px 24px 22px; text-align: center; transform: translateY(12px) scale(.98); transition: transform .25s; }
.upx-overlay.show .upx-card { transform: none; }
.upx-ring { position: relative; width: 132px; height: 132px; margin: 0 auto 16px; }
.upx-ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.upx-ring circle { fill: none; stroke-width: 9; }
.upx-track { stroke: var(--g-100); }
.upx-arc { stroke: var(--g-600); stroke-linecap: round; transition: stroke-dashoffset .25s ease, stroke .2s; }
.upx-center { position: absolute; inset: 0; display: grid; place-items: center; }
.upx-pct { font-size: 1.9rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.upx-pct small { font-size: .95rem; font-weight: 700; color: var(--muted); margin-left: 1px; }
.upx-ok, .upx-bad { display: none; width: 52px; height: 52px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.upx-title { font-size: 1.15rem; font-weight: 800; color: var(--ink); margin: 0 0 4px; }
.upx-file { color: var(--muted); font-size: .86rem; margin: 0 0 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upx-bar { position: relative; height: 8px; border-radius: 99px; background: var(--g-100); overflow: hidden; }
.upx-bar span { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--g-700), var(--g-500)); transition: width .25s ease; overflow: hidden; }
.upx-bar span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); transform: translateX(-100%); animation: upx-shine 1.6s ease-in-out infinite; }
.upx-stats { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.upx-stats .upx-sent { color: var(--text); font-weight: 600; }
.upx-note { font-size: .84rem; color: var(--muted); margin: 14px 0 0; min-height: 1.2em; }
.upx-actions { margin-top: 16px; }
.upx-actions .btn { min-width: 150px; border-radius: 999px; }
/* Saving: the ring turns into a spinner while the server works. */
.upx-overlay.is-saving .upx-arc { stroke-dasharray: 90 237 !important; stroke-dashoffset: 0 !important; transition: none; }
.upx-overlay.is-saving .upx-ring > svg { animation: upx-spin .9s linear infinite; }
.upx-overlay.is-saving .upx-pct { font-size: 1.25rem; }
.upx-overlay.is-done .upx-arc { stroke: var(--g-600); stroke-dashoffset: 0 !important; }
.upx-overlay.is-done .upx-pct, .upx-overlay.is-failed .upx-pct { display: none; }
.upx-overlay.is-done .upx-ok { display: block; color: var(--g-600); animation: upx-pop .35s ease; }
.upx-overlay.is-failed .upx-arc { stroke: var(--danger); }
.upx-overlay.is-failed .upx-bar span { background: var(--danger); }
.upx-overlay.is-failed .upx-bad { display: block; color: var(--danger); animation: upx-pop .35s ease; }
.upx-overlay.is-failed .upx-note { color: var(--danger); font-weight: 600; }
.upx-overlay.is-done .upx-bar span::after, .upx-overlay.is-failed .upx-bar span::after { display: none; }
/* Inline variant for AJAX forms. */
.upx-inline { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--g-50); padding: 10px 12px; margin: 0 0 10px; }
.upx-inline-head { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; margin-bottom: 6px; }
.upx-inline-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.upx-inline-pct { color: var(--g-700); font-variant-numeric: tabular-nums; }
.upx-inline .upx-bar { height: 6px; }
.upx-inline-stats { margin-top: 6px; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.upx-inline.is-saving .upx-bar span { width: 100% !important; background: repeating-linear-gradient(45deg, var(--g-600) 0 10px, var(--g-500) 10px 20px); background-size: 28px 28px; animation: upx-stripes .8s linear infinite; }
.upx-inline.is-done .upx-bar span::after, .upx-inline.is-saving .upx-bar span::after { display: none; }
.upx-inline.is-done .upx-inline-pct::before { content: "\2713  "; }
@keyframes upx-shine { to { transform: translateX(100%); } }
@keyframes upx-spin { to { transform: rotate(270deg); } }
@keyframes upx-stripes { to { background-position: 28px 0; } }
@keyframes upx-pop { from { transform: scale(.4); } to { transform: scale(1); } }

/* Lets a flex/grid child shrink below its content width, so text-truncate and scrolling code work. Used by every layout. */
.min-w-0 { min-width: 0; }

/* ---- Adverts: quiet, clearly labelled, never moving ---- */
.ad-unit { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.ad-label { position: absolute; top: .55rem; right: .6rem; z-index: 1; font-size: .74rem; font-weight: 700; color: var(--muted); background: rgba(255, 255, 255, .92); padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); }
.ad-link { display: flex; color: inherit; text-decoration: none !important; }
.ad-link:focus-visible { outline-offset: -3px; }
.ad-text { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.1rem; min-width: 0; }
.ad-text strong { font-family: var(--font-display); font-size: 1.1rem; color: var(--ink); line-height: 1.25; }
.ad-text span { color: var(--text); font-size: .95rem; }
.ad-text small { color: var(--muted); font-size: .82rem; }
.ad-link:hover .ad-text strong { text-decoration: underline; text-underline-offset: 3px; }
.ad-home .ad-link { flex-direction: row; align-items: stretch; }
.ad-home img { width: min(48%, 520px); aspect-ratio: 4 / 1; object-fit: cover; flex: none; }
.ad-home .ad-text { justify-content: center; padding: 1.2rem 1.6rem; }
.ad-listing .ad-link { flex-direction: column; }
.ad-listing img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
@media (max-width: 767.98px) { .ad-home .ad-link { flex-direction: column; } .ad-home img { width: 100%; aspect-ratio: 3 / 1; } }
.ad-slot { margin-top: 2.5rem; }
.ad-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.ad-choice { display: flex; gap: .7rem; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: .75rem .9rem; cursor: pointer; }
.ad-choice:has(input:checked) { border-color: var(--g-700); background: var(--g-50); }
.ad-choice span { display: flex; flex-direction: column; }
.ad-choice small { color: var(--muted); }
.ad-total { font-size: 1.05rem; color: var(--text); }
.ad-total strong { font-family: var(--font-display); color: var(--ink); }

/* Advert countdown (admin list and pages, advertiser status page) */
.countdown { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 999px; background: var(--g-100); color: var(--g-800); font-weight: 700; font-size: .84rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.countdown.soon { background: #e3ecfb; color: #1b3f86; }
.countdown.ending { background: var(--gold-100); color: var(--gold-700); }
.countdown.done { background: #e8e9f2; color: #43476a; }

.ad-pages .form-check[hidden] { display: none; }
