/* ============================================================================
   Shelfwise design tokens
   ----------------------------------------------------------------------------
   Every colour, radius and spacing value used by the UI resolves to a token here.
   To re-skin the product, change this file only — no component edits required.

   Tokens are exposed as CSS custom properties so they can also be overridden at
   runtime (e.g. from an OpenBao setting) without a rebuild.

   Palette direction: warm and muted. No pure black, no saturated blue, no neon
   green. The reference (DevSikt) proved that an operational UI reads calmer when
   the surfaces are off-white rather than grey and the accent is an earth tone
   rather than a signal colour. Shelfwise keeps that temperature but uses its own
   accent — a deep teal — because merchandising is about stock and shelves, not
   developer tooling. See docs/szablon-devsikt-analiza.md.
   ========================================================================== */

:root {
  /* ---- brand ------------------------------------------------------------ */
  /* Deep teal: reads as "operational" without the alarm quality of blue. */
  --sw-primary: #1f5f5b;
  --sw-primary-hover: #174a47;
  --sw-primary-soft: #e8f1f0;
  --sw-accent: #8a6a3f;

  /* ---- surfaces --------------------------------------------------------- */
  /* Canvas is warm off-white; the rail is a shade cooler so the sidebar reads as
     a separate plane without needing a shadow. */
  --sw-bg: #fafaf8;
  --sw-surface: #ffffff;
  --sw-surface-raised: #ffffff;
  --sw-surface-sunken: #f1f2ee;
  --sw-border: #dfe2da;
  --sw-border-strong: #c9cec2;

  /* ---- text ------------------------------------------------------------- */
  /* Ink carries a faint green cast so it sits with the warm surfaces rather than
     against them; pure #000 looks like a hole in this palette. */
  --sw-text: #242725;
  --sw-text-muted: #626960;
  --sw-text-subtle: #8b9187;
  --sw-text-on-primary: #ffffff;

  /* ---- semantic --------------------------------------------------------- */
  /* Muted, not signal-bright: a status word should inform, not alarm. */
  --sw-success: #257344;
  --sw-warning: #8a6a3f;
  --sw-danger: #a33a2c;
  --sw-info: #3f5f7a;

  /* ---- geometry --------------------------------------------------------- */
  /* One radius for everything. Multiple radii are the fastest way to make a
     restrained UI look assembled from parts. */
  --sw-radius-sm: 4px;
  --sw-radius: 6px;
  --sw-radius-lg: 6px;
  --sw-radius-pill: 999px;

  /* ---- spacing scale ---------------------------------------------------- */
  --sw-space-1: 4px;
  --sw-space-2: 8px;
  --sw-space-3: 12px;
  --sw-space-4: 16px;
  --sw-space-5: 24px;
  --sw-space-6: 32px;
  --sw-space-7: 48px;

  /* ---- layout ----------------------------------------------------------- */
  --sw-sidebar-width: 240px;
  --sw-sidebar-width-collapsed: 64px;
  --sw-topbar-height: 56px;

  /* ---- elevation -------------------------------------------------------- */
  /* Shadows are barely there: separation comes from borders and surface colour,
     not from floating cards. */
  --sw-shadow-sm: 0 1px 2px rgba(36, 39, 37, 0.04);
  --sw-shadow: 0 2px 8px rgba(36, 39, 37, 0.06);
  --sw-shadow-lg: 0 8px 24px rgba(36, 39, 37, 0.10);

  /* ---- typography ------------------------------------------------------- */
  --sw-font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --sw-font-mono: "JetBrains Mono", "Cascadia Code", monospace;
  --sw-text-xs: 0.75rem;
  --sw-text-sm: 0.875rem;
  --sw-text-base: 1rem;
  --sw-text-lg: 1.125rem;
  --sw-text-xl: 1.375rem;

  /* ---- motion ----------------------------------------------------------- */
  --sw-transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme: flip the surface and text tokens, keep brand hues. */
[data-theme="dark"] {
  --sw-bg: #0b0e14;
  --sw-surface: #131820;
  --sw-surface-raised: #1a2029;
  --sw-surface-sunken: #0f141b;
  --sw-border: #232b36;
  --sw-border-strong: #323c4a;
  --sw-text: #e7ecf3;
  --sw-text-muted: #98a4b5;
  --sw-text-subtle: #6b7788;
  --sw-primary-soft: #16233b;
  --sw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sw-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  --sw-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* ---------------------------------------------------------------------------
   Base
   ------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sw-font);
  font-size: var(--sw-text-base);
  line-height: 1.55;
  color: var(--sw-text);
  background: var(--sw-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sw-space-3);
  font-weight: 600;
  line-height: 1.25;
  /* Negative tracking on headings is the signature of the reference theme: without it the
     type reads as generic Bootstrap, with it the UI looks deliberately set. */
  letter-spacing: -0.02em;
}

