/* ============================================================
   SISTEMA DP — MOBILE-FIRST DESIGN SYSTEM
   ============================================================ */

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

:root {
  --bg:           #0a0e1a;
  --bg-card:      #111827;
  --bg-raised:    #1a2235;
  --bg-input:     #0d1525;
  --border:       #1f2f4a;
  --border-light: #263350;

  --primary:      #3b82f6;
  --primary-d:    #2563eb;
  --primary-glow: rgba(59,130,246,0.25);

  --success:      #10b981;
  --success-bg:   rgba(16,185,129,0.12);
  --success-b:    rgba(16,185,129,0.35);

  --error:        #ef4444;
  --error-bg:     rgba(239,68,68,0.12);
  --error-b:      rgba(239,68,68,0.35);

  --warning:      #f59e0b;
  --warning-bg:   rgba(245,158,11,0.12);

  --text:         #f1f5f9;
  --text-2:       #94a3b8;
  --text-3:       #4b6080;

  --r-sm:         10px;
  --r:            14px;
  --r-lg:         20px;
  --r-xl:         28px;

  /* Bottom nav safe area */
  --nav-h:        68px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 16px;
  /* Prevent iOS bounce */
  overscroll-behavior: none;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, #1e3a5f 0%, var(--bg) 70%);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}

.auth-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 8px 32px rgba(59,130,246,0.4);
}

.auth-brand h1 {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.auth-brand p {
  font-size: 0.9rem;
  color: var(--text-2);
  text-align: center;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
}

/* PIN Tabs */
.auth-tabs {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--r-sm);
  padding: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.auth-tab-btn {
  flex: 1;
  padding: 11px 8px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}

/* PIN Display */
.pin-display {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  background: transparent;
  transition: all 0.15s;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  transform: scale(1.1);
}

/* PIN Grid */
.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pin-btn {
  height: 68px;
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.pin-btn:active {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(0.94);
}

.pin-btn.pin-delete {
  color: var(--error);
  font-size: 1.2rem;
}

.pin-btn.pin-confirm {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.pin-error-msg {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--error-bg);
  border: 1px solid var(--error-b);
  color: var(--error);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  display: none;
}

/* ============================================================
   MAIN APP LAYOUT
   ============================================================ */
#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Space for bottom nav */
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

/* Top header bar */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,14,26,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.topbar-brand h2 {
  font-size: 1rem;
  font-weight: 800;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
}

.topbar-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  display: none;
}

.btn-logout {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}

.btn-logout:active { color: var(--error); border-color: var(--error); }

/* Main scrollable area */
.app-content {
  flex: 1;
  overflow-y: auto;
}

/* Page views */
.page-view {
  display: none;
  padding: 16px;
  min-height: calc(100vh - 56px - var(--nav-h) - var(--safe-bottom));
}

.page-view.active {
  display: block;
}

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(17,24,39,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 8px 4px;
  transition: all 0.2s;
  position: relative;
}

.nav-btn .nav-icon {
  font-size: 1.4rem;
  line-height: 1;
  transition: transform 0.2s;
}

.nav-btn .nav-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn.active .nav-icon {
  transform: translateY(-2px);
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* Center big scan button */
.nav-btn.nav-scan-main {
  flex: 0 0 72px;
}

.nav-scan-pill {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 20px rgba(59,130,246,0.5);
  transition: all 0.15s;
}

.nav-btn.nav-scan-main:active .nav-scan-pill {
  transform: scale(0.9);
}

/* ============================================================
   PACKING VIEW
   ============================================================ */
.packing-hero {
  background: linear-gradient(135deg, #0f1f3d, #1a2f55);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.packing-hero h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.packing-hero p {
  font-size: 0.85rem;
  color: var(--text-2);
  margin-bottom: 16px;
}

.scan-order-row {
  display: flex;
  gap: 10px;
}

.scan-order-row input {
  flex: 1;
  height: 52px;
  padding: 0 16px;
  background: rgba(0,0,0,0.4);
  border: 1.5px solid rgba(59,130,246,0.4);
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
}

.scan-order-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(59,130,246,0.2);
}

.btn-icon {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-icon:active { transform: scale(0.92); }

.btn-icon-primary { background: var(--primary); color: #fff; }
.btn-icon-camera  { background: var(--bg-raised); border: 1.5px solid var(--border); color: var(--text-2); }

/* Status alert inline */
.status-pill {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 700;
  display: none;
  align-items: center;
  gap: 8px;
}
.status-pill.show { display: flex; }
.status-pill.ok  { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-b); }
.status-pill.err { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-b); }
.status-pill.warn { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.35); }

/* Active order card */
.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

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

.order-num-badge {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--primary);
}

