/*
 * OCR Benchmark UI foundation
 *
 * Finálna vrstva dizajnového systému. Zámerne sa načítava po style.css:
 * existujúce obrazovky si zachovajú svoje layout triedy, kým spoločné
 * povrchy, ovládacie prvky a stavy dostanú jednotný vzhľad v oboch témach.
 */

:root {
  color-scheme: dark;
  --surface-raised: oklch(0.225 0.014 260);
  --surface-sunken: oklch(0.145 0.012 260);
  --surface-overlay: oklch(0.205 0.014 260);
  --text-strong: oklch(0.97 0.004 260);
  --control-bg: oklch(0.18 0.012 260);
  --control-hover: oklch(0.255 0.018 260);
  --focus-ring: oklch(0.72 0.15 255 / 0.42);
  --overlay-backdrop: oklch(0.08 0.015 260 / 0.76);
  --shadow-sm: 0 1px 2px oklch(0.06 0.01 260 / 0.34);
  --shadow-md: 0 12px 32px oklch(0.06 0.01 260 / 0.38);
  --shadow-lg: 0 24px 64px oklch(0.04 0.01 260 / 0.52);
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 15px;
  --transition-fast: 140ms ease;
}

[data-theme="light"] {
  color-scheme: light;
  --surface-raised: oklch(0.995 0.002 260);
  --surface-sunken: oklch(0.945 0.006 260);
  --surface-overlay: white;
  --text-strong: oklch(0.18 0.018 260);
  --control-bg: white;
  --control-hover: oklch(0.94 0.018 260);
  --focus-ring: oklch(0.56 0.18 255 / 0.26);
  --overlay-backdrop: oklch(0.18 0.02 260 / 0.46);
  --shadow-sm: 0 1px 3px oklch(0.25 0.02 260 / 0.1);
  --shadow-md: 0 12px 32px oklch(0.25 0.02 260 / 0.13);
  --shadow-lg: 0 24px 64px oklch(0.22 0.025 260 / 0.18);
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-bg); color: var(--text-strong); }
::placeholder { color: var(--muted2); opacity: 1; }

/* Jeden viditeľný a prístupný focus klávesnice na všetkých obrazovkách. */
:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Shell */
.shell { background: var(--bg); }
.sidebar {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 4%, var(--card)), var(--card) 190px);
  box-shadow: 1px 0 0 var(--border), var(--shadow-sm);
  z-index: 10;
}
.brand { min-height: 54px; }
.brand-logo {
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 28%, transparent);
  letter-spacing: -0.03em;
}
.brand-name, .topbar-title { color: var(--text-strong); letter-spacing: -0.01em; }
.nav-item, .stats-model-nav-link {
  min-height: 38px;
  transition: color var(--transition-fast), background var(--transition-fast),
    transform var(--transition-fast);
}
.nav-item:hover { transform: translateX(2px); text-decoration: none; }
.nav-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.nav-glyph { color: var(--muted2); }
.nav-item.active .nav-glyph { color: var(--accent-hi); }
.sidebar-user { margin-inline: 2px; }

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 66px;
  background: color-mix(in srgb, var(--card) 91%, transparent);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}
.topbar-title { font-size: 18px; }
.screen-body { width: 100%; max-width: 1720px; margin-inline: auto; }
.tab-panel.active { animation: ui-enter 180ms ease-out; }
/* Chromium can keep an animated ancestor on a composited layer and then fail
   to attach a nested sticky element to the viewport. The document detail has
   its own sticky toolbar, so keep this panel out of the animation entirely. */
#tab-statsdoc.active { animation: none; }