h1 {
  font-size: var(--sw-text-xl);
  letter-spacing: -0.025em;
}

h2 { font-size: var(--sw-text-lg); }

p { margin: 0 0 var(--sw-space-3); }

a {
  color: var(--sw-primary);
  text-decoration: none;
  transition: color var(--sw-transition);
}

a:hover { color: var(--sw-primary-hover); }

code, pre {
  font-family: var(--sw-font-mono);
  font-size: 0.9em;
}

/* Visible focus for keyboard users — WCAG 2.4.7 */
:focus-visible {
  outline: 2px solid var(--sw-primary);
  outline-offset: 2px;
  border-radius: var(--sw-radius-sm);
}

/* ---------------------------------------------------------------------------
   Layout: navigation left, content right
   ------------------------------------------------------------------------- */
.sw-shell {
  display: grid;
  grid-template-columns: var(--sw-sidebar-width) 1fr;
  grid-template-rows: var(--sw-topbar-height) 1fr;
  grid-template-areas:
    "topbar  topbar"
    "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns var(--sw-transition);
}

.sw-shell--collapsed {
  grid-template-columns: var(--sw-sidebar-width-collapsed) 1fr;
}

.sw-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--sw-space-4);
  padding: 0 var(--sw-space-5);
  background: var(--sw-surface);
  border-bottom: 1px solid var(--sw-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.sw-brand {
  display: flex;
  align-items: center;
  gap: var(--sw-space-3);
  font-weight: 700;
  font-size: var(--sw-text-lg);
  color: var(--sw-text);
  letter-spacing: -0.02em;
}

.sw-brand__mark {
  width: 32px;
  height: 32px;
  border-radius: var(--sw-radius-sm);
  background: linear-gradient(135deg, var(--sw-primary), var(--sw-accent));
  flex-shrink: 0;
}

.sw-topbar__spacer { flex: 1; }

.sw-main {
  grid-area: main;
  padding: var(--sw-space-5);
  overflow-x: hidden;
}

.sw-sidebar {
  grid-area: sidebar;
  /* The rail sits a shade cooler than the canvas, so it reads as a separate plane without a
     shadow. White sidebar on white content forces a shadow or a hard line to separate them. */
  background: var(--sw-surface-sunken);
  /* Border on the inner edge: the rail is now on the left, so the rule belongs on its right. */
  border-right: 1px solid var(--sw-border);
  padding: var(--sw-space-4) var(--sw-space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sw-space-1);
}

.sw-nav-group {
  margin-top: var(--sw-space-4);
  padding: 0 var(--sw-space-2);
  font-size: var(--sw-text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sw-text-subtle);
}

.sw-nav-item {
  display: flex;
  align-items: center;
  gap: var(--sw-space-3);
  padding: var(--sw-space-2) var(--sw-space-3);
  border-radius: var(--sw-radius-sm);
  color: var(--sw-text-muted);
  font-weight: 500;
  font-size: var(--sw-text-sm);
  transition: background var(--sw-transition), color var(--sw-transition);
  white-space: nowrap;
  overflow: hidden;
}

.sw-nav-item:hover {
  background: var(--sw-surface-sunken);
  color: var(--sw-text);
}

.sw-nav-item--active {
  background: var(--sw-primary-soft);
  color: var(--sw-primary);
  font-weight: 600;
}

.sw-nav-item__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.sw-shell--collapsed .sw-nav-item__label,
.sw-shell--collapsed .sw-nav-group {
  display: none;
}

/* ---------------------------------------------------------------------------
   Cards & primitives
   ------------------------------------------------------------------------- */
.sw-card {
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  padding: var(--sw-space-4);
  /* No shadow by default: separation comes from the border and the surface colour, as in the
     reference theme. A shadow on every card makes a dense operational screen look noisy. */
}

.sw-card--raised { box-shadow: var(--sw-shadow); }

.sw-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sw-space-4);
  /* A rule under the header separates it from the content without a card. */
  padding-bottom: var(--sw-space-4);
  margin-bottom: var(--sw-space-4);
  border-bottom: 1px solid var(--sw-border);
  flex-wrap: wrap;
}

