/* 
  Lavish Trader Inventory & Order-Packing System - Compact Mobile-First Design System
  Optimized for phone browsers (PWA) and warehouse thermal sticker printing
*/

:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #334155;
  --border-color: #334155;
  --border-focus: #3b82f6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-success: #10b981;
  --accent-success-hover: #059669;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 60px; /* Compact space for mobile bottom nav */
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Compact App Header (Desktop / Mobile Header) */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.4rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 48px;
}

.mobile-hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-main);
}

.app-brand-badge {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background-color: var(--bg-surface-elevated);
  text-decoration: none;
}

/* Mobile Slide-Out Navigation Drawer */
#mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9998;
}

#mobile-nav-backdrop.active {
  display: block;
}

#mobile-nav-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  max-width: 85vw;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  z-index: 9999;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 10px 0 25px rgba(0,0,0,0.6);
}

#mobile-nav-drawer.active {
  transform: translateX(0);
}

.mobile-drawer-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-primary);
}

.mobile-drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
}

.mobile-drawer-links {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mobile-drawer-section-title {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin: 0.85rem 0 0.35rem 0;
}
.mobile-drawer-section-title:first-child { margin-top: 0; }

.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
}
.mobile-drawer-link:hover, .mobile-drawer-link.active {
  background-color: var(--bg-surface-elevated);
  text-decoration: none;
}
.mobile-drawer-link.highlight {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
}

/* Compact Mobile Sticky Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 999;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  flex: 1;
  text-decoration: none;
}

.mobile-nav-item.active, .mobile-nav-item:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

.mobile-nav-icon {
  font-size: 1.1rem;
  line-height: 1;
}

@media (max-width: 768px) {
  .mobile-bottom-nav { display: flex; }
  .nav-links { display: none; }
  .mobile-hamburger-btn { display: inline-block; }
  .app-header { padding: 0.35rem 0.75rem; height: 44px; }
  .user-badge span:first-child { display: none; }
}

/* Compact Main Container */
.app-main {
  flex: 1;
  padding: 0.75rem 1rem;
  max-width: 1350px;
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 600px) {
  .app-main { padding: 0.5rem 0.65rem; }
}

/* Compact Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

/* Alert Banners */
.alert {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.alert-success { background-color: rgba(16, 185, 129, 0.15); border: 1px solid var(--accent-success); color: var(--accent-success); }
.alert-error { background-color: rgba(239, 68, 68, 0.15); border: 1px solid var(--accent-danger); color: var(--accent-danger); }

/* Product Pictures & Thumbnails */
.product-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
  flex-shrink: 0;
}

