/* ═══════════════════════════════════════════════════════════════
   Eleven Spices Inventory Portal — Design System
   Theme: Dark Spice — Saffron Orange Accent
   ═══════════════════════════════════════════════════════════════ */

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

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-primary:     #0F0E0D;
  --bg-secondary:   #1A1816;
  --bg-card:        #211F1C;
  --bg-card-hover:  #2A2723;
  --bg-input:       #2A2723;
  --bg-sidebar:     #161412;

  --accent:         #F97316;
  --accent-dark:    #C2580D;
  --accent-light:   #FB923C;
  --accent-glow:    rgba(249,115,22,0.15);

  --text-primary:   #F5F0EB;
  --text-secondary: #A89880;
  --text-muted:     #6B5E52;

  --border:         rgba(249,115,22,0.15);
  --border-subtle:  rgba(255,255,255,0.06);

  --success:  #22C55E;
  --warning:  #EAB308;
  --danger:   #EF4444;
  --info:     #3B82F6;

  --success-bg: rgba(34,197,94,0.12);
  --warning-bg: rgba(234,179,8,0.12);
  --danger-bg:  rgba(239,68,68,0.12);
  --info-bg:    rgba(59,130,246,0.12);

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-light); }

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

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

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

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px var(--accent-glow);
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  line-height: 1;
}

.sidebar-logo .logo-text strong {
  display: block;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-logo .logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}

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

.nav-link:hover {
  background: var(--accent-glow);
  color: var(--accent-light);
}

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

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

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info strong {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
}

.user-info span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ─── Main Content ────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.topbar-title {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

/* ─── Page Content ────────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(249,115,22,0.3);
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Stat Cards (Dashboard) ─────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
}

.stat-card.orange::before { background: var(--accent); }
.stat-card.green::before  { background: var(--success); }
.stat-card.yellow::before { background: var(--warning); }
.stat-card.red::before    { background: var(--danger); }
.stat-card.blue::before   { background: var(--info); }

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(249,115,22,0.3);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.orange { background: var(--accent-glow); }
.stat-icon.green  { background: var(--success-bg); }
.stat-icon.yellow { background: var(--warning-bg); }
.stat-icon.red    { background: var(--danger-bg); }
.stat-icon.blue   { background: var(--info-bg); }

.stat-info .stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.stat-info .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Product Cards ───────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}

.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(249,115,22,0.15);
}

.product-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--text-muted);
}

.product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card-body {
  padding: 14px;
}

.product-card-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card-sku {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.product-card-stock {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stock-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.stock-badge.high  { background: var(--success-bg); color: var(--success); }
.stock-badge.low   { background: var(--danger-bg); color: var(--danger); }
.stock-badge.zero  { background: var(--danger-bg); color: var(--danger); }

.product-card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(249,115,22,0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(249,115,22,0.4);
  color: white;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34,197,94,0.3);
}

.btn-success:hover { background: rgba(34,197,94,0.2); color: var(--success); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover { background: rgba(239,68,68,0.2); color: var(--danger); }

.btn-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(234,179,8,0.3);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ─── Forms ───────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23F97316' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select.form-control option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ─── Tables ──────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-top: 1px solid var(--border-subtle);
  transition: var(--transition);
}

tbody tr:hover { background: var(--bg-card-hover); }

tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ─── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success   { background: var(--success-bg); color: var(--success); }
.badge-danger    { background: var(--danger-bg); color: var(--danger); }
.badge-warning   { background: var(--warning-bg); color: var(--warning); }
.badge-primary   { background: var(--info-bg); color: var(--info); }
.badge-info      { background: rgba(59,130,246,0.15); color: #60A5FA; }
.badge-secondary { background: rgba(168,152,128,0.15); color: var(--text-secondary); }
.badge-dark      { background: rgba(30,20,10,0.6); color: var(--text-secondary); }
.badge-orange    { background: var(--accent-glow); color: var(--accent); }

/* ─── Alerts / Messages ──────────────────────────────────────── */
.messages-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}

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

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.alert-error   { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(234,179,8,0.3); }
.alert-info    { background: var(--info-bg); color: var(--info); border: 1px solid rgba(59,130,246,0.3); }

/* ─── Search Bar ──────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: var(--transition);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  flex: 1;
}

.search-bar input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); font-size: 16px; }

/* ─── Quick Actions ───────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quick-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.quick-action-btn:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(249,115,22,0.12);
  color: inherit;
}

.quick-action-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}

.quick-action-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

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

.empty-state-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ─── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top left, rgba(249,115,22,0.08) 0%, transparent 60%),
              var(--bg-primary);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
  box-shadow: 0 0 30px var(--accent-glow);
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 800;
}

.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Barcode Scanner ─────────────────────────────────────────── */
.scanner-container {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

#scanner-video-container {
  position: relative;
  width: 100%;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--accent);
  box-shadow: 0 0 30px var(--accent-glow);
}

