/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
  /* Color Palette */
  --bg-app: linear-gradient(135deg, #090d16 0%, #111827 100%);
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  
  --primary: #6366f1; /* Indigo */
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  
  --accent-cyan: #06b6d4;
  --accent-cyan-gradient: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  --accent-emerald: #10b981;
  --accent-emerald-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;
  
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  
  /* Status Colors */
  --status-open: #3b82f6;
  --status-pending: #f59e0b;
  --status-completed: #10b981;
  --status-cancelled: #ef4444;
  
  /* Fonts */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Transitions */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & GLOBAL STYLES
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* Restrict maximum width on desktop for mobile feel */
.app-container {
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  position: relative;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 20px 4px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--primary);
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.logo-area h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-area .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-light);
}

.dot-online {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
}

.status-text {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ==========================================================================
   CARDS (GLASSMORPHISM)
   ========================================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-smooth);
}

/* ==========================================================================
   SEARCH CARD & INPUTS
   ========================================================================== */
.search-card {
  position: relative;
  overflow: hidden;
}

.input-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 4px;
  transition: var(--transition-smooth);
}

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

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.input-group input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 12px 12px 12px 42px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 500;
  outline: none;
}

.input-group input::placeholder {
  color: #6b7280;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #818cf8 0%, #4f46e5 100%);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-full {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   CAMERA BARCODE SCANNER
   ========================================================================== */
.scanner-container {
  margin-top: 16px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  padding: 16px;
  animation: fadeIn 0.3s ease-out;
}

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

.scanner-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-light);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.btn-close:hover {
  color: #ffffff;
}

.scanner-preview {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid var(--border-light);
  background-color: #000000;
  position: relative;
}

/* Scanning glowing effect overlay */
.scanner-preview::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: scanLine 2s infinite linear;
  pointer-events: none;
}

.scanner-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* Custom HTML5-QRCode CSS overrides */
#reader__scan_region {
  background: #000 !important;
}
#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* ==========================================================================
   LOADING SPINNER
   ========================================================================== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(99, 102, 241, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

/* ==========================================================================
   EMPTY STATE / GUIDE CARD
   ========================================================================== */
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  animation: fadeIn 0.3s ease-out;
}

.empty-icon-wrapper {
  background: rgba(99, 102, 241, 0.1);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.empty-icon {
  width: 32px;
  height: 32px;
  color: var(--primary-light);
}

.empty-state-card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 280px;
  margin-bottom: 24px;
}

.quick-tips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tip-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-emerald);
  flex-shrink: 0;
}

/* ==========================================================================
   RESULTS SECTION
   ========================================================================== */
.results-section {
  animation: fadeIn 0.4s ease-out;
}

/* Order Summary */
.order-summary-card {
  padding: 16px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.6) 0%, rgba(17, 24, 39, 0.8) 100%);
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 2px;
}

.summary-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
}

.summary-details {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-icon {
  width: 18px;
  height: 18px;
  color: var(--primary-light);
}

.detail-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.detail-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

/* List Headers */
.list-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 4px 10px 4px;
}

.list-section-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.sort-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Badges */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  display: inline-block;
}

.badge-open {
  background: rgba(59, 130, 246, 0.15);
  color: var(--status-open);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--status-pending);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-completed);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-cancelled {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-cancelled);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ==========================================================================
   ITEM CARDS
   ========================================================================== */
.items-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.item-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.item-main-info {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.product-image-container {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

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

.product-image-fallback {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
}

.product-text-info {
  flex-grow: 1;
}

.product-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-sku-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.product-quantity-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  flex-shrink: 0;
  align-self: center;
}

/* Locations Sub-Card */
.item-locations-container {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.location-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.location-label-icon {
  width: 12px;
  height: 12px;
  color: var(--primary-light);
}

.location-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 10px;
}

.location-main-details {
  display: flex;
  align-items: center;
  gap: 8px;
}

.warehouse-pill {
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.location-code {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.location-stock-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-emerald);
}

/* Warnings */
.location-warning-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 500;
}

.warning-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

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

.toast {
  background: #1f2937;
  color: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease;
}

.toast-error {
  border-left: 4px solid var(--status-cancelled);
}

.toast-success {
  border-left: 4px solid var(--status-completed);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-text {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.app-footer {
  text-align: center;
  padding: 24px 0 10px 0;
  margin-top: auto;
}

.app-footer p {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes scanLine {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   LOGIN & LOGOUT STYLES
   ========================================================================== */
.login-page-container {
  justify-content: center;
}

.login-card {
  animation: fadeIn 0.4s ease-out;
}

.login-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 6px;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.login-form .form-group {
  margin-bottom: 16px;
  text-align: left;
}

.login-error {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  animation: fadeIn 0.2s ease-out;
}

.login-error .error-icon {
  width: 18px;
  height: 18px;
  color: #ef4444;
  flex-shrink: 0;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 10px;
}

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

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.btn-logout i {
  width: 18px;
  height: 18px;
}

