/* ===========================================================================
   HANSAFLEX SKU Extractor — shared design system
   Chrome (header + sidebar) and reusable components for every page.
   Page-specific styles live in each template's {% block head %}; the
   results page additionally loads static/results.css (built on these tokens).
   =========================================================================== */

:root {
  /* Brand — sampled from the official HANSA-FLEX Pneumatics datasheet
     (navy #1a2a5c exact; red is the HANSA-FLEX signal red, sample ≈ #e1221a) */
  --hf-navy:        #1a2a5c;
  --hf-navy-2:      #25357a;
  --hf-red:         #e2001a;
  --hf-red-logo:    #e2001a;

  /* Neutrals */
  --hf-ink:         #1a2a3a;
  --hf-ink-soft:    #545e70;
  --hf-muted:       #8a96a6;
  --hf-bg:          #f5f6f8;
  --hf-bg-2:        #eef0f4;
  --hf-surface:     #ffffff;
  --hf-border:      #e6e8ed;
  --hf-border-2:    #d4d8e0;

  /* States */
  --hf-green:       #2e7d32;
  --hf-green-bg:    #e8f5e9;
  --hf-red-bg:      #fef2f2;

  /* Metrics */
  --header-h:       53px;
  --rail-w:         184px;
  --content-max:    1640px;   /* shared page width (matches the results report) */
  --page-pad-x:     40px;     /* shared horizontal page padding */
  --radius:         8px;
  --radius-sm:      6px;
  --radius-xs:      4px;
  --ring:           0 0 0 3px rgba(226, 0, 26, .14);
  --ring-navy:      0 0 0 3px rgba(26, 42, 92, .16);
  --shadow-card:    0 1px 3px rgba(26, 42, 92, .06);
  --shadow-pop:     0 18px 60px rgba(0, 0, 0, .3);
  --ease:           .14s cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  color: var(--hf-ink);
  background: var(--hf-bg);
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { text-decoration: none; color: inherit; }

.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

/* Visible keyboard focus everywhere ---------------------------------------- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--hf-red);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ===========================================================================
   HEADER
   =========================================================================== */
.hf-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--hf-surface);
  border-bottom: 1px solid var(--hf-border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
}
.hf-header .left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.hf-logo { display: inline-flex; flex-shrink: 0; }
.hf-logo img { display: block; height: 38px; width: auto; }
.hf-sub {
  font-size: 13px;
  color: var(--hf-muted);
  font-weight: 600;
  white-space: nowrap;
}
.hf-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hf-chip {
  font-size: 11px;
  color: var(--hf-ink-soft);
  background: var(--hf-bg-2);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-weight: 700;
  white-space: nowrap;
}
.hf-chip.mono { font-weight: 600; }

/* Mobile menu toggle (hidden on desktop) ----------------------------------- */
.hf-burger {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--hf-border);
  background: var(--hf-surface);
  border-radius: var(--radius-sm);
  color: var(--hf-navy);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hf-burger:hover { background: var(--hf-bg-2); }

/* ===========================================================================
   LAYOUT: SIDEBAR + CONTENT
   =========================================================================== */
.hf-body { display: flex; min-height: calc(100vh - var(--header-h)); }

.nav-rail {
  width: var(--rail-w);
  flex-shrink: 0;
  background: var(--hf-navy);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  height: calc(100vh - var(--header-h));
}
.nav-section {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, .35);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: transparent;
  color: rgba(255, 255, 255, .65);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--ease), color var(--ease);
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.act { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-item.disabled { color: rgba(255, 255, 255, .30); cursor: default; pointer-events: none; }
.nav-item.disabled svg { opacity: .5; }
.nav-item.disabled:hover { background: transparent; color: rgba(255, 255, 255, .30); }
.nav-item .soon { margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: rgba(255, 255, 255, .45); border: 1px solid rgba(255, 255, 255, .22); border-radius: 999px; padding: 1px 6px; }
.nav-item .badge {
  margin-left: auto;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  border-radius: 8px;
  padding: 2px 6px;
}
.nav-grow { flex: 1; }
.nav-sep { height: 1px; background: rgba(255, 255, 255, .12); margin: 8px 10px; }

.nav-backdrop { display: none; }

.hf-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-h));
}