.order-customer {
  flex: 1;
}

.order-customer-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.order-customer-meta {
  font-size: 0.78rem;
  color: var(--text-2);
}

.order-notes-tag {
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(245,158,11,0.25);
  max-width: 120px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* Progress row */
.order-progress-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--text-2);
  white-space: nowrap;
}

.progress-track {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 10px;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-pct {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  min-width: 38px;
  text-align: right;
}

/* Scan area for items */
.scan-item-zone {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.scan-item-zone input {
  flex: 1;
  height: 50px;
  padding: 0 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--success);
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  box-shadow: 0 0 12px rgba(16,185,129,0.15);
}

/* Packing items list */
.packing-items-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pack-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  transition: all 0.2s;
}

.pack-item.done {
  border-color: var(--success-b);
  background: var(--success-bg);
}

.pack-item-check {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  border: 2px solid var(--border);
  color: var(--text-3);
  background: var(--bg-input);
  font-weight: 800;
}

.pack-item.done .pack-item-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.pack-item-info {
  flex: 1;
  min-width: 0;
}

.pack-item-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pack-item-sku {
  font-size: 0.78rem;
  color: var(--text-2);
  font-family: 'Courier New', monospace;
}

.pack-item-counter {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text-2);
  white-space: nowrap;
}

.pack-item.done .pack-item-counter {
  color: var(--success);
}

/* ============================================================
   INVENTORY VIEW
   ============================================================ */
.section-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title:first-child { margin-top: 0; }

/* Big scan action */
.big-scan-card {
  background: linear-gradient(135deg, #0c1f44, #112244);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.big-scan-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.big-scan-row input {
  flex: 1;
  height: 56px;
  padding: 0 18px;
  background: rgba(0,0,0,0.4);
  border: 1.5px solid rgba(59,130,246,0.35);
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  outline: none;
}

.big-scan-row input:focus {
  border-color: var(--primary);
}

.qty-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qty-row label {
  font-size: 0.8rem;
  color: var(--text-2);
  white-space: nowrap;
}

.qty-input {
  width: 80px;
  height: 44px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  outline: none;
}

.btn-confirm {
  flex: 1;
  height: 44px;
  background: var(--success);
  border: none;
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-confirm:active { transform: scale(0.95); background: #059669; }

/* Search */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0 16px;
  margin-bottom: 12px;
  height: 48px;
}

.search-bar span { font-size: 1rem; }

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

/* Product cards */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.product-card:active {
  background: var(--bg-raised);
  transform: scale(0.99);
}

.product-stock-pill {
  width: 54px;
  height: 54px;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.product-stock-pill.ok   { background: var(--success-bg); border: 1.5px solid var(--success-b); }
.product-stock-pill.low  { background: var(--warning-bg); border: 1.5px solid rgba(245,158,11,0.35); }
.product-stock-pill.zero { background: var(--error-bg);   border: 1.5px solid var(--error-b); }

.stock-num {
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
}
.product-stock-pill.ok   .stock-num { color: var(--success); }
.product-stock-pill.low  .stock-num { color: var(--warning); }
.product-stock-pill.zero .stock-num { color: var(--error); }

.stock-unit {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
}

.product-info { flex: 1; min-width: 0; }

.product-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-meta {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-add-stock {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.3);
  color: var(--primary);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.btn-add-stock:active {
  background: var(--primary);
  color: #fff;
}

/* FAB */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(59,130,246,0.45);
  z-index: 150;
  transition: all 0.2s;
}

.fab:active { transform: scale(0.9); }

/* ============================================================
   ORDERS VIEW
   ============================================================ */
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  height: 36px;
  padding: 0 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

/* Order list cards */
.order-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.order-list-card:active {
  background: var(--bg-raised);
  transform: scale(0.99);
}

.order-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.order-list-num {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
}

.order-status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.s-pending    { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.s-in_packing { background: rgba(59,130,246,0.12); color: var(--primary); border: 1px solid rgba(59,130,246,0.3); }
.s-packed     { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-b); }

.order-list-customer {
  font-size: 0.95rem;
  font-weight: 600;
}

.order-list-meta {
  font-size: 0.78rem;
  color: var(--text-2);
}

.order-list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.btn-pack-now {
  height: 34px;
  padding: 0 14px;
  background: var(--primary);
  border: none;
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-pack-now:active { background: var(--primary-d); transform: scale(0.95); }

/* ============================================================
   MODALS (BOTTOM SHEET STYLE)
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end; /* bottom sheet on mobile */
}

.modal-backdrop.center {
  align-items: center;
  justify-content: center;
}

.modal-backdrop.show {
  display: flex;
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 0;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.4,0,0.2,1);
}

.modal-sheet.centered {
  border-radius: var(--r-xl);
  width: calc(100% - 32px);
  max-width: 480px;
  animation: scaleIn 0.2s cubic-bezier(0.4,0,0.2,1);
}

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

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

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin: 12px auto 0;
}

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 20px;
}