#scanner-video-container video {
  width: 100%;
  display: block;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-line {
  width: 80%;
  height: 2px;
  background: var(--accent);
  animation: scanLine 2s ease-in-out infinite;
  box-shadow: 0 0 10px var(--accent);
}

@keyframes scanLine {
  0%, 100% { transform: translateY(-60px); opacity: 0.5; }
  50% { transform: translateY(60px); opacity: 1; }
}

.usb-input-container {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ─── Reports ─────────────────────────────────────────────────── */
.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: block;
}

.report-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(249,115,22,0.15);
  color: inherit;
}

.report-card-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.report-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.report-card-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.export-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Filters Bar ─────────────────────────────────────────────── */
.filters-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters-bar .form-group {
  margin-bottom: 0;
  min-width: 150px;
  flex: 1;
}

/* ─── Order Row Items ─────────────────────────────────────────── */
.order-item-row {
  display: grid;
  grid-template-columns: 1fr 120px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  padding: 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ─── Timeline / History ──────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-primary);
}

/* ─── Responsive Layout Utilities ────────────────────────── */
/* Two-column grid that stacks on mobile */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Two-column with wider left */
.two-col-main-aside {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

/* Side by side (for stock in/out, order detail etc) */
.side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 768px) {
  .two-col-grid,
  .two-col-main-aside,
  .side-by-side {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ─── Utility Classes ─────────────────────────────────────────── */
.text-accent   { color: var(--accent); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-muted    { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }

.d-flex  { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.w-100 { width: 100%; }

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

/* ─── Loading Spinner ─────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Product Detail ──────────────────────────────────────────── */
.product-detail-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  overflow: hidden;
}

.product-image-lg {
  width: 160px;
  height: 160px;
  min-width: 160px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  flex-shrink: 0;
  overflow: hidden; /* critical — clips image to box */
  position: relative;
}

.product-image-lg img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  display: block;
}

.stock-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stock-summary-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}

.stock-summary-item .value {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 800;
}

.stock-summary-item .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Comprehensive Breakpoints
   ═══════════════════════════════════════════════════════════ */

/* ─── Tablet (≤ 1024px) ──────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }

  .stat-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .report-cards {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ─── Mobile (≤ 768px) ───────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar: hidden off-canvas */
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.6);
  }

  /* Main content flush to edge */
  .main-content {
    margin-left: 0;
  }

  /* Show hamburger button */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
  }

  /* Topbar */
  .topbar {
    padding: 0 12px;
    height: 56px;
  }

  .topbar-title {
    font-size: 15px;
  }

  /* Hide logout text on mobile, keep scan button */
  .topbar-actions .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Page content padding */
  .page-content {
    padding: 14px 12px 80px; /* extra bottom for bottom nav */
  }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .page-header .btn,
  .page-header .export-buttons {
    width: 100%;
  }

  .export-buttons {
    flex-direction: row;
    width: 100%;
  }

  .export-buttons .btn {
    flex: 1;
  }

  /* Stat Cards: 2 per row */
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 10px;
  }

  .stat-info .stat-value {
    font-size: 22px;
  }

  .stat-info .stat-label {
    font-size: 10px;
  }

  /* Quick Actions: 3 per row */
  .quick-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .quick-action-btn {
    padding: 14px 8px;
  }

  .quick-action-icon {
    font-size: 22px;
    margin-bottom: 6px;
  }

  .quick-action-label {
    font-size: 11px;
  }

  /* Product cards: 2 per row on mobile */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .product-card-image {
    height: 120px;
    font-size: 36px;
  }

  .product-card-body {
    padding: 10px;
  }

  .product-card-name {
    font-size: 13px;
  }

  .product-card-actions {
    padding: 8px 10px;
    gap: 4px;
  }

  .product-card-actions .btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  /* Forms: single column */
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-control {
    font-size: 16px; /* prevent iOS zoom on focus */
    padding: 12px 14px;
  }

  /* Filters: stack vertically */
  .filters-bar {
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .filters-bar .form-group {
    min-width: 100%;
    width: 100%;
  }

  /* Tables: horizontal scroll with sticky first column */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }

  table {
    min-width: 500px;
  }

  thead th {
    padding: 10px 12px;
    font-size: 10px;
  }

  tbody td {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Cards */
  .card {
    padding: 14px;
  }

  /* Order item rows */
  .order-item-row {
    grid-template-columns: 1fr 90px 36px;
    gap: 6px;
    padding: 8px;
  }

  /* Report cards: 2 per row */
  .report-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .report-card {
    padding: 16px 12px;
  }

  .report-card-icon {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .report-card-title {
    font-size: 14px;
  }

  .report-card-desc {
    font-size: 12px;
  }

  /* Alert messages */
  .messages-container {
    right: 10px;
    left: 10px;
    top: 66px;
    max-width: none;
  }

  /* Scanner */
  .scanner-container {
    max-width: 100%;
  }

  .usb-input-container {
    flex-direction: column;
  }

  .usb-input-container .btn {
    width: 100%;
  }

  /* Dashboard two-column grids → single column */
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns:2fr 1fr"] {
    display: block !important;
  }

  [style*="grid-template-columns: 2fr 1fr"] > *,
  [style*="grid-template-columns: 1fr 1fr"] > *,
  [style*="grid-template-columns:1fr 1fr"] > *,
  [style*="grid-template-columns:2fr 1fr"] > * {
    margin-bottom: 16px;
  }

  /* Product detail — keep image as compact square, stay side-by-side on mobile */
  .product-detail-header {
    flex-direction: row;  /* stay horizontal on mobile */
    gap: 14px;
    align-items: flex-start;
  }

  .product-image-lg {
    width: 100px;
    min-width: 100px;
    height: 100px;
    font-size: 40px;
  }

  .stock-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Login box */
  .login-box {
    padding: 24px 18px;
    margin: 16px;
    max-width: none;
    border-radius: var(--radius);
  }
}

