/* HKS Admin - UI-1 stylesheet. Served as a static file only (CSP style-src 'self': no inline styles anywhere). */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #17202e;
  --text-muted: #556274;
  --border: #d5dbe5;
  --border-strong: #7d8899;      /* form control edges: >= 3:1 on surface and bg (WCAG 1.4.11) */
  --brand: #0b4f9c;
  --brand-strong: #083b75;
  --brand-soft: #e3edf9;
  --on-brand: #ffffff;           /* text on --brand / --brand-strong / --bad filled buttons */
  --ok: #17663a;
  --ok-soft: #e1f3e8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --bad: #a1251b;
  --bad-soft: #fbe5e3;
  --bad-strong: #7a1a12;         /* hover of danger buttons: stays red */
  --focus: #f0a500;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --sidebar: 248px;
  --topbar: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171e28;
    --surface-2: #1f2834;
    --text: #e6ebf2;
    --text-muted: #9aa7b8;
    --border: #2d3846;
    --border-strong: #6b7a8f;
    --brand: #6aa9ef;
    --brand-strong: #9cc6f5;
    --brand-soft: #1b2c42;
    --on-brand: #0f141b;         /* light fills in dark mode need dark text (>= 7:1 on brand, brand-strong, bad) */
    --ok: #6fd49a;
    --ok-soft: #173326;
    --warn: #f0c060;
    --warn-soft: #3a2e14;
    --bad: #f19a92;
    --bad-soft: #3d1c1a;
    --bad-strong: #f7b9b3;
    --shadow: none;
    color-scheme: dark;          /* F5-UI-FIX: native parts of date / number / select controls follow the dark theme */
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); }
a { color: var(--brand); }
a:hover { color: var(--brand-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--surface);
  border: 2px solid var(--brand); border-radius: var(--radius); }
.skip-link:focus { top: 8px; }

/* --- simple pages (login, errors) ------------------------------------------------------------------------------ */
.simple-main { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.simple-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.simple-card h1 { margin: 0 0 16px; font-size: 1.5rem; }
.brand-mark { margin: 0 0 8px; color: var(--brand); font-weight: 700; letter-spacing: .02em; }
.simple-card form p { display: grid; gap: 4px; margin: 0 0 14px; }
.simple-card input { width: 100%; }
.simple-card button[type="submit"] { width: 100%; }
.simple-card .error { color: var(--bad); background: var(--bad-soft); border-radius: var(--radius); padding: 10px 12px; }

/* --- form controls and buttons --------------------------------------------------------------------------------- */
input, select, button { font: inherit; color: inherit; }
/* F5-UI-FIX: date and number inputs (NAJAVA dates, seasonal quota) use the same tokens - light and dark theme */
input[type="text"], input[type="search"], input[type="password"], input[type="date"], input[type="number"], input:not([type]), select {
  min-height: 40px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px;
}
label { font-weight: 600; font-size: .9rem; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--brand); border-radius: 6px; background: var(--brand); color: var(--on-brand); font-weight: 600;
  text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { background: var(--brand-strong); color: var(--on-brand); }
.button-quiet { background: transparent; color: var(--brand); border-color: var(--border); }
.button-quiet:hover { background: var(--brand-soft); color: var(--brand-strong); }
.button-danger { background: var(--bad); border-color: var(--bad); }
.button-danger:hover { background: var(--bad-strong); border-color: var(--bad-strong); color: var(--on-brand); }

/* --- application shell ----------------------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: var(--topbar);
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-brand { margin: 0; font-weight: 700; color: var(--brand); white-space: nowrap; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-identity { color: var(--text-muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-logout { margin: 0; }
.topbar-logout .button { min-height: 34px; padding: 4px 12px; }
.nav-toggle { display: none; min-height: 40px; width: 40px; padding: 0; background: transparent; border-color: var(--border); }
.nav-toggle:hover { background: var(--brand-soft); }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; position: relative;
}
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-link { display: block; padding: 9px 12px; border-radius: 6px; color: var(--text); text-decoration: none; font-weight: 500; }
a.nav-link:hover { background: var(--brand-soft); color: var(--brand-strong); }
.nav-link.is-current { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); }
.nav-link.is-disabled { color: var(--text-muted); cursor: not-allowed; }
.nav-note { display: block; padding: 0 12px 6px; color: var(--text-muted); font-size: .78rem; }
.nav-group { margin: 14px 12px 4px; color: var(--text-muted); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

.content { padding: 20px 28px 48px; min-width: 0; }
.content:focus { outline: none; }
.page-title { margin: 4px 0 16px; font-size: 1.6rem; }
.lead { color: var(--text-muted); margin: 0 0 20px; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; font-size: .9rem; color: var(--text-muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 4px; color: var(--border); }

/* --- cards, sections, figures ---------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { margin: 0 0 20px; }
.section.card { padding: 16px 20px; }
.section-title { margin: 0 0 12px; font-size: 1.1rem; }
.subsection-title { margin: 20px 0 10px; font-size: 1rem; }
.hint { margin: 10px 0 0; color: var(--text-muted); font-size: .85rem; }
.figure-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.figure { padding: 16px 18px; }
.figure-label { margin: 0; color: var(--text-muted); font-size: .9rem; font-weight: 600; }
.figure-value { margin: 6px 0 0; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.figure-value a { text-decoration: none; }
.figure-note { margin: 4px 0 0; color: var(--text-muted); font-size: .8rem; }
.figure-missing { margin: 8px 0 0; color: var(--warn); font-weight: 600; }
.figure.is-unavailable { background: var(--warn-soft); }

.status-list { margin: 0; display: grid; gap: 8px; }
/* F4-UI: list of links (e.g. code lists); it had no rule - links stacked with browser bullets */
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.link-list a { display: inline-block; padding: 6px 0; }
.status-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding: 6px 0; }
.status-row:last-child { border-bottom: 0; }
.status-row dt { font-weight: 600; }
.status-row dd { margin: 0; }
.data-list { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 24px; }
.data-list dt { color: var(--text-muted); font-size: .85rem; }
.data-list dd { margin: 2px 0 0; font-weight: 600; }