.sw-page-header h1 { margin-bottom: var(--sw-space-1); }

.sw-page-header__sub {
  color: var(--sw-text-muted);
  font-size: var(--sw-text-sm);
  margin: 0;
}

.sw-grid {
  display: grid;
  gap: var(--sw-space-4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.sw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sw-space-2);
  padding: 0 var(--sw-space-3);
  border-radius: var(--sw-radius);
  border: 1px solid var(--sw-border);
  background: var(--sw-surface);
  color: var(--sw-text);
  font: inherit;
  font-size: var(--sw-text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--sw-transition), border-color var(--sw-transition);
  /* 44px: the smallest comfortable touch target, and it keeps button rows visually even. */
  min-height: 44px;
}

.sw-btn:hover { background: var(--sw-surface-sunken); }

.sw-btn--primary {
  background: var(--sw-primary);
  border-color: var(--sw-primary);
  color: var(--sw-text-on-primary);
}

.sw-btn--primary:hover {
  background: var(--sw-primary-hover);
  border-color: var(--sw-primary-hover);
}

.sw-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sw-space-1);
  padding: 2px var(--sw-space-2);
  border-radius: var(--sw-radius-pill);
  font-size: var(--sw-text-xs);
  font-weight: 600;
}

.sw-badge--success { background: color-mix(in srgb, var(--sw-success) 14%, transparent); color: var(--sw-success); }
.sw-badge--warning { background: color-mix(in srgb, var(--sw-warning) 14%, transparent); color: var(--sw-warning); }
.sw-badge--danger  { background: color-mix(in srgb, var(--sw-danger) 14%, transparent);  color: var(--sw-danger); }
.sw-badge--info    { background: color-mix(in srgb, var(--sw-info) 14%, transparent);    color: var(--sw-info); }

/* Status as a word, not a pill.
   A coloured chip draws the eye to every row; in a list of fifty work items that is noise.
   Plain coloured text carries the same meaning and keeps the table calm. Use .sw-badge only
   where the status must stand out from surrounding text. */
.sw-status {
  font-size: var(--sw-text-sm);
  color: var(--sw-text-muted);
}

.sw-status--success { color: var(--sw-success); }
.sw-status--warning { color: var(--sw-warning); }
.sw-status--danger  { color: var(--sw-danger); }
.sw-status--info    { color: var(--sw-info); }

.sw-stat__label {
  font-size: var(--sw-text-sm);
  color: var(--sw-text-muted);
  margin-bottom: var(--sw-space-1);
}

.sw-stat__value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.sw-stat__meta {
  font-size: var(--sw-text-xs);
  color: var(--sw-text-subtle);
  margin-top: var(--sw-space-2);
}