/* ─── Small Mobile (≤ 480px) ─────────────────────────────── */
@media (max-width: 480px) {

  .page-content {
    padding: 10px 10px 80px;
  }

  /* Stat cards: still 2-col but tighter */
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
    gap: 8px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .stat-info .stat-value {
    font-size: 20px;
  }

  /* Quick actions: 2 per row for very small screens */
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Product grid: 2 columns still, but smaller */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .product-card-image {
    height: 100px;
    font-size: 28px;
  }

  .product-card-name {
    font-size: 12px;
  }

  /* Report cards: 1 column */
  .report-cards {
    grid-template-columns: 1fr;
  }

  /* Page header h1 */
  .page-header h1 {
    font-size: 18px;
  }

  /* Topbar title shorter */
  .topbar-title {
    font-size: 14px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Stock summary: 2 col */
  .stock-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Empty state smaller */
  .empty-state {
    padding: 40px 16px;
  }

  .empty-state-icon {
    font-size: 40px;
  }
}

/* ─── Sidebar Overlay (mobile) ───────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  display: block;
  animation: fadeOverlay 0.25s ease;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Mobile Bottom Navigation Bar ──────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  padding: 4px 0 env(safe-area-inset-bottom, 4px);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}

.mobile-bottom-nav .nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.mobile-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  text-decoration: none;
  color: var(--text-muted);
  transition: var(--transition);
  border-radius: var(--radius-sm);
  min-width: 52px;
}

.mobile-bottom-nav .nav-item.active {
  color: var(--accent);
}

.mobile-bottom-nav .nav-item .nav-icon {
  font-size: 20px;
  line-height: 1;
}

.mobile-bottom-nav .nav-item .nav-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Scan FAB button in bottom nav */
.mobile-bottom-nav .nav-item.scan-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  margin-top: -18px;
  box-shadow: 0 4px 20px rgba(249,115,22,0.5);
  padding: 0;
  justify-content: center;
}

.mobile-bottom-nav .nav-item.scan-btn .nav-icon {
  font-size: 22px;
}

.mobile-bottom-nav .nav-item.scan-btn .nav-label {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    flex-direction: column;
  }
}

/* ─── Touch-friendly interactive targets ─────────────────── */
@media (max-width: 768px) {
  /* Minimum 44×44px touch targets */
  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
  }

  .nav-link {
    padding: 12px;
    min-height: 44px;
  }

  /* Remove hover transforms on touch */
  .stat-card:hover,
  .product-card:hover,
  .report-card:hover,
  .quick-action-btn:hover {
    transform: none;
  }

  /* Tap highlight color */
  * {
    -webkit-tap-highlight-color: rgba(249, 115, 22, 0.1);
  }
}

/* ─── Print styles ───────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar,
  .mobile-bottom-nav,
  .btn,
  .export-buttons,
  .filters-bar,
  .messages-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    border: 1px solid #ccc;
    background: white;
  }

  table {
    font-size: 12px;
  }
}