/* Povrchy a typografia */
.card,
.tile,
.scorecard-item,
.stability-doc,
.schema-editor,
.stats-detail-section,
.stats-compact-block,
.stats-reference-comparison-card {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.card {
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  padding: 16px 18px;
}
.card:hover { border-color: color-mix(in srgb, var(--border2) 82%, var(--accent)); }
.card h2 { color: var(--text-strong); letter-spacing: -0.01em; }
.card h3 { color: var(--text); }
.tile, .scorecard-item { border-radius: var(--radius-sm); background: var(--card2); }
hr { border: 0; border-top: 1px solid var(--border); }
code, pre, .mono, .num { font-variant-ligatures: none; }
code {
  border-radius: 5px;
  background: var(--surface-sunken);
  padding: 0.12em 0.35em;
  color: var(--text-strong);
}

/* Formuláre */
:is(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
  min-height: 38px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  color: var(--text);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 3%, transparent);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast);
}
:is(input:not([type="checkbox"]):not([type="radio"]), textarea, select):hover {
  border-color: color-mix(in srgb, var(--border2) 55%, var(--accent));
}
:is(input:not([type="checkbox"]):not([type="radio"]), textarea, select):focus {
  border-color: var(--accent-hi);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}
:is(input, textarea, select):disabled {
  cursor: not-allowed;
  opacity: 0.58;
  background: var(--surface-sunken);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.field { color: var(--muted); font-weight: 500; }
.field > input, .field > textarea, .field > select { margin-top: 2px; font-weight: 400; }

/* Všetky varianty tlačidiel používajú rovnakú geometriu a stavy. */
:is(.btn, .btn-sm, .btn-primary, .btn-danger, .icon-btn, .theme-toggle, .link-btn) {
  min-height: 36px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  line-height: 1.2;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), box-shadow var(--transition-fast),
    transform var(--transition-fast);
}
:is(.btn, .btn-sm, .icon-btn, .theme-toggle) {
  border: 1px solid var(--border2);
  background: var(--card2);
  color: var(--text);
}
:is(.btn, .btn-sm, .icon-btn, .theme-toggle):hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--border2) 45%, var(--accent));
  background: var(--control-hover);
  color: var(--text-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
:is(.btn-primary, .btn.btn-primary) {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 25%, transparent);
}
:is(.btn-primary, .btn.btn-primary):hover:not(:disabled) {
  border-color: var(--accent-hi);
  background: var(--accent-hi);
  color: white;
}
:is(.btn-danger, .btn.btn-danger):hover:not(:disabled) {
  background: color-mix(in srgb, var(--fail) 18%, var(--card));
}
:is(button, .btn, .btn-sm):active:not(:disabled) { transform: translateY(0); }
:is(button, .btn, .btn-sm):disabled { cursor: not-allowed; opacity: 0.48; box-shadow: none; }
.theme-toggle { width: 38px; padding: 0; font-size: 16px; }

/* Tabuľky */
:is(.dtable, .models-table, .doc-table, .extract-table, .comparison-table) {
  width: 100%;
  border-spacing: 0;
  color: var(--text);
}
:is(.dtable, .models-table, .doc-table, .extract-table, .comparison-table) th {
  border-bottom: 1px solid var(--border2);
  background: var(--card2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}
:is(.dtable, .models-table, .doc-table, .extract-table, .comparison-table) td {
  border-bottom-color: var(--border);
}
:is(.dtable, .models-table, .doc-table, .extract-table, .comparison-table) tbody tr {
  transition: background var(--transition-fast);
}
:is(.dtable, .models-table, .doc-table, .extract-table, .comparison-table) tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.table-scroll, .extract-table-wrap, .reference-table-scroll, .stats-detail-scroll {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  scrollbar-color: var(--border2) transparent;
}

/* Dialógy, rozbaľovacie bloky a správy */
.overlay, .modal { background: var(--overlay-backdrop); backdrop-filter: blur(5px); }
.overlay-panel, .modal-box {
  border-color: var(--border2);
  border-radius: var(--radius-lg);
  background: var(--surface-overlay);
  box-shadow: var(--shadow-lg);
}
.overlay-head, .overlay-foot {
  background: color-mix(in srgb, var(--card2) 72%, transparent);
}
.stats-clear-dialog {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border2);
  border-radius: var(--radius-lg); background: var(--surface-overlay); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.stats-clear-dialog::backdrop { background: var(--overlay-backdrop); backdrop-filter: blur(5px); }
.stats-clear-dialog form { display: grid; gap: 14px; padding: 22px; }
.stats-clear-dialog h2, .stats-clear-dialog p { margin: 0; }
.stats-clear-option { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.stats-clear-all-option { border-color: color-mix(in srgb, var(--fail) 45%, var(--border)); }
.stats-clear-option .btn { justify-self: start; }
.stats-clear-actions { display: flex; justify-content: flex-end; }
details {
  border-color: var(--border);
  border-radius: var(--radius-sm);
}
summary { color: var(--text); }
summary:hover { color: var(--text-strong); }
.banner, .hint, .pdf-input-note, .analytics-explanation, .test-note {
  border-radius: var(--radius-sm);
}
.toast {
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  background: var(--surface-overlay);
  color: var(--text-strong);
  box-shadow: var(--shadow-md);
}
.empty-state {
  border: 1px dashed var(--border2);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--card2) 65%, transparent);
  color: var(--muted);
}

