/* css/base.css — Design tokens, reset, typography — Inventory System v2 */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  /* Brand (amber — logo/accents only) */
  --brand:        #F4A52A;
  --brand-light:  #F7BC5E;
  --brand-dim:    rgba(244,165,42,0.12);
  --brand-border: rgba(244,165,42,0.30);

  /* Primary Blue — main actions */
  --primary:        #2563EB;
  --primary-hover:  #1D4ED8;
  --primary-light:  #EFF6FF;
  --primary-dim:    rgba(37,99,235,0.10);
  --primary-border: rgba(37,99,235,0.25);

  /* Sidebar — deep navy */
  --sidebar-bg:       #0F172A;
  --sidebar-bg-hover: rgba(255,255,255,0.06);
  --sidebar-active:   rgba(37,99,235,0.18);
  --sidebar-active-border: rgba(37,99,235,0.60);
  --sidebar-text:     rgba(226,232,240,0.70);
  --sidebar-text-active: #E2E8F0;
  --sidebar-section:  rgba(148,163,184,0.40);
  --sidebar-border:   rgba(255,255,255,0.06);

  /* Surfaces */
  --bg:           #F1F5F9;
  --surface:      #FFFFFF;
  --surface-2:    #F8FAFC;
  --surface-3:    #F1F5F9;
  --surface-hover: #EFF6FF;

  /* Text */
  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-on-dark:   #E2E8F0;

  /* Borders */
  --border:       #E2E8F0;
  --border-light: #F1F5F9;
  --border-dark:  rgba(255,255,255,0.08);

  /* Status colors */
  --green:        #16A34A;
  --green-dim:    rgba(22,163,74,0.10);
  --green-border: rgba(22,163,74,0.25);
  --red:          #DC2626;
  --red-dim:      rgba(220,38,38,0.10);
  --red-border:   rgba(220,38,38,0.25);
  --amber:        #D97706;
  --amber-dim:    rgba(217,119,6,0.10);
  --amber-border: rgba(217,119,6,0.25);
  --blue:         #2563EB;
  --blue-dim:     rgba(37,99,235,0.10);
  --orange:       #EA580C;

  /* Dimensions */
  --sidebar-w:    256px;
  --sidebar-w-c:  68px;
  --header-h:     58px;

  /* Radii */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);

  /* Font */
  --font-head: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img  { max-width: 100%; display: block; }
a    { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-head); font-weight: 700; line-height: 1.25; color: var(--text-primary); }
h1 { font-size: 1.875rem; letter-spacing: -.025em; }
h2 { font-size: 1.5rem;   letter-spacing: -.020em; }
h3 { font-size: 1.2rem;   letter-spacing: -.010em; }
h4 { font-size: 1.0rem; }
h5 { font-size: 0.9rem; font-weight: 600; }

.label {
  font-family: var(--font-body); font-size: 0.72rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted);
}
.mono    { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.amount  { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── App shell layout ─────────────────────────────────────────────────────── */
#app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — Professional Dark Navy
════════════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width .25s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid var(--sidebar-border);
  overflow: hidden;
}
#sidebar.collapsed { width: var(--sidebar-w-c); }

/* Logo area */
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid var(--sidebar-border);
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-logo img {
  width: 34px; height: 34px; object-fit: contain;
  flex-shrink: 0; border-radius: var(--radius-sm);
  box-shadow: 0 0 0 2px rgba(244,165,42,0.35);
}
.sidebar-logo-text { overflow: hidden; white-space: nowrap; }
.sidebar-logo-name {
  font-family: var(--font-head); font-size: 0.9rem; font-weight: 800;
  color: #F8FAFC; letter-spacing: -.01em; line-height: 1.15;
}
.sidebar-logo-name span { color: var(--brand); }
.sidebar-logo-sub {
  font-size: 0.62rem; color: var(--sidebar-section);
  text-transform: uppercase; letter-spacing: .08em;
  margin-top: 1px;
}

/* Nav */
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.nav-section {
  padding: 16px 20px 6px;
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: .10em; text-transform: uppercase;
  color: var(--sidebar-section);
  white-space: nowrap; overflow: hidden;
  transition: opacity .2s;
}
#sidebar.collapsed .nav-section { opacity: 0; height: 0; padding: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-size: 0.84rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; overflow: hidden;
  transition: background .15s, color .15s;
  user-select: none;
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; transition: opacity .15s; opacity: .7; }
.nav-item .nav-label { transition: opacity .15s, width .25s; overflow: hidden; }