/* Forms inside modal */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-input {
  height: auto;
  padding: 12px 16px;
  resize: none;
}

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

.btn-full {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--r);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-full:active { transform: scale(0.97); }
.btn-full.primary { background: var(--primary); color: #fff; }
.btn-full.success { background: var(--success); color: #fff; }
.btn-full.danger  { background: var(--error);   color: #fff; }

/* Quagga2 High-Performance 1D Barcode Viewport */
.quagga-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: var(--r);
  overflow: hidden;
  background: #000;
}

.quagga-viewport video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
}

.quagga-viewport canvas.drawingBuffer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
}

.camera-preview-box {
  width: 100%;
  border-radius: var(--r);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  margin-bottom: 12px;
}

/* Celebration */
.celebration-modal {
  text-align: center;
  padding: 32px 24px;
}

.celebrate-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 12px;
  animation: celebBounce 0.7s ease infinite alternate;
}

@keyframes celebBounce {
  from { transform: scale(1)   translateY(0); }
  to   { transform: scale(1.1) translateY(-8px); }
}

/* ============================================================
   AUDIT VIEW
   ============================================================ */
.log-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.log-item:last-child { border-bottom: none; }

.log-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.log-dot.in  { background: var(--success); }
.log-dot.out { background: var(--primary); }
.log-dot.err { background: var(--error); }

.log-info { flex: 1; min-width: 0; }

.log-title {
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-sub {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 2px;
}

.log-right {
  text-align: right;
  flex-shrink: 0;
}

.log-qty {
  font-size: 0.95rem;
  font-weight: 800;
}

.log-time {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 2px;
}

/* ============================================================
   USERS VIEW
   ============================================================ */
.user-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }

.user-full-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.user-username {
  font-size: 0.78rem;
  color: var(--text-2);
}

.user-role-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.role-admin  { background: rgba(168,85,247,0.15); color: #a855f7; border: 1px solid rgba(168,85,247,0.3); }
.role-packer { background: rgba(59,130,246,0.12); color: var(--primary); border: 1px solid rgba(59,130,246,0.3); }
.role-bodega { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-b); }

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}

.empty-state .es-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.85rem;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}

.toast {
  padding: 14px 16px;
  border-radius: var(--r);
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast.toast-ok  { background: #064e3b; border: 1px solid var(--success-b); color: var(--success); }
.toast.toast-err { background: #450a0a; border: 1px solid var(--error-b);   color: var(--error); }
.toast.toast-warn{ background: #451a03; border: 1px solid rgba(245,158,11,0.4); color: var(--warning); }

@keyframes toastIn {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@keyframes toastOut {
  to { transform: translateY(-16px); opacity: 0; }
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* ============================================================
   ORDER-ITEM DRAFT LIST
   ============================================================ */
.draft-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
}

.draft-item-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.draft-item-qty {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-2);
}

.btn-remove-draft {
  width: 28px;
  height: 28px;
  background: var(--error-bg);
  border: 1px solid var(--error-b);
  border-radius: 6px;
  color: var(--error);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   DESKTOP ENHANCEMENTS (>= 768px)
   ============================================================ */
@media (min-width: 768px) {
  .topbar-name { display: block; }

  .bottom-nav {
    display: none;
  }

  /* On desktop, use a real sidebar instead */
  #app-screen {
    flex-direction: row;
    padding-bottom: 0;
  }

  .desktop-sidebar {
    display: flex !important;
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }

  .desktop-sidebar .ds-brand {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .desktop-sidebar .ds-nav {
    padding: 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .ds-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
  }

  .ds-nav-item:hover { background: var(--bg-raised); color: var(--text); }
  .ds-nav-item.active { background: var(--primary); color: #fff; }
  .ds-nav-item .ds-icon { font-size: 1.1rem; }

  .desktop-sidebar .ds-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
  }

  .app-content {
    flex: 1;
    overflow-y: auto;
    height: 100vh;
  }

  .app-topbar { display: none; }

  .page-view {
    padding: 28px;
    max-width: 900px;
  }

  .fab { bottom: 24px; }
}

/* ============================================================
   SHARED UTILS
   ============================================================ */
.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

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

.badge-count {
  background: var(--error);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