/* One shared content container for every page (forms, lists and the results
   report all share the same width + padding -> a single, consistent shell).
   Pages fill the full content area; long-form text is kept readable via the
   `.lead` cap and the field grids below, not by narrowing the whole page. */
.wrap {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px var(--page-pad-x) 72px;
}
.wrap.wide { max-width: none; }
.wrap.narrow { max-width: 920px; }   /* opt-in for short, single-column forms */

/* ===========================================================================
   PAGE HEADINGS
   =========================================================================== */
h1.title {
  position: relative;
  font-size: 20px;
  font-weight: 700;
  color: var(--hf-navy);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
/* HANSA-FLEX datasheet motif: a solid red marker bar set in the gutter before
   the page title (the "▌ Eigenschaften" cue from the printed datasheets). */
h1.title::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 0.92em;
  background: var(--hf-red);
  border-radius: 1px;
}
.lead { font-size: 13px; color: var(--hf-muted); margin-bottom: 28px; max-width: 64ch; }
.head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.summary { font-size: 13px; color: var(--hf-muted); margin-bottom: 20px; }
.summary b { color: var(--hf-red); }

.sec { margin-bottom: 24px; }
.sec h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--hf-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* ===========================================================================
   BUTTONS
   =========================================================================== */
.btn {
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--radius-xs);
  padding: 11px 20px;
  transition: filter var(--ease), background var(--ease), color var(--ease), box-shadow var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.93); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: progress; filter: none; transform: none; }
.btn-sm { padding: 8px 14px; font-size: 12px; gap: 6px; }
.btn-red { background: var(--hf-red); color: #fff; }
.btn-navy { background: var(--hf-navy); color: #fff; }
.btn-navy:hover { filter: brightness(1.12); }
.btn-out {
  background: var(--hf-surface);
  color: var(--hf-navy);
  border: 1px solid var(--hf-border-2);
}
.btn-out:hover { filter: none; border-color: var(--hf-navy); background: var(--hf-bg-2); }

/* ===========================================================================
   CARDS
   =========================================================================== */
.card {
  background: var(--hf-surface);
  border: 1px solid var(--hf-border);
  border-radius: var(--radius);
  padding: 18px;
}

/* ===========================================================================
   FORM FIELDS
   =========================================================================== */
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--hf-ink-soft);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 9px 11px;
  border: 1px solid var(--hf-border-2);
  border-radius: var(--radius-xs);
  background: var(--hf-surface);
  color: var(--hf-ink);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--hf-red); box-shadow: var(--ring); }
.field input.active-ring { border-color: var(--hf-navy); background: #fbfcfe; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Responsive field grid: lays form fields out across the full page width,
   wrapping to fewer columns as space shrinks. Used wherever a form should
   fill the screen rather than sit in a narrow column. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 18px;
}
.field-grid .field { margin-bottom: 0; }
.field-grid .span-2 { grid-column: span 2; }
.field-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 620px) { .field-grid .span-2 { grid-column: 1 / -1; } }

.hint { font-size: 11px; color: var(--hf-muted); margin-top: 10px; }

/* Filter / search box used in list toolbars ------------------------------- */
.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid var(--hf-border-2);
  border-radius: var(--radius-sm);
  background: var(--hf-surface);
  color: var(--hf-ink);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search-input:focus { border-color: var(--hf-red); box-shadow: var(--ring); }

/* Compact row / card action button ---------------------------------------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  background: var(--hf-surface);
  border: 1px solid var(--hf-border-2);
  color: var(--hf-navy);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.icon-btn:hover { background: var(--hf-navy); color: #fff; border-color: var(--hf-navy); }
.icon-btn--danger { color: var(--hf-red); border-color: #f0c9cd; }
.icon-btn--danger:hover { background: var(--hf-red); color: #fff; border-color: var(--hf-red); }

/* ===========================================================================
   FLASH MESSAGES (success / error)
   =========================================================================== */
