/* ========================================================
   Big Apple 3 — Fast-Scan Mobile Stylesheet
   Modern, Dark-Mode First, High-Contrast for Retail Aisles
   ======================================================== */

:root {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-subtle: #334155;
  --border-color: #334155;
  --border-focus: #38bdf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-success: #10b981;
  --accent-success-hover: #059669;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 540px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 16px 32px 16px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

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

.brand-logo {
  font-size: 2rem;
  line-height: 1;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.user-pill {
  font-size: 0.75rem;
  background: var(--bg-card-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 600;
  color: var(--border-focus);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.btn-icon:hover {
  background: var(--bg-card-subtle);
  color: var(--text-main);
}

/* Tabs */
.tab-bar {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Cards */
.scanner-card,
.product-card,
.placeholder-card,
.audit-card,
.export-card,
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

/* Scanner Button & Container */
.btn-scanner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-heading);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
  transition: transform 0.1s ease;
}

.btn-scanner:active {
  transform: scale(0.98);
}

.scanner-icon {
  font-size: 1.3rem;
}

.reader-container {
  margin-bottom: 14px;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-focus);
  background: #000;
}

#reader {
  width: 100% !important;
}

.reader-instruction {
  text-align: center;
  font-size: 0.8rem;
  padding: 8px;
  color: var(--text-muted);
  background: #000;
}

/* Search Bar */
.search-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 8px;
}

.search-bar-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.search-icon {
  font-size: 1.1rem;
  color: var(--text-dim);
}

.search-bar-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1rem;
  padding: 8px 4px;
  outline: none;
  font-family: var(--font-body);
}

/* Form Styles */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--font-body);
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-focus);
}

.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.price-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.price-input-wrap input {
  padding-left: 28px;
  font-weight: 700;
  font-size: 1.25rem;
  font-family: var(--font-heading);
}

/* Margin Indicator */
.margin-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.margin-box strong {
  font-size: 1.1rem;
  font-family: var(--font-heading);
}

.margin-good { color: var(--accent-success); border-color: var(--accent-success); }
.margin-medium { color: var(--accent-warning); border-color: var(--accent-warning); }
.margin-low { color: var(--accent-danger); border-color: var(--accent-danger); }

/* Toggles */
.toggle-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  display: none;
}

.slider {
  width: 44px;
  height: 24px;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-full);
  position: relative;
  transition: 0.2s;
  flex-shrink: 0;
}

.slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle-switch input:checked + .slider {
  background: var(--accent-primary);
}

.toggle-switch input:checked + .slider::after {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Buttons */
.btn-primary,
.btn-success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  color: #fff;
}

.btn-primary { background: var(--accent-primary); }
.btn-primary:hover { background: var(--accent-primary-hover); }

.btn-success { background: var(--accent-success); }
.btn-success:hover { background: var(--accent-success-hover); }

.btn-sm {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

/* Badges */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.badge-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: #fff;
  text-transform: uppercase;
}

.badge-new {
  background: var(--accent-warning);
  color: #000;
}

.upc-tag {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Placeholder */
.placeholder-card {
  text-align: center;
  padding: 40px 20px;
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.placeholder-card h3 {
  font-family: var(--font-heading);
  margin-bottom: 6px;
}

.placeholder-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Audit List */
.audit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.audit-item-info {
  display: flex;
  flex-direction: column;
}

.audit-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.audit-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.audit-price-change {
  text-align: right;
}

.old-price {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: line-through;
}

.new-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-success);
}

/* Export Section */
.export-card {
  text-align: center;
  padding: 28px 20px;
}

.export-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.export-card h2 {
  font-family: var(--font-heading);
  margin-bottom: 8px;
}

.export-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.export-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 12px 6px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--border-focus);
}

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

.instructions-box {
  margin-top: 24px;
  text-align: left;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.instructions-box h4 {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--accent-warning);
}

.instructions-box ol {
  padding-left: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Login Card */
.login-card {
  max-width: 400px;
  margin: 60px auto;
  text-align: center;
}

.lock-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.login-header h2 {
  font-family: var(--font-heading);
  margin-bottom: 6px;
}

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

.login-card .input-group {
  text-align: left;
  margin-bottom: 14px;
}

.login-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.login-card input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-main);
  font-size: 1rem;
}

.login-hint {
  margin-top: 16px;
  color: var(--text-dim);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease;
}

.toast.success { background: var(--accent-success); color: #fff; }
.toast.error { background: var(--accent-danger); color: #fff; }
.toast.info { background: var(--accent-primary); color: #fff; }

/* Utilities */
.hidden { display: none !important; }