/* Prihlasovacia obrazovka používa rovnaký vizuálny jazyk. */
.login-layer {
  background:
    radial-gradient(circle at 50% 10%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 42%),
    var(--bg) !important;
}
.login-brand { padding: 0 12px; }
.login-wrap.card {
  border-color: var(--border2);
  border-radius: var(--radius-lg);
  background: var(--surface-overlay);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

@keyframes ui-enter {
  /* Do not transform the tab panel: a transformed ancestor changes the
     containing block of nested sticky controls in Chromium. */
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Tablet: kompaktný navigačný rail namiesto skrytej navigácie. */
@media (max-width: 980px) {
  .shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > div:last-child, .nav-item:not(.active) { font-size: 0; }
  .brand-name, .brand-sub, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding-inline: 8px; }
  .nav-item.active { font-size: 0; }
  .nav-glyph { width: auto; font-size: 16px; }
  .stats-model-nav, .profile-nav, .sidebar-user .username, .sidebar-user a { display: none !important; }
  .sidebar-user { justify-content: center; padding-inline: 0; }
  .screen-body { padding: 16px; }
  .topbar { padding-inline: 16px; }
  .models-layout, .prompts-layout, .overview-columns { grid-template-columns: 1fr; }
}

/* Telefón: navigácia sa zmení na spodný panel a nezmenšuje obsah zboku. */
@media (max-width: 680px) {
  body { padding-bottom: 64px; }
  .shell { display: block; min-height: calc(100vh - 64px); }
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    width: 100%;
    height: 64px;
    padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--border2);
    box-shadow: 0 -8px 24px color-mix(in srgb, var(--bg) 68%, transparent);
  }
  .sidebar .brand, .sidebar-user, .stats-model-nav, .profile-nav, .nav-section-title { display: none !important; }
  #mainNav { display: grid; grid-template-columns: repeat(11, minmax(28px, 1fr)); gap: 2px; }
  .nav-item, .nav-item.active, .nav-item:not(.active) {
    min-height: 48px;
    padding: 5px 2px;
    justify-content: center;
    font-size: 0;
    box-shadow: none;
  }
  .nav-glyph { font-size: 18px; }
  .topbar { min-height: 58px; padding: 10px 12px; gap: 8px; }
  .topbar-title { font-size: 16px; }
  .topbar-sub, .search-input { display: none; }
  .topbar .btn-primary {
    position: relative;
    min-width: 38px;
    max-width: 38px;
    padding-inline: 0;
    overflow: hidden;
    color: transparent;
    white-space: nowrap;
  }
  .topbar .btn-primary::after {
    content: "▶";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: white;
    font-size: 13px;
  }
  .theme-toggle { flex: 0 0 38px; }
  .screen-body { padding: 12px; }
  .card { padding: 14px; margin-bottom: 10px; }
  .row { align-items: stretch; }
  .field { max-width: none; }
  select { max-width: 100%; min-width: 0; }
  .modal, .overlay { padding: 8px; align-items: flex-end; }
  .modal-box, .overlay-panel { width: 100%; max-height: 94vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .doc-modal-body, .gt-editor-body { grid-template-columns: 1fr; }
  .gt-editor-panel { height: 94vh; }
  .gt-preview { min-height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}