.flash {
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  margin-bottom: 18px;
  border-left: 3px solid;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.flash p { margin: 0; font-size: 13px; color: var(--hf-ink); }
.flash::before { font-weight: 700; line-height: 1.4; flex-shrink: 0; }
.flash.success { background: var(--hf-green-bg); border-left-color: var(--hf-green); }
.flash.success::before { content: "✓"; color: var(--hf-green); }
.flash.error { background: var(--hf-red-bg); border-left-color: var(--hf-red); }
.flash.error::before { content: "⚠"; color: var(--hf-red); }

/* ===========================================================================
   SPINNER
   =========================================================================== */
.spinner { display: inline-flex; gap: 6px; }
.spinner span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--hf-navy);
  animation: hf-bounce 1.2s infinite ease-in-out;
}
.spinner span:nth-child(2) { animation-delay: .15s; background: var(--hf-red); }
.spinner span:nth-child(3) { animation-delay: .3s; }
@keyframes hf-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-10px); opacity: 1; }
}

/* Full-screen processing overlay ------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(245, 246, 248, .95);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.overlay.on { display: flex; }
.overlay .lt { font-size: 15px; font-weight: 700; color: var(--hf-navy); }
.overlay .ls { font-size: 12px; color: var(--hf-muted); }

/* ===========================================================================
   EMPTY STATE
   =========================================================================== */
.empty-state { text-align: center; padding: 64px 24px; color: var(--hf-muted); }
.empty-state .ic { font-size: 42px; opacity: .25; margin-bottom: 14px; }
.empty-state h2 { font-size: 16px; color: var(--hf-navy); margin-bottom: 8px; font-weight: 700; }
.empty-state p { font-size: 13px; }

/* ===========================================================================
   RESPONSIVE: collapse the sidebar into an off-canvas drawer
   =========================================================================== */
@media (max-width: 860px) {
  .hf-burger { display: inline-flex; }

  .nav-rail {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100vh - var(--header-h));
    transform: translateX(-100%);
    transition: transform var(--ease);
    z-index: 60;
    box-shadow: var(--shadow-pop);
  }
  body.nav-open .nav-rail { transform: translateX(0); }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(20, 30, 50, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ease);
    z-index: 50;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  .wrap { padding: 22px 18px 56px; }
  .wrap.wide { padding: 22px 18px 56px; }
}

@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .hf-header { padding: 10px 14px; }
  .hf-logo img { height: 32px; }
}

/* ===========================================================================
   GLOBAL UX ADDITIONS
   Skip-link, toasts, progress bar, dismissible flashes, back-to-top,
   styled file inputs, collapsible hints, reduced motion.
   =========================================================================== */

/* Skip to content (a11y) ---------------------------------------------------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 200;
  background: var(--hf-navy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  transition: top var(--ease);
}
.skip-link:focus-visible { top: 10px; outline: 2px solid var(--hf-red); outline-offset: 2px; }

/* Slim top progress bar (page navigations / form submits) ------------------- */
.hf-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  z-index: 300;
  background: linear-gradient(90deg, var(--hf-red), #ff5f52);
  box-shadow: 0 0 8px rgba(226, 0, 26, .5);
  opacity: 0;
  transition: width .25s ease, opacity .3s ease;
  pointer-events: none;
}
.hf-progress.on { opacity: 1; }

/* Toast notifications -------------------------------------------------------- */
.hf-toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}
.hf-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--hf-surface);
  border: 1px solid var(--hf-border);
  border-left: 3px solid var(--hf-navy);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(26, 42, 92, .18);
  padding: 11px 12px 11px 14px;
  font-size: 13px;
  color: var(--hf-ink);
  line-height: 1.4;
  animation: hf-toast-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
