/**
 * Grocery Sync - Hebrew RTL Mobile-First Supermarket Design
 * Anti-AI Aesthetic: Crisp, functional, high-contrast, tactile design for real supermarket aisles.
 * Zero generic gradients, zero blurry glassmorphism, zero micro-text.
 */

:root {
  /* Color Palette - High-Contrast Supermarket Dark Theme */
  --bg-app: #121212;
  --bg-surface: #1e1e1e;
  --bg-surface-elevated: #282828;
  --bg-surface-active: #333333;
  
  --border-subtle: #2d2d2d;
  --border-strong: #404040;
  --border-focus: #f59e0b;

  --text-primary: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --text-inverse: #121212;

  /* Semantic Accents */
  --accent-amber: #f59e0b;
  --accent-amber-hover: #d97706;
  --accent-amber-glow: rgba(245, 158, 11, 0.15);

  --accent-green: #10b981;
  --accent-green-bg: #064e3b;
  --accent-red: #ef4444;
  --accent-red-bg: #450a0a;
  --accent-blue: #3b82f6;

  /* Hebrew System Typography */
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Rubik", "Assistant", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Ergonomics */
  --touch-target-min: 48px;
  --touch-target-shopper: 52px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --safe-bottom: 0px;
  --safe-top: 0px;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  :root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
  }
}

/* Base Reset & Mobile Rules */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  direction: rtl;
  text-align: right;
  background-color: var(--bg-app);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

html, body {
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.45;
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  touch-action: pan-y;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* ==================== BANNERS ==================== */

/* iOS Standalone Guidance Banner */
.ios-banner {
  background-color: #27272a;
  border-bottom: 2px solid var(--accent-amber);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.ios-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
}

.ios-banner-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.ios-banner-text {
  font-size: 14px;
  color: #e4e4e7;
  line-height: 1.4;
  flex: 1;
}

.share-icon {
  display: inline-block;
  background: #3f3f46;
  border-radius: 4px;
  padding: 0 6px;
  font-weight: bold;
}

.banner-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Top Toast In-App Alert (Non-blocking & auto-dismissing after 4s) */
.toast-container {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 10000;
  pointer-events: none; /* Crucial: Does NOT block interaction with other buttons */
  padding: 0 16px;
}

.toast-card {
  pointer-events: auto; /* Toast actions remain interactive */
  background: rgba(30, 27, 24, 0.96);
  border: 1px solid var(--accent-amber);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 16px rgba(245, 158, 11, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 14px;
  max-width: 480px;
  width: 100%;
  animation: toastSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

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

.toast-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  animation: pulse 1.5s infinite;
}

.toast-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toast-text strong {
  font-size: 13.5px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-text span {
  font-size: 12px;
  color: #fef3c7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.toast-btn-action {
  background-color: var(--accent-amber);
  color: #000;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.toast-btn-action:hover {
  opacity: 0.9;
}

.toast-btn-dismiss {
  background: transparent;
  border: none;
  color: #a8a29e;
  font-size: 20px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-btn-dismiss:hover {
  color: #fff;
}

/* Auto-Fill Badge in Form */
.label-with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.badge-autofill {
  font-size: 11px;
  font-weight: 600;
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  animation: fadeIn 0.25s ease-out;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Active Shopper Bar */
.shopper-active-bar {
  background-color: #1c1917;
  border-bottom: 1px solid #44403c;
  padding: 8px 16px;
  font-size: 13px;
  color: #fef3c7;
}

.shopper-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
}

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

/* ==================== APP HEADER ==================== */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: var(--safe-top);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 640px;
  margin: 0 auto;
}

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

.brand-icon {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--accent-amber);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.sync-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-green);
  display: inline-block;
}

.status-dot.disconnected {
  background-color: var(--accent-red);
}

.status-dot.reconnecting {
  background-color: var(--accent-amber);
}

.status-divider {
  color: var(--border-strong);
}

.item-count-pill {
  font-size: 12px;
  background-color: var(--bg-surface-elevated);
  padding: 1px 7px;
  border-radius: 4px;
  color: #d4d4d8;
  font-weight: 600;
}

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

.btn-header-install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--accent-amber);
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 0 12px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-header-icon {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-header-icon:active {
  background-color: var(--bg-surface-active);
}

/* ==================== SORTING & DISPLAY TOOLBAR ==================== */
.sorting-toolbar {
  border-top: 1px solid var(--border-subtle);
  background-color: #171717;
  padding: 8px 16px;
}

.sorting-toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 420px) {
  .sorting-toolbar {
    padding: 6px 10px;
  }
  .sorting-toolbar-inner {
    gap: 4px;
  }
  .sort-label {
    font-size: 11px;
  }
  .sort-select {
    font-size: 12px;
    padding: 2px 4px;
    height: 30px;
  }
  .btn-ghost-tool {
    font-size: 11px;
    padding: 2px 6px;
    height: 30px;
  }
}

