/**
 * client/packages/theme.css
 * --------------------------
 * Kang (Nature Basket) — design tokens (UI/UX §0.1 Design Plan).
 *
 * Every color, type, radius, shadow, spacing, and breakpoint value used
 * anywhere in the app is declared here as a CSS custom property. No page or
 * component may hardcode a hex value, a px radius, or a shadow — every later
 * phase's CSS reads through these tokens so the "one bold gradient moment,
 * everything around it calm" restraint principle stays enforceable app-wide
 * from one file.
 *
 * Load this BEFORE any component stylesheet in client/packages/components/.
 *
 * Font files: Baloo 2 / Inter / Noto Sans Tamil must be self-hosted under
 * client/packages/fonts/ (no CDN fetches, per Tech Stack §1.3 — nothing may
 * load from outside client/packages/). Drop the woff2 files in following the
 * paths referenced below; until then the system-font fallback stack keeps
 * every page legible.
 */

:root {
  /* ---------------------------------------------------------------------
   * Color — punchy white/orange/green, named and purposeful (UI/UX §0.1)
   * ------------------------------------------------------------------- */
  --basket-orange:      #FF7A1A; /* Primary action — CTAs, active nav, primary buttons */
  --basket-orange-deep: #E85D04; /* Gradient partner / pressed / hover */
  --leaf-green:         #1E9E5A; /* Success, Delivered, Packed, positive stock, confirm */
  --leaf-green-deep:    #127A43; /* Gradient partner / hover */
  --paper-white:        #FFFFFF; /* Base surface */
  --husk-cream:         #FFF8F0; /* Secondary surface / page background */
  --charcoal-ink:       #26221D; /* Primary text — warm near-black */
  --rust-alert:         #D64545; /* Errors, destructive actions, Returned */
  --amber-caution:      #F2A93B; /* Warnings, Pending, near-expiry stock */

  /* Derived / utility tones (not new brand colors — tints & text-on-color
     pairings needed structurally by components; kept minimal on purpose) */
  --charcoal-ink-muted: #6B655C; /* secondary text on paper/cream surfaces */
  --border-subtle:      #EFE3D6; /* hairline borders on cream/white surfaces */
  --overlay-scrim:      rgba(38, 34, 29, 0.55); /* modal/bottom-sheet backdrop */

  --basket-orange-tint: #FFE8D6; /* light tint fill — chips, drag-over states */
  --leaf-green-tint:    #DFF3E7; /* light tint fill — success banners/badges */
  --rust-alert-tint:    #FBE2E2; /* light tint fill — error banners/badges */
  --amber-caution-tint: #FDEDD3; /* light tint fill — warning banners/badges */

  /* The ONE signature gradient — used sparingly, one hero treatment per
     screen (dashboard header band, login backdrop, primary FAB). Never an
     all-over wash. Monochrome dark-to-dark, built from the brand's
     --leaf-green family (not a neutral black/brown) so every gradient
     surface in the app reads as one calm, deep forest-green tone. */
  --kang-gradient-hero: linear-gradient(135deg, #0F3D26, #071A11);
  --kang-gradient-hero-pressed: linear-gradient(135deg, #0A2E1C, #04120B);

  /* ---------------------------------------------------------------------
   * Typography (UI/UX §0.1)
   * ------------------------------------------------------------------- */
  --font-display: 'Baloo 2', 'Noto Sans Tamil', system-ui, sans-serif;
  --font-body-en: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body-ta: 'Noto Sans Tamil', system-ui, sans-serif;
  /* Components use var(--font-body) directly; sparrow.php's currentLanguage()
     helper (Phase 3) drives which one a page sets on <html lang> / <body>,
     with --font-body-ta layered in as an additional font in the stack so
     mixed EN/TA strings on one screen never fall back to tofu boxes. */
  --font-body: var(--font-body-en), var(--font-body-ta);

  /* Type scale — 1.25 ratio from a 16px base */
  --text-xs:   10.24px;
  --text-sm:   12.8px;
  --text-base: 16px;
  --text-md:   20px;
  --text-lg:   25px;
  --text-xl:   31.25px;
  --text-2xl:  39.06px;

  --font-weight-body:    400;
  --font-weight-label:   600;
  --font-weight-heading: 700;

  --line-length-max: 75ch; /* prose blocks: help text, notes fields */

  /* ---------------------------------------------------------------------
   * Radii — generous, consistent "curvy/soft structure" (UI/UX §0.1)
   * ------------------------------------------------------------------- */
  --radius-sm:   12px; /* chips, small buttons, inputs */
  --radius-md:   16px; /* cards, standard buttons */
  --radius-lg:   20px; /* content panels, modals */
  --radius-pill: 999px; /* pill switches, filter chips, pagination pills */
  --radius-circle: 50%; /* avatars, FAB, logo preview */

  /* ---------------------------------------------------------------------
   * Shadows — soft two-color, warm-tinted (never generic grey rgba(0,0,0,.1))
   * ------------------------------------------------------------------- */
  --shadow-sm: 0 1px 2px rgba(232, 93, 4, 0.06), 0 1px 1px rgba(38, 34, 29, 0.04);
  --shadow-md: 0 4px 12px rgba(232, 93, 4, 0.10), 0 2px 4px rgba(38, 34, 29, 0.06);
  --shadow-lg: 0 12px 28px rgba(232, 93, 4, 0.14), 0 4px 10px rgba(38, 34, 29, 0.08);
  --shadow-focus-ring: 0 0 0 3px rgba(255, 122, 26, 0.28); /* keyboard focus */

  /* ---------------------------------------------------------------------
   * Spacing scale
   * ------------------------------------------------------------------- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ---------------------------------------------------------------------
   * Layout / breakpoints (UI/UX §4 cross-portal responsive summary)
   * ------------------------------------------------------------------- */
  --bp-phone:  767px;  /* <768px: bottom nav takes over even for Admin */
  --bp-tablet: 1023px; /* 768–1023px: sidebar collapses to icon rail */
  --bp-desktop: 1439px; /* 1024–1439px: sidebar expanded */
  /* >=1440px: wide monitor, content max-width capped */

  --sidebar-width-expanded: 248px;
  --sidebar-width-rail: 76px;
  --bottom-nav-height: 64px;
  --content-max-width: 1320px; /* wide-monitor cap, generous margins */

  /* ---------------------------------------------------------------------
   * Motion
   * ------------------------------------------------------------------- */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
}

/* ---------------------------------------------------------------------
 * Self-hosted font faces — see file header. Fallback stack in --font-*
 * above keeps every page legible before/without these files present.
 * ------------------------------------------------------------------- */
@font-face {
  font-family: 'Baloo 2';
  src: url('fonts/baloo2/Baloo2-Regular.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter/Inter-Variable.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Sans Tamil';
  src: url('fonts/noto-sans-tamil/NotoSansTamil-Variable.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

/* ---------------------------------------------------------------------
 * Base element defaults built on the tokens above.
 * ------------------------------------------------------------------- */
html, body {
  margin: 0;
  padding: 0;
  background: var(--husk-cream);
  color: var(--charcoal-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-weight-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* never let a stray absolutely-positioned element
                         (e.g. an open Select2 dropdown) widen the page */
}

h1, h2, h3, h4, .kang-heading {
  font-family: var(--font-display);
  font-weight: var(--font-weight-heading);
  color: var(--charcoal-ink);
  margin: 0 0 var(--space-3) 0;
}

label, .kang-label {
  font-weight: var(--font-weight-label);
}

p, .kang-prose {
  max-width: var(--line-length-max);
}

a {
  color: var(--basket-orange-deep);
}

/* Focus visibility — accessible, on-brand (not the browser default blue) */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus-ring);
  border-radius: var(--radius-sm);
}

/* One hero gradient utility — apply to exactly one element per screen */
.kang-hero-gradient {
  background: var(--kang-gradient-hero);
  color: var(--paper-white);
}

/* Shared card surface used by every card-based component in later phases */
.kang-card {
  background: var(--paper-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
}

/* Status color utility classes — the fixed, app-wide status vocabulary */
.kang-status-success { color: var(--leaf-green); }
.kang-status-warning  { color: var(--amber-caution); }
.kang-status-danger   { color: var(--rust-alert); }
.kang-status-success-bg { background: var(--leaf-green-tint); color: var(--leaf-green-deep); }
.kang-status-warning-bg { background: var(--amber-caution-tint); color: var(--charcoal-ink); }
.kang-status-danger-bg  { background: var(--rust-alert-tint); color: var(--rust-alert); }

/* Screen-reader-only utility, used throughout the states/nav components */
.kang-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------------
 * Buttons — Phase 7 addition: states.js (Phase 4) already references
 * `.kang-btn-primary` on its empty-state CTA and session-expired modal's
 * submit button, but Phase 4 never shipped the class itself. Added here,
 * additively, rather than in states.css, since buttons are a base
 * typography/surface primitive (this file) not a "state" pattern. No
 * existing markup changes behavior — it simply starts rendering as
 * intended instead of unstyled.
 * ------------------------------------------------------------------- */
.kang-btn-primary,
.kang-btn-secondary {
  text-decoration: none; /* buttons are frequently <a> tags — never underline button text */
  line-height: 1.2;
  white-space: nowrap;
}

.kang-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  background: var(--kang-gradient-hero);
  color: var(--paper-white);
  font-family: var(--font-body);
  font-weight: var(--font-weight-label);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast) var(--ease-standard);
}
.kang-btn-primary:hover   { box-shadow: var(--shadow-md); color: var(--paper-white); }
.kang-btn-primary:active  { background: var(--kang-gradient-hero-pressed); transform: translateY(1px); }
.kang-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

.kang-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1.5px solid var(--border-subtle);
  background: var(--paper-white);
  color: var(--charcoal-ink);
  font-family: var(--font-body);
  font-weight: var(--font-weight-label);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.kang-btn-secondary:hover { border-color: var(--charcoal-ink); color: var(--charcoal-ink); }

.kang-btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }

/* ---------------------------------------------------------------------
 * Status toggle switch — `data-kang-toggle` pill switch used by the
 * product add/edit form, inventory matrix, and customer detail page.
 * Previously had no CSS at all, so it rendered as a bare native <button>
 * with plain nested spans. Styled here, once, as a shared component.
 * ------------------------------------------------------------------- */
.kang-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: none;
  background: transparent;
  padding: var(--space-1) 0;
  margin: 0;
  font-family: var(--font-body);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.kang-toggle-track {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--border-subtle);
  transition: background var(--duration-base) var(--ease-standard);
}

.kang-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-circle);
  background: var(--paper-white);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-base) var(--ease-standard);
}