/* --- badges -------------------------------------------------------------------------------------------------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge-role { background: var(--brand-soft); color: var(--brand-strong); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-muted, .badge-neutral { background: var(--surface-2); color: var(--text-muted); }

/* --- alerts / empty states ------------------------------------------------------------------------------------- */
.messages { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.alert { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-info { background: var(--brand-soft); color: var(--brand-strong); }
.empty-state { padding: 28px 16px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state.is-unavailable { background: var(--warn-soft); border-color: transparent; }
.empty-title { margin: 0; font-weight: 700; }
.empty-text { margin: 4px 0 0; color: var(--text-muted); }

/* --- filters / tables / pagination ----------------------------------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 14px 16px; margin: 0 0 14px; }
.field { display: grid; gap: 4px; min-width: 160px; flex: 1 1 160px; }
.field:first-child { flex: 2 1 240px; }
/* F5-UI-FIX: a select with long options ("Vrsta") must shrink with its field - no horizontal page overflow */
.filters .field { min-width: min(160px, 100%); grid-template-columns: minmax(0, 1fr); }   /* track never wider than the field */
.filters select, .filters input:not([type="hidden"]) { max-width: 100%; }
.filter-actions { display: flex; gap: 8px; }
.result-count { margin: 0 0 10px; color: var(--text-muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: var(--surface-2); font-size: .85rem; color: var(--text-muted); white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { text-decoration: underline; }
.table th[aria-sort="ascending"] a::after { content: " ▲"; }
.table th[aria-sort="descending"] a::after { content: " ▼"; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.pagination ul { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0 0; padding: 0; }
.pagination a, .pagination span[aria-disabled] { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; }
.pagination span[aria-disabled] { color: var(--text-muted); }

/* --- tabs / schedule ------------------------------------------------------------------------------------------- */
/* tabs wrap onto a second row instead of scrolling: no tab is ever cut off (narrow desktop ~1024 px, tablet, phone) */
.tabs ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0 4px; margin: 0; padding: 0; border-bottom: 1px solid var(--border); }
.tab { display: block; padding: 10px 12px; white-space: nowrap; text-decoration: none; color: var(--text-muted);
  border-bottom: 3px solid transparent; font-weight: 600; }
a.tab:hover { color: var(--brand-strong); }
.tab.is-current { color: var(--brand-strong); border-bottom-color: var(--brand); }
.tab.is-disabled { color: var(--text-muted); font-weight: 500; cursor: not-allowed; }
.tab-soon { display: inline-block; margin-left: 4px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: .75rem; font-weight: 600; color: var(--text-muted); vertical-align: 1px; }
.tabs-hint { margin: 8px 0 0; }
.tab-panel { margin-top: 16px; padding: 16px 20px; }
.schedule { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.schedule-item { padding: 8px 12px; background: var(--surface-2); border-radius: 6px; }
.schedule-date { display: inline-block; min-width: 100px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- confirmation dialog --------------------------------------------------------------------------------------- */
.dialog { max-width: 440px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 20px; }
.dialog::backdrop { background: rgba(10, 15, 25, .5); }
.dialog-title { margin: 0 0 8px; font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.nav-backdrop { display: none; }
.sort-label, .sort-state { display: none; }      /* phone-only sort bar label / direction text (see @600) */

/* --- responsive: tablet and phone ------------------------------------------------------------------------------ */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Without a working admin.js (JavaScript off, script blocked or failed) the menu stays in the page flow above the
     content; the off-canvas menu applies only once admin.js has initialised it (html.nav-ready). */
  html:not(.nav-ready) .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .nav-ready .nav-toggle { display: inline-flex; }
  .nav-ready .sidebar { position: fixed; z-index: 15; top: var(--topbar); bottom: 0; left: 0; width: min(84vw, 300px);
    transform: translateX(-100%); overflow-y: auto; box-shadow: var(--shadow);
    /* closed = hidden from keyboard and assistive tech too */
    visibility: hidden; }
  .nav-ready .sidebar.is-open { transform: none; visibility: visible; }
  /* html.nav-animate is set after nav-ready, so the menu never slides out on page load; visibility flips only after
     the slide-out ends */
  .nav-animate .sidebar { transition: transform .2s ease, visibility 0s linear .2s; }
  .nav-animate .sidebar.is-open { transition: transform .2s ease, visibility 0s; }
  .content { padding: 16px 16px 40px; }
  .topbar-identity { display: none; }
  .nav-backdrop:not([hidden]) { display: block; position: fixed; z-index: 14; top: var(--topbar); right: 0; bottom: 0; left: 0;
    background: rgba(10, 15, 25, .45); }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar-user { gap: 6px; }
  .badge-role { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; }
  .page-title { font-size: 1.35rem; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: 6px 0; }
  .table td { border: 0; padding: 4px 12px; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--text-muted); font-weight: 600; }
  /* sortable tables keep their header links on phones: the header row becomes a wrapped row of sort buttons */
  .table-sortable thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: block; }
  .sort-label { display: block; margin: 0; padding: 10px 12px 0; background: var(--surface-2); color: var(--text-muted);
    font-size: .85rem; font-weight: 600; }
  .sort-state { display: inline; position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; }
  .table-sortable thead tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px 10px;
    background: var(--surface-2); }
  .table-sortable thead th { display: block; padding: 0; border: 0; background: none; }
  .table-sortable thead th a { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 4px 12px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
  .table-sortable thead th[aria-sort="ascending"] a, .table-sortable thead th[aria-sort="descending"] a {
    border-color: var(--brand); color: var(--brand-strong); }
  .filter-actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-animate .sidebar, .nav-animate .sidebar.is-open { transition: none; }
}

/* SA-1: competition editor forms (NAJAVA) */
.page-actions { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.form-grid { display: grid; gap: 14px; max-width: 760px; }
.data-list + .form-grid { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-grid fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 14px; }
.form-grid .field { min-width: 0; }
.form-grid input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), .form-grid select { width: 100%; max-width: 100%; }
/* F5-UI-FIX: checkboxes keep their natural size (were stretched to the full field width) */
.form-grid input[type="checkbox"], .form-grid input[type="radio"] { width: 20px; height: 20px; margin: 4px 0; justify-self: start;
  accent-color: var(--brand); }
/* F5-UI-FIX: a form that is itself the card (Novo natjecanje) gets the card's inner spacing */
.card.form-grid { padding: 16px 20px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.field-error { margin: 0; color: var(--bad, #b42318); font-size: .9rem; }
.field.has-error input, .field.has-error select { border-color: var(--bad, #b42318); }
.required { color: var(--bad, #b42318); }
.tab.is-soon { opacity: .75; }
@media (max-width: 600px) {
  .page-actions { justify-content: stretch; }
  .page-actions .button { width: 100%; text-align: center; }
}

/* SA3-F6-C: inline action form in a table cell (participant deactivation) - wraps on small screens */
.inline-form { display: inline-block; margin: 0; }
.inline-form .button { white-space: nowrap; }

/* SA3-F6-C3/C4: tab heading with its action; compact forms (fields side by side, one column on phones) */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-bottom: 8px; }
.section-head .section-title { margin: 0; }
.form-compact { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); align-items: start; max-width: 960px; }
.form-compact > .form-actions, .form-compact > fieldset, .form-compact > .hint { grid-column: 1 / -1; }
.form-compact fieldset { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.form-compact fieldset > .hint { grid-column: 1 / -1; }