.sort-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sort-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sort-select {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  height: 32px;
}

.sort-select:focus {
  outline: none;
  border-color: var(--accent-amber);
}

.btn-ghost-tool {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  height: 32px;
  white-space: nowrap;
}

.btn-ghost-tool:active {
  background-color: var(--bg-surface-active);
  color: var(--text-primary);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Shopper Mode Pill Banner */
.shopper-mode-pill-banner {
  background-color: #000;
  border: 2px solid var(--accent-amber);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pill-banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #fff;
}

.pulsing-amber-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-amber);
  box-shadow: 0 0 10px var(--accent-amber);
  animation: pulse 1s infinite;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 54px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 15px;
  max-width: 320px;
  margin: 0 auto;
}

/* ==================== DYNAMIC SECTIONS ==================== */
.dynamic-sections-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-group {
  margin-bottom: 4px;
}

.section-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title {
  font-size: 16px;
  font-weight: 800;
  color: #e4e4e7;
  letter-spacing: -0.2px;
}

.section-count-badge {
  font-size: 12px;
  font-weight: 700;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: #d4d4d8;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.section-chevron {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.section-group.collapsed .section-chevron {
  transform: rotate(90deg);
}

.section-group.collapsed .section-items-list {
  display: none;
}

.section-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Item Card */
.item-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: stretch;
  min-height: var(--touch-target-min);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
  user-select: none;
  overflow: hidden;
}

.item-card:active {
  background-color: var(--bg-surface-elevated);
}

.item-card.highlight-flash {
  border-color: var(--accent-amber);
  box-shadow: 0 0 16px var(--accent-amber);
  animation: highlightGlow 2.5s ease-out;
}

