/* FixUnit design tokens + reset — shared by every page.
   Single-binary, offline-first app: no CDN fonts, no external assets.
   System font stack only. */

:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-surface-alt: #f0f2f5;
  --color-border: #dde2e8;
  --color-text: #1a2233;
  --color-text-muted: #667085;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-contrast: #ffffff;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-success: #16a34a;
  --color-success-bg: #ecfdf3;
  --color-warning: #b7791f;
  --color-warning-bg: #fef6e4;
  --color-primary-soft: rgba(37, 99, 235, 0.1);
  --color-row-hover: #f7f9fc;
  --color-focus-ring: rgba(37, 99, 235, 0.35);
  --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, 0.16), 0 2px 6px rgba(16, 24, 40, 0.08);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --control-h: 40px;
  /* Spacing scale — the de facto values the codebase already used by feel
     (see DESIGN.md "Spacing"), now named so new rules stop drifting. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --radius-xl: 20px;
  /* Shell chrome. The sidebar gets its own token names — not because it
     departs from the theme (it must not; it follows light/dark like every
     other surface) but because its states are tuned for a tall column of nav
     rows rather than for cards, and naming them keeps that tuning in one
     place instead of re-derived across a dozen rules. */
  --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
  --sidebar-text: var(--color-text);
  --sidebar-text-muted: var(--color-text-muted);
  --sidebar-hover-bg: var(--color-surface-alt);
  --sidebar-active-bg: linear-gradient(90deg, rgba(37, 99, 235, 0.14), rgba(99, 102, 241, 0.03));
  --sidebar-active-text: var(--color-primary);
  --sidebar-divider: var(--color-border);
  --sidebar-shadow: 0 10px 30px rgba(16, 24, 40, 0.09), 0 1px 2px rgba(16, 24, 40, 0.05);
  --sidebar-scroll-thumb: rgba(16, 24, 40, 0.18);
  /* Backdrop behind an uploaded company logo, which may be dark-on-
     transparent or light-on-transparent — a neutral plate reads correctly for
     both, in either theme. */
  --sidebar-logo-bg: var(--color-surface-alt);
  /* Translucent so content scrolling underneath is felt rather than hidden;
     paired with backdrop-filter in dashboard.css. */
  --header-bg: rgba(255, 255, 255, 0.72);
  --brand-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  /* The canvas behind the floating panels — a faint tint rather than flat
     gray, so the white cards on top of it read as lifted. */
  --canvas-bg: radial-gradient(1200px 600px at 78% -8%, rgba(99, 102, 241, 0.1), transparent 62%), var(--color-bg);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0f1420;
    --color-surface: #171d2c;
    --color-surface-alt: #1e2536;
    --color-border: #2a3245;
    --color-text: #e7eaf0;
    --color-text-muted: #96a0b5;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --color-primary-contrast: #0b1020;
    --color-danger: #f87171;
    --color-danger-bg: #3a1a1a;
    --color-success: #4ade80;
    --color-success-bg: #12291c;
    --color-warning: #fbbf24;
    --color-warning-bg: #33280f;
    --color-primary-soft: rgba(59, 130, 246, 0.16);
    --color-row-hover: #1b2233;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
    --radius-xl: 20px;
    /* Dark mode: the canvas is near-black, so the sidebar separates by sitting
       slightly ABOVE it — the same relationship the light theme has, inverted.
       Active text goes white rather than primary, which on this background
       would be the dimmer of the two. */
    --sidebar-bg: linear-gradient(180deg, #1d2536 0%, #151b29 100%);
    --sidebar-text: var(--color-text);
    --sidebar-text-muted: var(--color-text-muted);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: linear-gradient(90deg, rgba(59, 130, 246, 0.3), rgba(99, 102, 241, 0.08));
    --sidebar-active-text: #ffffff;
    --sidebar-divider: var(--color-border);
    --sidebar-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
    --sidebar-scroll-thumb: rgba(255, 255, 255, 0.18);
    --sidebar-logo-bg: rgba(255, 255, 255, 0.92);
    --header-bg: rgba(23, 29, 44, 0.72);
    --brand-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --canvas-bg: radial-gradient(1200px 600px at 78% -8%, rgba(99, 102, 241, 0.12), transparent 62%), var(--color-bg);
  }
}