.hf-toast.success { border-left-color: var(--hf-green); }
.hf-toast.error   { border-left-color: var(--hf-red); }
.hf-toast .tic { flex-shrink: 0; font-weight: 800; }
.hf-toast.success .tic { color: var(--hf-green); }
.hf-toast.error   .tic { color: var(--hf-red); }
.hf-toast .tx { color: var(--hf-navy); }
.hf-toast .tclose {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--hf-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  font-weight: 700;
}
.hf-toast .tclose:hover { color: var(--hf-red); }
.hf-toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
@keyframes hf-toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Dismissible flash messages ------------------------------------------------- */
.flash { position: relative; padding-right: 38px; }
.flash .flash-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--hf-muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-xs);
}
.flash .flash-close:hover { color: var(--hf-red); background: rgba(0, 0, 0, .05); }
.flash.leaving { opacity: 0; transform: translateY(-4px); transition: opacity .3s, transform .3s; }

/* Back-to-top button ---------------------------------------------------------- */
.hf-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--hf-border-2);
  background: var(--hf-surface);
  color: var(--hf-navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(26, 42, 92, .18);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--ease), transform var(--ease), background var(--ease), color var(--ease);
}
.hf-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.hf-top:hover { background: var(--hf-navy); color: #fff; border-color: var(--hf-navy); }
/* Keep clear of the toast stack */
.hf-toasts { bottom: 74px; }

/* Busy submit buttons (double-submit protection) ------------------------------ */
.btn.is-busy, button.is-busy {
  position: relative;
  pointer-events: none;
  opacity: .65;
}
.btn.is-busy::after, button.is-busy::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: hf-spin .7s linear infinite;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -2px;
}
@keyframes hf-spin { to { transform: rotate(360deg); } }

/* Nicer native file inputs ----------------------------------------------------- */
input[type="file"] { color: var(--hf-ink-soft); font-size: 12px; }
input[type="file"]::file-selector-button {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--hf-navy);
  background: var(--hf-surface);
  border: 1px solid var(--hf-border-2);
  border-radius: var(--radius-xs);
  padding: 7px 12px;
  margin-right: 10px;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
input[type="file"]::file-selector-button:hover {
  background: var(--hf-navy);
  color: #fff;
  border-color: var(--hf-navy);
}

/* Collapsible long help texts ---------------------------------------------------- */
details.hint-details { font-size: 11px; color: var(--hf-muted); flex-basis: 100%; margin-top: 2px; }
details.hint-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--hf-ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  list-style: none;
  border-radius: var(--radius-xs);
  padding: 2px 4px;
  margin-left: -4px;
}
details.hint-details summary::-webkit-details-marker { display: none; }
details.hint-details summary::before {
  content: "▸";
  font-size: 10px;
  transition: transform var(--ease);
  color: var(--hf-muted);
}
details.hint-details[open] summary::before { transform: rotate(90deg); }
details.hint-details summary:hover { color: var(--hf-navy); }
details.hint-details .hint { margin-top: 6px; line-height: 1.55; }

/* Search shortcut hint (kbd) ------------------------------------------------------ */
kbd.kbd {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--hf-ink-soft);
  background: var(--hf-bg-2);
  border: 1px solid var(--hf-border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
}

/* Small screens: drop the header subtitle to avoid crowding ------------------------ */
@media (max-width: 560px) {
  .hf-sub { display: none; }
  .hf-top { right: 14px; bottom: 14px; }
  .hf-toasts { right: 12px; bottom: 66px; }
}

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

/* Language switcher in the nav rail ------------------------------------------- */
.nav-lang {
  display: flex;
  gap: 6px;
  padding: 4px 10px 6px;
}
.lang-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, .22);
  color: rgba(255, 255, 255, .65);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .8px;
  text-decoration: none;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.lang-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.lang-btn.act {
  background: var(--hf-red);
  border-color: var(--hf-red);
  color: #fff;
  cursor: default;
}