@keyframes highlightGlow {
  0% { transform: scale(1.02); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* Checkbox Button Container */
.item-check-btn {
  background: transparent;
  border: none;
  width: var(--touch-target-min);
  min-width: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
}

.checkbox-custom {
  width: 26px;
  height: 26px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.checkbox-custom svg {
  display: none;
}

/* Item Content Body */
.item-content {
  flex: 1;
  padding: 12px 10px 12px 2px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
}

.item-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  word-break: break-word;
}

.item-qty-badge {
  font-size: 13px;
  font-weight: 700;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--accent-amber);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.item-sub-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.item-note {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Quick Edit Trigger Icon */
.item-edit-trigger {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.item-edit-trigger:active {
  color: var(--text-primary);
}

/* Checked Item State */
.item-card.is-checked {
  opacity: 0.55;
  background-color: #171717;
}

.item-card.is-checked .item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.item-card.is-checked .checkbox-custom {
  background-color: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.item-card.is-checked .checkbox-custom svg {
  display: block;
}

/* ==================== COMPLETED ITEMS TRAY ==================== */
.completed-tray {
  margin-top: 32px;
  border-top: 2px solid var(--border-subtle);
  padding-top: 16px;
}

.completed-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  cursor: pointer;
}

.completed-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chevron-icon {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.completed-tray.collapsed .chevron-icon {
  transform: rotate(90deg);
}

.completed-tray.collapsed .completed-items-list {
  display: none;
}

.completed-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
}

.btn-text-danger {
  background: transparent;
  border: none;
  color: var(--accent-red);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  min-height: 38px;
}

.btn-text-danger:hover {
  background-color: var(--accent-red-bg);
}

.completed-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* ==================== STICKY BOTTOM THUMB BAR ==================== */
.sticky-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  overflow: hidden;
  background-color: var(--bg-surface);
  border-top: 2px solid var(--border-subtle);
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 80;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
}

.bottom-bar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
  overflow: hidden;
}

/* Base button properties for all 4 navigation actions */
.btn-shopper-toggle,
.btn-voice-toggle,
.btn-scanner-toggle,
.btn-add-primary {
  min-width: 0;
  box-sizing: border-box;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  font-family: var(--font-family);
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

/* 1. Shopper Mode Button */
.btn-shopper-toggle {
  flex: 1.05 1 0;
  gap: 5px;
  padding: 0 6px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 700;
}

.btn-shopper-toggle:active {
  background-color: var(--bg-surface-active);
}

.shopper-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shopper-toggle-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 2. Voice Mode Button */
.btn-voice-toggle {
  flex: 0.85 1 0;
  gap: 5px;
  padding: 0 6px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
  font-size: 13.5px;
  font-weight: 700;
}

.btn-voice-toggle:active,
.btn-voice-toggle.is-listening {
  background-color: rgba(245, 158, 11, 0.2);
  color: #fff;
  border-color: #fbbf24;
}

.voice-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.voice-toggle-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 3. Barcode Scanner Button */
.btn-scanner-toggle {
  flex: 0.95 1 0;
  gap: 5px;
  padding: 0 6px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid rgba(59, 130, 246, 0.45);
  color: #60a5fa;
  font-size: 13.5px;
  font-weight: 700;
}

.btn-scanner-toggle:active {
  background-color: rgba(59, 130, 246, 0.18);
}

.scanner-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.scanner-toggle-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 4. Primary Add Item Button */
.btn-add-primary {
  flex: 1.25 1 0;
  gap: 6px;
  padding: 0 8px;
  background-color: var(--accent-amber);
  color: #000;
  font-size: 14.5px;
  font-weight: 800;
  border: none;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-add-primary:active {
  background-color: var(--accent-amber-hover);
  transform: scale(0.98);
}

.btn-add-primary svg {
  flex-shrink: 0;
}

.add-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-spacer {
  height: 96px;
}

/* Responsive adjustments for phones & small screens */
@media (max-width: 480px) {
  .sticky-bottom-bar {
    padding: 7px 8px;
    padding-bottom: calc(7px + var(--safe-bottom));
  }
  .bottom-bar-container {
    gap: 6px;
  }
  .btn-shopper-toggle,
  .btn-voice-toggle,
  .btn-scanner-toggle,
  .btn-add-primary {
    height: 48px;
    font-size: 12.5px;
    gap: 4px;
    padding: 0 4px;
  }
  .btn-add-primary {
    font-size: 13px;
    padding: 0 6px;
  }
}

@media (max-width: 360px) {
  .sticky-bottom-bar {
    padding: 6px 6px;
    padding-bottom: calc(6px + var(--safe-bottom));
  }
  .bottom-bar-container {
    gap: 4px;
  }
  .btn-shopper-toggle,
  .btn-voice-toggle,
  .btn-scanner-toggle,
  .btn-add-primary {
    height: 46px;
    font-size: 11.5px;
    gap: 3px;
    padding: 0 2px;
  }
  .btn-add-primary {
    font-size: 12px;
    padding: 0 4px;
  }
}

/* ==================== SHOPPER MODE STYLING ==================== */
body.shopper-mode-active {
  background-color: #000000;
}

body.shopper-mode-active .app-header {
  background-color: #000000;
  border-bottom: 2px solid var(--accent-amber);
}

body.shopper-mode-active .sorting-toolbar {
  display: none; /* Hide extraneous controls during shopping */
}

body.shopper-mode-active .item-card {
  background-color: #0a0a0a;
  border: 2px solid #262626;
  min-height: var(--touch-target-shopper);
}

body.shopper-mode-active .item-card:hover {
  border-color: #404040;
}

/* 52px touch targets for Shopper mode */
body.shopper-mode-active .item-check-btn {
  width: var(--touch-target-shopper);
  min-width: var(--touch-target-shopper);
}

body.shopper-mode-active .checkbox-custom {
  width: 34px;
  height: 34px;
  border-width: 3px;
  border-color: #737373;
}

body.shopper-mode-active .item-name {
  font-size: 19px;
  font-weight: 700;
}

body.shopper-mode-active .item-qty-badge {
  font-size: 15px;
  padding: 4px 10px;
  background-color: #171717;
  border-color: var(--accent-amber);
}

body.shopper-mode-active .btn-shopper-toggle {
  background-color: var(--accent-green);
  color: #fff;
  border-color: var(--accent-green);
}

/* ==================== MODALS & BOTTOM SHEETS ==================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  background-color: var(--bg-surface);
  border-top: 2px solid var(--border-strong);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 20px calc(24px + var(--safe-bottom)) 20px;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 32px;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Form Controls */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
}

.form-input, .form-select {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  width: 100%;
  min-height: 48px;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 2px var(--accent-amber-glow);
}

.quick-qty-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.qty-chip {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.qty-chip:active {
  background-color: var(--accent-amber);
  color: #000;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions-edit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 15px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
}

.btn-primary {
  background-color: var(--accent-amber);
  color: #000;
  flex: 1;
}

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

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

.btn-danger-action {
  background-color: var(--accent-red-bg);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
  font-size: 14px;
  font-weight: 700;
  padding: 0 16px;
  min-height: 48px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-danger-action:active {
  background-color: var(--accent-red);
  color: #fff;
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-xs {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.btn-outline {
  background: transparent;
  border: 1px solid #737373;
  color: #e4e4e7;
}

.btn-block {
  width: 100%;
}

/* Settings Modal Specifics */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.settings-icon {
  font-size: 20px;
}

.settings-card-text {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}

.badge-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.badge-active {
  background-color: var(--accent-green-bg);
  color: #6ee7b7;
  border: 1px solid var(--accent-green);
}

.badge-unknown {
  background-color: #27272a;
  color: #a1a1aa;
}

.badge-blocked {
  background-color: var(--accent-red-bg);
  color: #fca5a5;
  border: 1px solid var(--accent-red);
}

.push-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-outline-action {
  background-color: transparent;
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  min-height: 40px;
  cursor: pointer;
}

.btn-ghost-action {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  min-height: 40px;
  cursor: pointer;
}

.ios-push-warning {
  margin-top: 10px;
  font-size: 12px;
  color: #fef08a;
  background-color: #422006;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.code-pill {
  background: #18181b;
  padding: 1px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.system-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-row {
  display: flex;
  justify-content: space-between;
}

.stat-row strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

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

/* ==================== FAMILY ACCESS LOCK SCREEN ==================== */
.auth-lock-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 99999;
  background: rgba(18, 16, 14, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.auth-lock-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 24px rgba(245, 158, 11, 0.15);
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.auth-lock-icon-wrap {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-amber);
}

.auth-lock-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.auth-lock-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.auth-lock-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-lock-form > * + * {
  margin-top: 12px;
}

.auth-password-input {
  text-align: center;
  font-size: 16px;
  letter-spacing: 2px;
  direction: ltr;
}

.auth-error-msg {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
}

.auth-submit-btn {
  margin-top: 8px;
  min-height: 48px;
  font-size: 16px;
}

/* ==================== VOICE MODE STYLING ==================== */
/* In-Modal Voice Button inside Input */
.input-with-voice {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-voice .form-input {
  padding-left: 44px; /* Space for the mic button on the left (RTL) */
  width: 100%;
}

.btn-input-mic {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--accent-amber);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn-input-mic:active,
.btn-input-mic.is-listening {
  background-color: rgba(245, 158, 11, 0.2);
  color: #ef4444;
}

/* Voice Modal Sheet */
.voice-sheet {
  max-width: 480px;
}

.voice-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 0 4px;
}

/* Big Pulsing Mic Button Container */
.voice-mic-container {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 10px auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-mic-main-btn {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-full);
  background: var(--accent-amber);
  color: #000;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
  transition: transform 0.15s ease, background-color 0.2s ease;
}

.voice-mic-main-btn:active {
  transform: scale(0.94);
}

.voice-mic-main-btn.is-listening {
  background: #ef4444;
  color: #fff;
  animation: voiceMicPulse 1.6s infinite ease-in-out;
  box-shadow: 0 4px 24px rgba(239, 68, 68, 0.5);
}

@keyframes voiceMicPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.voice-ripple-ring {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: var(--radius-full);
  border: 2px solid rgba(245, 158, 11, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.voice-mic-main-btn.is-listening ~ .voice-ripple-ring.ripple-1 {
  border-color: rgba(239, 68, 68, 0.6);
  animation: voiceRipple 1.8s infinite cubic-bezier(0.2, 0.8, 0.2, 1);
}

.voice-mic-main-btn.is-listening ~ .voice-ripple-ring.ripple-2 {
  border-color: rgba(239, 68, 68, 0.4);
  animation: voiceRipple 1.8s infinite 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes voiceRipple {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.voice-status-text {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.voice-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Transcript & Live Input Box */
.voice-transcript-box {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  margin-bottom: 14px;
  transition: border-color 0.2s ease;
}

.voice-transcript-box:focus-within {
  border-color: var(--accent-amber);
}

.voice-live-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 600;
  text-align: right;
  direction: rtl;
  padding: 8px 4px;
}

.voice-live-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 14px;
}

.voice-transcript-box.empty .voice-interim-text {
  color: var(--text-muted);
  font-style: italic;
}

.voice-interim-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-amber);
  line-height: 1.4;
  padding: 2px 4px;
  text-align: right;
}

/* Parsed Preview Card */
.voice-preview-card {
  width: 100%;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  text-align: right;
  animation: fadeIn 0.2s ease-out;
}

.voice-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.preview-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.voice-preview-list {
  display: flex;
  flex-direction: column;
}

.voice-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--accent-amber);
}

.voice-preview-row-right {
  display: flex;
  align-items: center;
}

.voice-preview-row-right .preview-name {
  margin-left: 8px;
}

.voice-preview-details {
  display: flex;
  align-items: center;
}

.preview-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-left: 8px;
}

.preview-qty {
  font-size: 13px;
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Options & Actions */
.voice-options {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.voice-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.voice-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-amber);
  cursor: pointer;
}

.voice-actions {
  width: 100%;
  margin-top: 4px;
}

/* ==========================================================================
   14. BARCODE SCANNER & SUPERMARKET PRICE COMPARISON MODAL
   ========================================================================== */

.scanner-sheet {
  max-height: 90vh;
  overflow-y: auto;
}

.scanner-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scanner-cam-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.scanner-cam-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13.5px;
  padding: 0 10px;
  min-height: 44px;
  text-align: center;
  cursor: pointer;
}

.barcode-reader-wrap {
  width: 100%;
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 8px;
  text-align: center;
}

.barcode-reader-box {
  width: 100%;
  min-height: 200px;
  max-height: 280px;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.barcode-reader-box video {
  width: 100% !important;
  height: auto !important;
  border-radius: var(--radius-sm);
}

.scanner-viewfinder-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 6px 0 2px;
}

.scanner-search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
}

.scanner-search-row {
  display: flex;
  gap: 8px;
}

.scanner-search-input {
  flex: 1;
  min-height: 42px;
  font-size: 14px;
}

.scanner-search-submit {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  font-size: 14px;
}

.scanner-city-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scanner-city-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.scanner-city-select {
  flex: 1;
  max-width: 190px;
  min-height: 34px;
  font-size: 13.5px;
}

.scanner-status-msg {
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.scanner-result-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scanner-product-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scanner-product-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scanner-product-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 4px;
  flex-shrink: 0;
}

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

.scanner-product-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.scanner-barcode-tag {
  font-size: 11.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.scanner-product-name {
  font-size: 16.5px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 3px;
  line-height: 1.3;
}

.scanner-product-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.scanner-add-item-btn {
  min-height: 44px;
  font-size: 14.5px;
}

.scanner-section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.scanner-alternatives-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scanner-alt-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.scanner-alt-chip.active {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.16);
  color: var(--accent-amber);
  font-weight: 700;
}

.scanner-price-summary {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: #a7f3d0;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.scanner-prices-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scanner-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  gap: 8px;
}

.scanner-price-row.is-cheapest {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.08);
}

.scanner-store-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.scanner-store-chain {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.scanner-cheapest-badge {
  background: var(--accent-green);
  color: #000;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

.scanner-store-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scanner-store-price-box {
  text-align: left;
  flex-shrink: 0;
}

.scanner-price-main {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-amber);
}

.scanner-price-row.is-cheapest .scanner-price-main {
  color: #34d399;
}

.scanner-price-reg-strike {
  font-size: 11.5px;
  color: var(--text-muted);
  text-decoration: line-through;
  display: block;
}

.scanner-promo-desc {
  font-size: 11.5px;
  color: var(--accent-amber);
  margin-top: 3px;
  line-height: 1.25;
}

.scanner-price-sub-label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.price-summary-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-summary-card.cheapest {
  color: #34d399;
}

.price-summary-card.expensive {
  color: #f87171;
  text-align: left;
}

.price-summary-label {
  font-size: 12px;
  opacity: 0.9;
}

.price-summary-val {
  font-size: 16px;
  font-weight: 800;
}

.item-price-trigger {
  background: transparent;
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #60a5fa;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-family);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 4px;
  flex-shrink: 0;
}

.item-price-trigger:active {
  background: rgba(96, 165, 250, 0.18);
}



