/* StockFlow Design System Theme Tokens & Component Styles */

:root {
  /* Brand Palette */
  --color-matcha: #395078;
  --color-matcha-dark: #273958;
  --color-matcha-light: #BAC8DA;
  
  --color-sylvan: #2E68B2;
  --color-sylvan-dark: #1C3E68;

  --color-vanilla: #DBD7D5;
  --color-paper: #FFFFFF;
  --color-tan: #C2BCB8;
  --color-ink: #1A2332;
  --color-muted: #505E72;

  /* Semantic Status Colors */
  --status-danger-bg: #FEE2E2;
  --status-danger-text: #7F1D1D;
  --status-warning-bg: #FDE3B0;
  --status-warning-text: #6B4208;
  --status-ok-bg: #D1E7DD;
  --status-ok-text: #14532D;

  /* Typography */
  --font-interface: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-numeric: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Base resets & typography */
body {
  font-family: var(--font-interface);
  background-color: var(--color-vanilla);
  color: var(--color-ink);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Numeric & Code elements: quantities, money, invoice numbers */
.font-mono,
.numeric-data,
.font-num,
[data-format="currency"],
[data-format="quantity"],
[data-format="invoice-no"] {
  font-family: var(--font-numeric) !important;
  font-variant-numeric: tabular-nums;
}

/* Flat Cards: 12px radius, 0.5px tan borders, no gradients, no heavy shadows */
.card-flat,
.flat-card {
  background-color: var(--color-paper);
  border: 0.5px solid var(--color-tan);
  border-radius: 12px;
  box-shadow: none !important;
  background-image: none !important;
}

/* Headers: matcha-dark with vanilla text */
.header-primary {
  background-color: var(--color-matcha-dark);
  color: var(--color-vanilla);
}

/* =========================================================================
   Buttons: 3 Standard Styles (Minimum 48px height on mobile)
   ========================================================================= */

/* Primary Button: matcha-dark background, vanilla text */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-matcha-dark);
  color: var(--color-vanilla);
  font-family: var(--font-interface);
  font-weight: 500;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 1.25rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease-in-out;
  box-sizing: border-box;
}

.btn-primary:hover {
  opacity: 0.92;
}

/* Secondary Button: paper background with matcha border */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-interface);
  font-weight: 500;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 1.25rem;
  border: 1px solid var(--color-matcha);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease-in-out;
  box-sizing: border-box;
}

.btn-secondary:hover {
  background-color: rgba(194, 188, 184, 0.25);
}

/* Danger Button: paper background with red text and border */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-paper);
  color: var(--status-danger-text);
  font-family: var(--font-interface);
  font-weight: 500;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 1.25rem;
  border: 1px solid var(--status-danger-text);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease-in-out;
  box-sizing: border-box;
}

.btn-danger:hover {
  background-color: #FEF2F2;
}

/* Tap Target standard: 48px minimum for mobile */
.tap-target,
.min-h-tap {
  min-height: 48px;
  box-sizing: border-box;
}

.min-w-tap {
  min-width: 48px;
  box-sizing: border-box;
}

/* =========================================================================
   Accents: Sylvan is ONLY for small accents
   ========================================================================= */
.accent-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-sylvan);
}

.tab-active {
  border-bottom: 3px solid var(--color-sylvan);
  color: var(--color-matcha-dark);
  font-weight: 600;
}

.stock-bar-healthy {
  background-color: var(--color-sylvan);
}

/* =========================================================================
   Status Badges & Chips
   ========================================================================= */
.badge-danger {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 0.5px solid #FCA5A5;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.badge-warning {
  background-color: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 0.5px solid #FCD34D;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.badge-ok {
  background-color: var(--status-ok-bg);
  color: var(--status-ok-text);
  border: 0.5px solid var(--color-matcha);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* Subtle 0.5px border utility */
.border-subtle {
  border: 0.5px solid var(--color-tan);
}
.border-b-subtle {
  border-bottom: 0.5px solid var(--color-tan);
}
.border-t-subtle {
  border-top: 0.5px solid var(--color-tan);
}

/* =========================================================================
   Forms: Visible labels, 16px min font on mobile, sylvan-dark focus ring
   ========================================================================= */
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-muted);
  margin-bottom: 0.375rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
  font-size: 16px !important; /* 16px min font on mobile prevents iOS auto-zoom */
  min-height: 48px;
  background-color: var(--color-paper);
  border: 0.5px solid var(--color-tan);
  border-radius: 8px;
  color: var(--color-ink);
  padding: 0.5rem 0.75rem;
  box-sizing: border-box;
  font-family: var(--font-interface);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input:focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-color: var(--color-sylvan-dark) !important;
  box-shadow: 0 0 0 2px var(--color-sylvan-dark) !important;
}

/* Accessible focus visible */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-sylvan-dark) !important;
  outline-offset: 2px;
}

/* Inline form errors in danger style */
.form-error,
.field-error,
.errorlist {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 0.5px solid #FCA5A5;
  border-radius: 6px;
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.375rem;
  list-style: none;
}

/* Disabled submit state while saving */
button[type="submit"]:disabled,
input[type="submit"]:disabled,
.htmx-request button[type="submit"],
.htmx-request input[type="submit"] {
  opacity: 0.6;
  cursor: not-allowed !important;
  pointer-events: none;
}

/* =========================================================================
   Tables: Sticky headers, container scrolling, JetBrains Mono numbers
   ========================================================================= */
.table-responsive-container {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table thead th {
  position: sticky;
  top: 0;
  background-color: var(--color-vanilla);
  z-index: 10;
}

td.text-right,
th.text-right,
.text-right,
td[data-align="right"] {
  text-align: right;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   HTMX Loading Indicator: Subtle top bar
   ========================================================================= */
.htmx-indicator {
  opacity: 0;
  transition: opacity 150ms ease-in-out;
  pointer-events: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}
