/* ============================================================
   BASE.CSS — Reset, Design Tokens, Typography, Global Utils
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Zeploy Commercial Brand Palette */
  --canvas:         #F8FAFC;
  --surface:        #FFFFFF;
  --surface-raised: #F1F5F9;
  --border:         #CBD5E1;
  --border-soft:    #E2E8F0;

  --primary:        #3B82F6;
  --primary-dark:   #0F1C3F;
  --primary-light:  #AFD2FA;
  --primary-muted:  #F0F7FF;
  --zeploy-midnight: #0B1535;
  --zeploy-navy:     #0F1C3F;
  --zeploy-header:   #182350;
  --zeploy-accent:   #3B82F6;

  --stock-in:       #059669;
  --stock-in-bg:    #D1FAE5;
  --sale:           #4F46E5;
  --sale-bg:        #EDE9FE;
  --alert:          #D97706;
  --alert-bg:       #FEF3C7;
  --danger:         #DC2626;
  --danger-bg:      #FEE2E2;
  --spoilage:       #7C3AED;
  --spoilage-bg:    #EDE9FE;

  /* Semantic Color Aliases (used in components) */
  --success:        #059669;
  --success-bg:     #D1FAE5;
  --warning:        #D97706;
  --warning-bg:     #FEF3C7;
  --info:           #0EA5E9;
  --info-bg:        #E0F2FE;
  --teal:           #0D9488;
  --teal-bg:        #CCFBF1;

  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-inverse:   #FFFFFF;

  /* Typography */
  --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Spacing scale */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border radius — consistent scale */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px 0 rgb(15 23 42 / 0.06);
  --shadow-md:  0 4px 12px 0 rgb(15 23 42 / 0.08), 0 1px 3px 0 rgb(15 23 42 / 0.05);
  --shadow-lg:  0 10px 32px 0 rgb(15 23 42 / 0.12), 0 2px 8px 0 rgb(15 23 42 / 0.06);
  --shadow-xl:  0 20px 56px 0 rgb(15 23 42 / 0.16);

  /* Transition */
  --transition-fast:   120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   320ms cubic-bezier(0.4, 0, 0.2, 1);
  --spring:            300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --sidebar-width: 224px;
  --topbar-height: 60px;
}


/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--canvas);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  display: block;
  max-width: 100%;
}

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

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 0.12);
}

hr {
  border: none;
  border-top: 1px solid var(--border-soft);
}

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 1.875rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.015em; }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
h4 { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; }
h5 { font-size: 0.875rem; font-weight: 600; line-height: 1.4; }

p { line-height: 1.6; }

.text-xs    { font-size: 0.75rem; }
.text-sm    { font-size: 0.8125rem; }
.text-base  { font-size: 0.9375rem; }
.text-lg    { font-size: 1.0625rem; }
.text-xl    { font-size: 1.25rem; }
.text-2xl   { font-size: 1.5rem; }
.text-3xl   { font-size: 1.875rem; }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-teal      { color: var(--primary); }
.text-green     { color: var(--stock-in); }
.text-indigo    { color: var(--sale); }
.text-amber     { color: var(--alert); }
.text-red       { color: var(--danger); }

.mono { font-family: var(--font-mono); }

/* ── Utility Classes ───────────────────────────────────────── */
.hidden   { display: none !important; }
.visible  { display: block !important; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.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;
}
.pointer { cursor: pointer; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.8;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-primary   { background: var(--primary-light);  color: var(--primary-dark); }
.badge-green     { background: var(--stock-in-bg);    color: #065F46; }
.badge-indigo    { background: var(--sale-bg);        color: #3730A3; }
.badge-amber     { background: var(--alert-bg);       color: #92400E; }
.badge-red       { background: var(--danger-bg);      color: #991B1B; }
.badge-purple    { background: var(--spoilage-bg);    color: #5B21B6; }
.badge-gray      { background: var(--border-soft);    color: var(--text-secondary); }
.badge-dark      { background: var(--text-primary);   color: var(--text-inverse); }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Selection ─────────────────────────────────────────────── */
::selection { background: var(--primary-light); color: var(--primary-dark); }

/* ── Focus Ring ────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.animate-fade-in       { animation: fadeIn var(--transition-normal) ease both; }
.animate-slide-up      { animation: slideInUp var(--transition-normal) ease both; }
.animate-slide-right   { animation: slideInRight var(--transition-normal) ease both; }
.animate-scale-in      { animation: scaleIn var(--spring) both; }
.animate-pulse         { animation: pulse 1.8s ease-in-out infinite; }
.animate-spin          { animation: spin 1s linear infinite; }

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