/* ---------------------------------------------------------------------------
   Responsive: the rail becomes a drawer on narrow screens
   ----------------------------------------------------------------------------
   Below 960px there is no room for a permanent column, so the rail slides in over the content
   instead of sitting under it. The earlier design made it a horizontal bar at the bottom, which
   forced sideways scrolling through fifteen items and left the menu permanently visible — on a
   phone that is worse than no menu at all.
   ------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .sw-shell,
  .sw-shell--collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: var(--sw-topbar-height) 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  /* The drawer leaves the grid and floats over the content. */
  .sw-sidebar {
    position: fixed;
    inset-block: var(--sw-topbar-height) 0;
    inset-inline-start: 0;
    width: min(84vw, 320px);
    z-index: 40;
    background: var(--sw-surface);
    border-right: 1px solid var(--sw-border);
    border-top: none;
    flex-direction: column;
    overflow-y: auto;
    padding: var(--sw-space-4) var(--sw-space-3);
    /* Off-canvas until opened. transform, not display, so it can animate. */
    transform: translateX(-100%);
    transition: transform var(--sw-transition);
    /* Hidden from the accessibility tree and from tab order while off-canvas.
       Deliberately NOT part of the transition: with prefers-reduced-motion the duration collapses
       to ~0, and a visibility transition at that duration leaves the drawer hidden even after the
       open class is applied. visibility flips instantly; only transform animates. */
    visibility: hidden;
  }

  .sw-sidebar--open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: var(--sw-shadow-lg);
  }

  /* Group headings belong in a vertical drawer. */
  .sw-nav-group { display: block; }

  /* Collapsing has no meaning in a drawer: the drawer is open or closed. */
  .sw-shell--collapsed .sw-nav-item__label { display: inline; }
  .sw-shell--collapsed .sw-nav-item { justify-content: flex-start; }

  .sw-scrim {
    position: fixed;
    inset: var(--sw-topbar-height) 0 0 0;
    z-index: 30;
    background: rgba(36, 39, 37, 0.32);
  }

  .sw-main { padding: var(--sw-space-4); }
}

/* The hamburger only exists on narrow screens; above the breakpoint the same button collapses
   the column instead, so its glyph is swapped by CSS rather than by server-side state. */
@media (min-width: 961px) {
  .sw-menu-toggle__icon::before { content: "»"; }
  .sw-menu-toggle__icon { font-size: 1rem; }

  .sw-shell--collapsed .sw-menu-toggle__icon::before { content: "«"; }
}

@media (max-width: 600px) {
  .sw-page-header { flex-direction: column; }
  .sw-topbar { padding: 0 var(--sw-space-4); }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  /* A near-zero transition on a transform that also flips visibility leaves the element stuck at
     its start value in some engines: the drawer never slides in, so the menu is unreachable for
     anyone with reduced motion enabled. Removing the transition entirely makes the state change
     instant and correct. */
  .sw-sidebar {
    transition: none !important;
  }
}
/* ---------------------------------------------------------------------------
   Authentication UI
   ------------------------------------------------------------------------- */
.sw-user {
  display: flex;
  align-items: center;
  gap: var(--sw-space-2);
  padding: var(--sw-space-1) var(--sw-space-2);
  border-radius: var(--sw-radius-pill);
  background: var(--sw-surface-sunken);
}

.sw-user__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sw-primary), var(--sw-accent));
  color: var(--sw-text-on-primary);
  font-size: var(--sw-text-xs);
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sw-user__name {
  font-size: var(--sw-text-sm);
  font-weight: 550;
  color: var(--sw-text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sw-space-5);
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--sw-primary) 8%, transparent), transparent 55%),
    radial-gradient(circle at 80% 80%, color-mix(in srgb, var(--sw-accent) 8%, transparent), transparent 55%),
    var(--sw-bg);
}

.sw-login__card {
  width: 100%;
  max-width: 400px;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius-lg);
  padding: var(--sw-space-6);
  box-shadow: var(--sw-shadow-lg);
  text-align: center;
}

.sw-brand--center {
  justify-content: center;
  margin-bottom: var(--sw-space-5);
}

.sw-login__title {
  font-size: var(--sw-text-xl);
  margin-bottom: var(--sw-space-2);
}

.sw-login__sub {
  color: var(--sw-text-muted);
  font-size: var(--sw-text-sm);
  margin-bottom: var(--sw-space-5);
}

.sw-btn--block {
  display: flex;
  width: 100%;
  justify-content: center;
  min-height: 44px;
}

@media (max-width: 600px) {
  .sw-user__name { display: none; }
}

/* ---------------------------------------------------------------------------
   Tenant switcher (topbar)
   ------------------------------------------------------------------------- */
.sw-tenant {
  display: flex;
  align-items: center;
  gap: var(--sw-space-2);
}