.product-info-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Color Badges */
.color-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: capitalize;
  border: 1px solid rgba(255,255,255,0.2);
}
.color-black { background-color: #000; color: #fff; }
.color-blue { background-color: #1e3a8a; color: #93c5fd; }
.color-green { background-color: #064e3b; color: #6ee7b7; }
.color-clear { background-color: #334155; color: #cbd5e1; border: 1px dashed #94a3b8; }
.color-white { background-color: #f8fafc; color: #0f172a; }
.color-red { background-color: #7f1d1d; color: #fca5a5; }
.color-pink { background-color: #831843; color: #fbcfe8; }

/* Audit Log Event Action Pills */
.audit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-login { background: rgba(59, 130, 246, 0.18); color: #60a5fa; border: 1px solid #3b82f6; }
.badge-order { background: rgba(16, 185, 129, 0.18); color: #34d399; border: 1px solid #10b981; }
.badge-scan { background: rgba(6, 182, 212, 0.18); color: #22d3ee; border: 1px solid #06b6d4; }
.badge-complete { background: rgba(16, 185, 129, 0.25); color: #6ee7b7; border: 1px solid #10b981; }
.badge-stock { background: rgba(129, 140, 248, 0.18); color: #a5b4fc; border: 1px solid #6366f1; }
.badge-import { background: rgba(168, 85, 247, 0.18); color: #c084fc; border: 1px solid #a855f7; }
.badge-product { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid #f59e0b; }
.badge-danger { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid #ef4444; }
.badge-default { background: var(--bg-surface-elevated); color: var(--text-muted); border: 1px solid var(--border-color); }

/* Real-Time Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  max-height: 280px;
  overflow-y: auto;
  z-index: 9999;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

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

.autocomplete-item:hover {
  background-color: var(--bg-surface-elevated);
}

.autocomplete-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

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

.autocomplete-title {
  font-size: 0.85rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-stock {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.stock-healthy { background-color: rgba(16, 185, 129, 0.2); color: var(--accent-success); }
.stock-low { background-color: rgba(245, 158, 11, 0.2); color: var(--accent-warning); }
.stock-out { background-color: rgba(239, 68, 68, 0.2); color: var(--accent-danger); }

/* Dashboard Cards Grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.card-stat {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1.1;
  margin-top: 0.2rem;
}

.card-stat.warning { color: var(--accent-warning); }
.card-stat.success { color: var(--accent-success); }

/* Tables */
.table-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

th {
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

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

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Compact Forms & Buttons */
.form-group {
  margin-bottom: 0.85rem;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 38px;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary { background-color: var(--accent-primary); color: #fff; }
.btn-primary:hover { background-color: var(--accent-primary-hover); text-decoration: none; }

.btn-success { background-color: var(--accent-success); color: #fff; }
.btn-success:hover { background-color: var(--accent-success-hover); text-decoration: none; }

.btn-secondary { background-color: var(--bg-surface-elevated); color: var(--text-main); }
.btn-secondary:hover { background-color: #475569; text-decoration: none; }

.btn-danger { background-color: var(--accent-danger); color: #fff; }
.btn-danger:hover { background-color: #dc2626; text-decoration: none; }

.btn-sm {
  min-height: 32px;
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* BATCH MULTI-LABEL PRINT PREVIEWS & STICKER SIZES */
.batch-print-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: center;
  margin: 1rem 0;
}

.sticker-card {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.label-preset-standard .sticker-card {
  width: 55mm;
  height: 35mm;
  padding: 2.5mm 3.5mm;
  box-sizing: border-box;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  page-break-inside: avoid;
}

.label-preset-small .sticker-card {
  width: 44mm;
  height: 28mm;
  padding: 2mm;
  box-sizing: border-box;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  page-break-inside: avoid;
}

.label-preset-large .sticker-card {
  width: 75mm;
  height: 45mm;
  padding: 4mm 5mm;
  box-sizing: border-box;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  page-break-inside: avoid;
}

.label-preset-a4 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4mm;
  width: 210mm;
  margin: 0 auto;
}
.label-preset-a4 .sticker-card {
  width: 65mm;
  height: 34mm;
  padding: 2.5mm;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  page-break-inside: avoid;
}

/* RESPONSIVE MOBILE PHONE (PWA) OVERHAUL (< 650px) */
.bulk-arrival-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 850px) {
  .bulk-arrival-grid {
    grid-template-columns: 1fr !important;
  }
}

.variant-input-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-primary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
}

/* Mobile Product Color Cards & Responsive Viewports (< 650px) */
.mobile-variant-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  margin-bottom: 0.5rem;
}

@media (max-width: 650px) {
  .desktop-color-table { display: none !important; }
  .mobile-color-cards-container { display: flex !important; flex-direction: column; gap: 0.5rem; }
  
  .model-group-card > div:first-child {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.6rem !important;
  }

  .model-group-card .product-info-cell {
    width: 100%;
  }

  .grid-cards {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (min-width: 651px) {
  .mobile-color-cards-container { display: none !important; }
  .desktop-color-table { display: table !important; }
}

@media (max-width: 550px) {
  .variant-input-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .variant-input-card > div:last-child {
    width: 100% !important;
  }
  .variant-input-card input[type="number"] {
    min-height: 38px !important;
    width: 100% !important;
    font-size: 0.9rem !important;
  }
}

@media print {
  body { background: #ffffff !important; color: #000000 !important; padding-bottom: 0; }
  .app-header, .mobile-bottom-nav, .btn, .page-header, .print-controls-card, #mobile-nav-drawer, #mobile-nav-backdrop { display: none !important; }
  .batch-print-wrapper { gap: 0; margin: 0; }
  .sticker-card { border: none !important; box-shadow: none !important; }
}