#sidebar.collapsed .nav-item .nav-label { opacity: 0; width: 0; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
#sidebar.collapsed .nav-item svg { opacity: .75; }

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
}
.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: var(--sidebar-active);
  color: #93C5FD; /* light blue */
  border-left: 2px solid var(--primary);
  margin-left: 6px; padding-left: 12px;
}
.nav-item.active svg { opacity: 1; color: #93C5FD; }
#sidebar.collapsed .nav-item.active {
  border-left: none; margin-left: 8px; padding-left: 10px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-dim);
  border: 1.5px solid var(--primary-border);
  color: #93C5FD;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 0.75rem;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
  font-size: 0.8rem; color: var(--text-on-dark);
  font-weight: 600; white-space: nowrap;
}
.sidebar-user-role {
  font-size: 0.65rem; color: var(--sidebar-section);
  text-transform: capitalize;
}

/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════════════════════════════ */
#main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
  overflow-x: hidden;
  max-width: calc(100vw - var(--sidebar-w));
}
#sidebar.collapsed ~ #main-content {
  margin-left: var(--sidebar-w-c);
  max-width: calc(100vw - var(--sidebar-w-c));
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
#topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-xs);
}
#topbar-toggle {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: background .15s, color .15s;
  flex-shrink: 0;
}
#topbar-toggle:hover { background: var(--surface-3); color: var(--text-primary); }
#topbar-toggle svg { transition: transform .25s cubic-bezier(.4,0,.2,1); }
#sidebar.collapsed ~ #main-content #topbar-toggle svg { transform: rotate(180deg); }
#topbar-title {
  font-family: var(--font-head); font-size: 1.05rem; font-weight: 700;
  color: var(--text-primary); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* Date/time chip in topbar */
.topbar-date {
  font-size: 0.75rem; color: var(--text-muted); font-weight: 500;
  background: var(--surface-3); padding: 4px 10px;
  border-radius: 20px; border: 1px solid var(--border);
  white-space: nowrap;
}

/* ── Page content area ────────────────────────────────────────────────────── */
#page-content {
  flex: 1; padding: 24px 28px 40px;
  overflow-x: hidden; min-width: 0;
}
@media (max-width: 768px) { #page-content { padding: 16px; } }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar          { width: 6px; height: 6px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: rgba(0,0,0,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.28); }

/* ── Utility classes ─────────────────────────────────────────────────────── */
.hidden        { display: none !important; }
.sr-only       { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.flex          { display: flex; }
.flex-1        { flex: 1; }
.items-center  { align-items: center; }
.justify-end   { justify-content: flex-end; }
.gap-1         { gap: 4px; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 12px; }
.gap-4         { gap: 16px; }
.mt-1          { margin-top: 4px; }
.mt-2          { margin-top: 8px; }
.mt-3          { margin-top: 12px; }
.mt-4          { margin-top: 16px; }
.mt-6          { margin-top: 24px; }
.mt-8          { margin-top: 32px; }
.mb-1          { margin-bottom: 4px; }
.mb-2          { margin-bottom: 8px; }
.mb-4          { margin-bottom: 16px; }
.mb-6          { margin-bottom: 24px; }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.text-left     { text-align: left; }
.text-brand    { color: var(--brand); }
.text-primary-c { color: var(--primary); }
.text-green    { color: var(--green); }
.text-red      { color: var(--red); }
.text-amber    { color: var(--amber); }
.text-muted    { color: var(--text-muted); }
.text-blue     { color: var(--blue); }
.fw-500        { font-weight: 500; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.fw-bold       { font-weight: 700; }
.w-full        { width: 100%; }
.truncate      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  #sidebar, #topbar, .no-print, .filters-bar { display: none !important; }
  #main-content { margin-left: 0 !important; max-width: 100% !important; }
  #page-content { padding: 0 !important; }
  body { background: white; color: black; font-size: 12px; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
════════════════════════════════════════════════════════════════ */
@keyframes fadeSlideUp {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideRight {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.animate-in {
  animation: fadeSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
}
.page-enter {
  animation: fadeSlideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stagger-1 { animation-delay: 0.04s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.12s; }
.stagger-4 { animation-delay: 0.16s; }
.stagger-5 { animation-delay: 0.20s; }
.stagger-6 { animation-delay: 0.24s; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); transition: transform .25s; }
  #sidebar.mobile-open { transform: none; }
  #main-content { margin-left: 0 !important; max-width: 100% !important; }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
