/* ==========================================================================
   UNIVERSAL INVENTORY & POS SYSTEM - MODERN DESIGN SYSTEM (CSS)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Brand Palette */
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-800: #3730a3;
  --primary-900: #312e81;

  /* Accent Emerald (POS & Success) */
  --accent-500: #10b981;
  --accent-600: #059669;

  /* Neutral Slate */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Feedback Colors */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #0ea5e9;
  --info-bg: rgba(14, 165, 233, 0.12);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);

  /* Glassmorphism & Borders */
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(226, 232, 240, 0.8);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout Dimensions */
  --sidebar-width: 270px;
  --header-height: 70px;
}

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

body {
  font-family: var(--font-sans);
  background-color: #f8fafc;
  color: var(--slate-800);
  line-height: 1.5;
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  color: var(--primary-700);
}

/* ==========================================================================
   APP LAYOUT (Sidebar & Main Container)
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--slate-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  border-right: 1px solid var(--slate-800);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--slate-800);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.brand-text h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.7rem;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.sidebar-nav {
  padding: 1.25rem 0.875rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--slate-400);
  padding: 0.75rem 0.75rem 0.375rem;
  letter-spacing: 0.08em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 0.875rem;
  color: var(--slate-300);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  color: var(--slate-400);
  transition: color 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-link:hover svg {
  color: var(--primary-400);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.08));
  color: #fff;
  font-weight: 600;
  border-left: 3px solid var(--primary-500);
}

.nav-link.active svg {
  color: var(--primary-400);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--slate-800);
  background: rgba(15, 23, 42, 0.6);
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role-badge {
  font-size: 0.68rem;
  color: var(--primary-300);
  text-transform: capitalize;
}

/* Main Content Area */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #f8fafc;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-heading h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.currency-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-700);
}

.currency-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-500);
}

.maintenance-badge-active {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Page Container */
.page-body {
  padding: 2rem;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.stat-icon.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-icon.emerald { background: linear-gradient(135deg, #10b981, #047857); }
.stat-icon.amber { background: linear-gradient(135deg, #f59e0b, #b45309); }
.stat-icon.rose { background: linear-gradient(135deg, #f43f5e, #be123c); }
.stat-icon.indigo { background: linear-gradient(135deg, #6366f1, #4338ca); }

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--slate-500);
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.2;
  margin-top: 0.2rem;
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--slate-400);
  margin-top: 0.25rem;
}

/* Card Component */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.75rem;
}

.card-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--slate-500);
  margin-top: 0.2rem;
}

.card-body {
  padding: 1.75rem;
}

.card-footer {
  padding: 1rem 1.75rem;
  background: var(--slate-50);
  border-top: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================================================
   BUTTONS & FORMS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.25;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: #fff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-700), var(--primary-800));
  color: #fff;
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: #fff;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.25);
}

.btn-accent:hover {
  background: linear-gradient(135deg, var(--accent-600), #047857);
  color: #fff;
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
  background: #fff;
  border-color: var(--slate-300);
  color: var(--slate-700);
}

.btn-secondary:hover {
  background: var(--slate-100);
  color: var(--slate-900);
  border-color: var(--slate-400);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  color: #fff;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 0.4rem;
}

.form-label .required {
  color: var(--danger);
  margin-left: 0.2rem;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.875rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--slate-900);
  background: #fff;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

.form-helper {
  font-size: 0.75rem;
  color: var(--slate-500);
  margin-top: 0.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.table th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--slate-200);
}

.table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-700);
  vertical-align: middle;
}

.table tr:hover td {
  background: var(--slate-50);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-primary { background: var(--primary-100); color: var(--primary-800); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-secondary { background: var(--slate-100); color: var(--slate-600); }

/* Alerts & Toasts */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); border-color: rgba(16, 185, 129, 0.3); color: #065f46; }
.alert-warning { background: var(--warning-bg); border-color: rgba(245, 158, 11, 0.3); color: #92400e; }
.alert-danger { background: var(--danger-bg); border-color: rgba(239, 68, 68, 0.3); color: #991b1b; }
.alert-info { background: var(--info-bg); border-color: rgba(14, 165, 233, 0.3); color: #075985; }

/* Toast Notification Container */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--primary-600);
  box-shadow: var(--shadow-lg);
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  animation: slideInRight 0.3s ease;
}

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

/* ==========================================================================
   AUTH LAYOUT
   ========================================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 10% 20%, #1e1b4b 0%, #0f172a 90%);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.auth-bg-blob {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, rgba(99, 102, 241, 0) 70%);
  filter: blur(40px);
  pointer-events: none;
}

.auth-blob-1 { top: -100px; right: -100px; }
.auth-blob-2 { bottom: -100px; left: -100px; }

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 50px rgba(0, 0, 0, 0.3);
  padding: 2.5rem;
  position: relative;
  z-index: 10;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.auth-logo {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, var(--primary-600), var(--accent-500));
  color: #fff;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 800;
  box-shadow: var(--shadow-glow);
  margin: 0 auto 1.25rem auto;
}

.auth-logo-img {
  max-height: 85px;
  max-width: 240px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto 1.25rem auto;
  display: block;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.08));
}

.auth-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--slate-900);
  letter-spacing: -0.02em;
}

.auth-header p {
  font-size: 0.875rem;
  color: var(--slate-500);
  margin-top: 0.35rem;
}

/* ==========================================================================
   VIEWPORT GATEKEEPER RESTRICTION SCREEN
   ========================================================================== */
.viewport-lock-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  padding: 2rem;
  text-align: center;
}

.lock-card {
  max-width: 520px;
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3rem 2rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.lock-icon-pulse {
  width: 72px;
  height: 72px;
  background: rgba(245, 158, 11, 0.15);
  border: 2px solid var(--warning);
  color: var(--warning);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  animation: pulse 2s infinite;
}

.lock-card h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.lock-card p {
  color: var(--slate-300);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   POINT OF SALE (POS) DEDICATED STYLES
   ========================================================================== */
.product-touch-card:hover {
  border-color: var(--primary-400) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md) !important;
}

.product-touch-card:active {
  transform: scale(0.98);
}

.category-btn {
  transition: all 0.15s ease;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .pos-wrapper {
    grid-template-columns: 1fr !important;
    height: auto !important;
    overflow: visible !important;
  }
}

/* ==========================================================================
   PAGINATION COMPONENT
   ========================================================================== */
.pagination-wrapper {
  background: var(--slate-50);
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .pagination-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ==========================================================================
   CAMERA BARCODE & QR SCANNER COMPONENT
   ========================================================================== */
@keyframes scannerLaser {
  0% { top: 6px; opacity: 0.85; }
  50% { top: calc(100% - 10px); opacity: 1; }
  100% { top: 6px; opacity: 0.85; }
}

.scanner-laser-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #22c55e, #10b981, #22c55e, transparent);
  box-shadow: 0 0 10px #22c55e, 0 0 20px #10b981;
  border-radius: 2px;
  animation: scannerLaser 2s ease-in-out infinite;
}

#scanner_interactive_reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

#scanner_interactive_reader img {
  display: none !important;
}

.scanner-recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  transition: background 0.15s ease;
}

.scanner-recent-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 640px) {
  #modal_barcode_scanner > div {
    max-height: 98vh !important;
    border-radius: 12px !important;
  }
  .scanner-laser-box {
    width: 220px !important;
    height: 150px !important;
  }
}


