/* ============================================
   RestoSuite Inventory — Design Tokens
   Unified from: restosuite.sg + portal + token
   ============================================ */

:root {
  /* ── Brand Colors (from restosuite.sg) ── */
  --brand-navy: #1D1B2E;
  --brand-blue: #2563EB;
  --brand-blue-dark: #1D4ED8;
  --accent-orange: #F97316;
  --accent-gold: #F59E0B;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #0ea5e9;

  /* ── Portal Internal Colors ── */
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #2d3f55;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #0ea5e9;
  --sidebar-border: #2d3f55;
  --sidebar-width: 260px;

  /* ── Backgrounds ── */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;

  /* ── Text ── */
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  /* ── Borders ── */
  --border: #e2e8f0;

  /* ── Badges (portal style) ── */
  --badge-sop: #3b82f6;
  --badge-sop-bg: #eff6ff;
  --badge-tool: #22c55e;
  --badge-tool-bg: #f0fdf4;
  --badge-template: #f97316;
  --badge-template-bg: #fff7ed;
  --badge-lark: #a855f7;
  --badge-lark-bg: #faf5ff;
  --badge-resource: #64748b;
  --badge-resource-bg: #f1f5f9;

  /* ── Inventory Status Badges ── */
  --status-instock: #10B981;
  --status-instock-bg: #ecfdf5;
  --status-transit: #3b82f6;
  --status-transit-bg: #eff6ff;
  --status-deployed: #a855f7;
  --status-deployed-bg: #faf5ff;
  --status-faulty: #EF4444;
  --status-faulty-bg: #fef2f2;
  --status-reserved: #F59E0B;
  --status-reserved-bg: #fffbeb;

  /* ── Gradients ── */
  --gradient-hero: linear-gradient(135deg, #1D1B2E 0%, #1e3a5f 50%, #1a2f4e 100%);
  --gradient-blue: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
  --gradient-gold: linear-gradient(135deg, #F59E0B 0%, #F97316 100%);

  /* ── Shadows ── */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.08);
  --shadow-xl: 0 20px 50px rgba(0,0,0,.15);

  /* ── Radius ── */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 32px;
  --radius-pill: 999px;

  /* ── Typography ── */
  --font-main: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* ── Transitions ── */
  --transition: 150ms ease;
  --transition-smooth: 0.25s ease;

  /* ── Layout ── */
  --header-height: 64px;
  --content-max: 1400px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
}

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

/* ── Layout Shell ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  z-index: 100;
  transition: transform var(--transition-smooth);
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-height);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--gradient-blue);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  font-weight: 700;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--sidebar-active);
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-text);
  padding: 0 12px;
  margin-bottom: 8px;
  opacity: 0.6;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
}

.sidebar-link-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-link-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 24px;
  text-align: center;
}

.sidebar-link.active .sidebar-link-badge {
  background: rgba(255,255,255,0.25);
  color: white;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--sidebar-text);
  opacity: 0.6;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
}

/* ── Top Header ── */
.top-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
}

.top-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
}

.header-btn-primary {
  background: var(--brand-blue);
  color: white;
}

.header-btn-primary:hover {
  background: var(--brand-blue-dark);
}

.header-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.header-btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* ── Page Content ── */
.page-content {
  padding: 32px;
  max-width: var(--content-max);
}

/* ── Stat Cards Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card.blue::after { background: var(--brand-blue); }
.stat-card.green::after { background: var(--success); }
.stat-card.orange::after { background: var(--accent-orange); }
.stat-card.purple::after { background: #7C3AED; }
.stat-card.red::after { background: var(--danger); }

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.stat-card-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-card.blue .stat-card-icon { background: #eff6ff; }
.stat-card.green .stat-card-icon { background: #ecfdf5; }
.stat-card.orange .stat-card-icon { background: #fff7ed; }
.stat-card.purple .stat-card-icon { background: #faf5ff; }
.stat-card.red .stat-card-icon { background: #fef2f2; }

.stat-card-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat-card-change {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-card-change.up { color: var(--success); }
.stat-card-change.down { color: var(--danger); }

/* ── Section ── */
.section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Table ── */
.table-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 280px;
}

.table-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  font-family: var(--font-main);
  color: var(--text-primary);
  width: 100%;
}

.table-search input::placeholder {
  color: var(--text-muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 24px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface-hover); }

/* ── Status Badge ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-instock { background: var(--status-instock-bg); color: var(--status-instock); }
.status-instock::before { background: var(--status-instock); }

.status-transit { background: var(--status-transit-bg); color: var(--status-transit); }
.status-transit::before { background: var(--status-transit); }

.status-deployed { background: var(--status-deployed-bg); color: var(--status-deployed); }
.status-deployed::before { background: var(--status-deployed); }

.status-faulty { background: var(--status-faulty-bg); color: var(--status-faulty); }
.status-faulty::before { background: var(--status-faulty); }

.status-reserved { background: var(--status-reserved-bg); color: var(--status-reserved); }
.status-reserved::before { background: var(--status-reserved); }

/* ── Location Tag ── */
.location-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Alert / Warning Row ── */
.alert-row {
  background: #fef2f2;
  border-left: 3px solid var(--danger);
}

.alert-row td {
  color: var(--danger);
}

/* ── Pagination ── */
.table-footer {
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ── Loading ── */
.loading-skeleton {
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--bg) 50%, var(--surface-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast Notification ── */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  font-size: 14px;
  animation: slideIn 0.3s ease;
  min-width: 300px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .top-header { padding: 0 16px; }
  .page-content { padding: 16px; }
  .table-search { width: 100%; }
}