.kang-toggle-label {
  font-weight: var(--font-weight-label);
  font-size: var(--text-sm);
  color: var(--charcoal-ink-muted);
  transition: color var(--duration-base) var(--ease-standard);
}

/* Active state — driven by the JS-managed aria-pressed attribute so the
   switch's visuals always match its real value, not just a CSS :hover/
   :active pseudo-state. */
.kang-toggle[aria-pressed="true"] .kang-toggle-track {
  background: var(--leaf-green);
}
.kang-toggle[aria-pressed="true"] .kang-toggle-knob {
  transform: translateX(20px);
}
.kang-toggle[aria-pressed="true"] .kang-toggle-label {
  color: var(--leaf-green-deep);
}

.kang-toggle:hover .kang-toggle-track {
  box-shadow: var(--shadow-sm);
}
.kang-toggle:focus-visible .kang-toggle-track {
  box-shadow: var(--shadow-focus-ring);
}
.kang-toggle:disabled,
.kang-toggle[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Any stray native-looking anchor/button that still carries a legacy
   underline (browser default on <a>, or an inherited link style) gets
   neutralized wherever it sits inside a button/action context. */
.kang-btn-primary:visited,
.kang-btn-secondary:visited,
.kang-btn-primary:focus,
.kang-btn-secondary:focus {
  text-decoration: none;
}

/* ---------------------------------------------------------------------
 * Login shell polish — shared by every portal's login.php (root, admin,
 * dev, customer, staff/packing, staff/transport). Each page already
 * defines its own `.kang-login-body` / `.kang-login-card` layout inline;
 * this just adds a consistent entrance animation and a slightly stronger
 * card shadow against the gradient backdrop, from one shared place so all
 * portals pick it up without duplicating the same rules five times.
 * ------------------------------------------------------------------- */
@keyframes kang-login-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kang-login-card {
  box-shadow: var(--shadow-lg);
  animation: kang-login-card-in var(--duration-slow) var(--ease-standard);
}
@media (prefers-reduced-motion: reduce) {
  .kang-login-card { animation: none; }
}