.sw-tenant__label {
  font-size: var(--sw-text-xs);
  color: var(--sw-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.sw-tenant__select {
  font: inherit;
  font-size: var(--sw-text-sm);
  padding: var(--sw-space-1) var(--sw-space-3);
  border-radius: var(--sw-radius-sm);
  border: 1px solid var(--sw-border-strong);
  background: var(--sw-surface);
  color: var(--sw-text);
  min-height: 34px;
  cursor: pointer;
}

.sw-tenant__select:hover { border-color: var(--sw-primary); }

/* Card variant without inner padding — for grids that manage their own spacing. */
.sw-card--flush { padding: 0; overflow: hidden; }

@media (max-width: 960px) {
  .sw-tenant__label { display: none; }
}

/* ============================================================================
   Syncfusion components
   ----------------------------------------------------------------------------
   Colour comes from wwwroot/syncfusion-shelfwise.css, which is generated from the
   --sw-* tokens above by tools/theme/generate-syncfusion-theme.mjs. Do not add
   colour overrides here — change the token and re-run the generator.

   What remains below is typography and geometry: Syncfusion's defaults for these
   are not tokenised, so they need explicit rules.
   ========================================================================== */

/* Header cells: small, muted, uppercase — the reference theme's table convention.
   Syncfusion renders them at body size and weight, which makes the header compete
   with the data instead of labelling it. */
.e-grid .e-headertext {
  font-size: var(--sw-text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  /* Syncfusion has no header-text variable: header cells inherit content-text-color, so the
     muted tone has to be set on the element. This is the one place colour is asserted here. */
  color: var(--sw-text-muted);
}

.e-grid .e-rowcell {
  font-size: var(--sw-text-sm);
}

/* The default Syncfusion focus ring is a blue outline that clashes with the palette. */
.e-grid .e-headercell:focus,
.e-grid .e-rowcell:focus,
.e-grid .e-gridcontent:focus {
  outline-color: var(--sw-primary);
}

.e-grid .e-pager .e-currentitem {
  border-radius: var(--sw-radius-sm);
}

/* ---------------------------------------------------------------------------
   Empty state
   ---------------------------------------------------------------------------
   A grid with no rows and no message looks broken. This says which case it is.
   ------------------------------------------------------------------------- */
.sw-empty {
  padding: var(--sw-space-6) var(--sw-space-4);
  text-align: center;
}

.sw-empty__title {
  margin: 0 0 var(--sw-space-1);
  font-size: var(--sw-text-sm);
  font-weight: 600;
  color: var(--sw-text);
}

.sw-empty__hint {
  margin: 0;
  font-size: var(--sw-text-sm);
  color: var(--sw-text-muted);
}

/* ---------------------------------------------------------------------------
   Edit form
   ------------------------------------------------------------------------- */
.sw-form {
  display: grid;
  gap: var(--sw-space-4);
  max-width: 720px;
}

.sw-form-actions {
  display: flex;
  gap: var(--sw-space-2);
  align-items: center;
}

.sw-alert {
  padding: var(--sw-space-3) var(--sw-space-4);
  border-radius: var(--sw-radius);
  border: 1px solid var(--sw-border);
  margin-bottom: var(--sw-space-4);
}

.sw-alert--danger {
  background: color-mix(in srgb, var(--sw-danger) 8%, transparent);
  border-color: color-mix(in srgb, var(--sw-danger) 30%, transparent);
}

.sw-alert__title {
  margin: 0 0 var(--sw-space-1);
  font-weight: 600;
  font-size: var(--sw-text-sm);
  color: var(--sw-danger);
}

.sw-alert__list {
  margin: 0;
  padding-left: var(--sw-space-4);
  font-size: var(--sw-text-sm);
  color: var(--sw-text);
}

.sw-btn--link {
  min-height: 32px;
  padding: 0 var(--sw-space-2);
  border: none;
  background: none;
  color: var(--sw-primary);
  text-decoration: underline;
}

.sw-field {
  display: grid;
  gap: var(--sw-space-1);
}

.sw-field--inline {
  display: flex;
  align-items: center;
  gap: var(--sw-space-2);
}

.sw-field__label {
  font-size: var(--sw-text-sm);
  font-weight: 500;
  color: var(--sw-text-muted);
}