:root[data-theme="dark"] {
  --color-bg: #0f1420;
  --color-surface: #171d2c;
  --color-surface-alt: #1e2536;
  --color-border: #2a3245;
  --color-text: #e7eaf0;
  --color-text-muted: #96a0b5;
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-contrast: #0b1020;
  --color-danger: #f87171;
  --color-danger-bg: #3a1a1a;
  --color-success: #4ade80;
  --color-success-bg: #12291c;
  --color-warning: #fbbf24;
  --color-warning-bg: #33280f;
  --color-primary-soft: rgba(59, 130, 246, 0.16);
  --color-row-hover: #1b2233;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  --radius-xl: 20px;
  /* Dark mode: the canvas is near-black, so the sidebar separates by sitting
     slightly ABOVE it — the same relationship the light theme has, inverted.
     Active text goes white rather than primary, which on this background
     would be the dimmer of the two. */
  --sidebar-bg: linear-gradient(180deg, #1d2536 0%, #151b29 100%);
  --sidebar-text: var(--color-text);
  --sidebar-text-muted: var(--color-text-muted);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: linear-gradient(90deg, rgba(59, 130, 246, 0.3), rgba(99, 102, 241, 0.08));
  --sidebar-active-text: #ffffff;
  --sidebar-divider: var(--color-border);
  --sidebar-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
  --sidebar-scroll-thumb: rgba(255, 255, 255, 0.18);
  --sidebar-logo-bg: rgba(255, 255, 255, 0.92);
  --header-bg: rgba(23, 29, 44, 0.72);
  --brand-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --canvas-bg: radial-gradient(1200px 600px at 78% -8%, rgba(99, 102, 241, 0.12), transparent 62%), var(--color-bg);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--color-primary);
}

/* --- Form controls --- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
}

.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  /* Recessed look (surface-alt, not plain surface) so a field still reads
     against a modal or the page panel, both of which are --color-surface
     themselves — otherwise an un-focused input is only a 1px border away
     from disappearing into its own background. */
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  min-height: var(--control-h);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.field textarea {
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 0.8;
}

.field input:hover:not(:focus):not(:disabled),
.field select:hover:not(:focus):not(:disabled),
.field textarea:hover:not(:focus):not(:disabled) {
  border-color: var(--color-text-muted);
}

.field select {
  cursor: pointer;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.field input.field-invalid,
.field select.field-invalid,
.field textarea.field-invalid {
  border-color: var(--color-danger);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* A read-only input is still focusable and copyable, so it keeps the normal
   text colour — but it must not invite typing that will be discarded. */
.field input[readonly],
.field textarea[readonly] {
  background: var(--color-surface-alt);
  cursor: default;
}

/* An empty .field-error used to reserve 15px under every input (plus the
   6px flex gap) whether or not there was an error — the main reason modal
   forms felt so spread out. It now takes no space until a message arrives. */
.field-error {
  color: var(--color-danger);
  font-size: 12.5px;
}

.field-error:empty {
  display: none;
}

/* Small helper text under an input (format hints, what a field is for). */
.field-hint {
  color: var(--color-text-muted);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* .btn is used on <a> as well as <button> (the "Tidak ada akses" panel's
     way back to the Dashboard, for one) — without this the anchor keeps the
     browser's default underline and reads as a link wearing a button. */
  text-decoration: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  padding: 9px 16px;
  min-height: var(--control-h);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* Keyboard focus is always visible (mouse clicks stay ring-free via
   :focus-visible) — staff who tab through a form can see where they are. */
.btn:focus-visible,
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.btn-sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 13px;
}

.btn:disabled {
  cursor: default;
  opacity: 0.75;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-block {
  width: 100%;
}

/* --- Button icon — a leading emoji glyph inside a .btn, e.g.
   <button class="btn btn-primary"><span class="btn-icon" aria-hidden="true">
   ➕</span><span data-i18n="...">Tambah Produk</span></button>. The label
   stays in its own inner span (not the button's own textContent) precisely
   so I18n.apply() — which does el.textContent = ... — replaces only that
   span's text on a language switch instead of wiping the icon out too. */
.btn-icon {
  font-size: 14px;
  line-height: 1;
  flex: none;
}

/* --- Spinner (used by ui.js buttonLoading / sectionLoading) --- */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: fx-spin 0.6s linear infinite;
  flex: none;
}

.spinner-lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

/* --- Toggle track (Ganti Bahasa / Tampilan in the dashboard header
   dropdown; the top-right language switch on the pre-auth Login/Install
   pages) — lives here, not dashboard.css, so every page that needs a
   two-option pill toggle shares one definition instead of each page
   re-inventing (or, as happened before, omitting) its own styling. --- */

.theme-toggle-track {
  display: flex;
  gap: 2px;
  background: var(--color-surface-alt);
  border-radius: 999px;
  padding: 2px;
}

.theme-toggle-option {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--color-text-muted);
}

.theme-toggle-option.is-active {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

/* --- Top-right corner placement for a toggle on a pre-auth page (Login,
   Install) — those pages have no header/dropdown to tuck it into, so it
   floats fixed at the viewport corner instead. --- */

.corner-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  *:not(.spinner),
  *:not(.spinner)::before,
  *:not(.spinner)::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes fx-spin {
  to {
    transform: rotate(360deg);
  }
}

.section-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  color: var(--color-text-muted);
}

/* --- Alert banner --- */

.alert {
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.alert-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* For a report that rendered correctly but rests on missing master data —
   something to act on, not an error to recover from. */
.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.alert.is-visible {
  display: block;
}

/* An identifier shown for copying — an invoice number, an ID. Tabular so the
   characters sit in even columns, and selectable as one word so a
   double-click takes the whole thing. */
.kv-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
  letter-spacing: 0.01em;
  user-select: all;
}
