/* ═══════════════════════════════════════════════════════════════════════════
   ListaCompra - Premium Shopping List UI
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  /* Colors - Dark theme */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1f2a42;
  --bg-elevated: #243049;
  --bg-modal: #151d30;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #475569;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-subtle: rgba(99, 102, 241, 0.1);

  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.2);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;

  /* Store Colors */
  --mercadona: #00a650;
  --mercadona-bg: rgba(0, 166, 80, 0.15);
  --carrefour: #004e9e;
  --carrefour-bg: rgba(0, 78, 158, 0.15);

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(99, 102, 241, 0.3);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 50%;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Layout */
  --header-height: 60px;
  --max-width: 640px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background gradient */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(34, 197, 94, 0.05) 0%, transparent 50%);
  z-index: -1;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-5%, -5%) rotate(3deg); }
}

input, select, button, textarea {
  font-family: var(--font);
  font-size: 0.95rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

/* ─── App Layout ───────────────────────────────────────────────────────────── */
#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.logo-icon {
  font-size: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Connection Status */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.3s;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulse 2s infinite;
}

.status-dot.disconnected {
  background: var(--danger);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

/* User Badge */
.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.user-badge:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.user-badge .material-symbols-rounded {
  font-size: 18px;
  color: var(--accent);
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.icon-btn:active {
  transform: scale(0.92);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary .material-symbols-rounded {
  font-size: 20px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.btn-secondary .material-symbols-rounded {
  font-size: 20px;
}

/* FAB */
.fab {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  right: max(16px, calc((100vw - var(--max-width)) / 2 + 16px));
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg), 0 0 30px var(--accent-glow);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 50;
}

.fab:hover {
  transform: scale(1.08) rotate(90deg);
  box-shadow: var(--shadow-lg), 0 0 40px var(--accent-glow);
}

.fab:active {
  transform: scale(0.95);
}

.fab .material-symbols-rounded {
  font-size: 28px;
}

/* ─── Views ────────────────────────────────────────────────────────────────── */
.view {
  display: none;
  padding: 16px;
  padding-bottom: calc(80px + var(--safe-bottom));
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Home View ────────────────────────────────────────────────────────────── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.view-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Lists Grid */
.lists-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.list-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  opacity: 0;
  transition: opacity 0.3s;
}

.list-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 20px var(--accent-glow);
}

.list-card:hover::before {
  opacity: 1;
}

.list-card:active {
  transform: scale(0.98);
}

.list-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.list-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
}

.list-card-icon.mercadona {
  background: var(--mercadona-bg);
  color: var(--mercadona);
}

.list-card-icon.carrefour {
  background: var(--carrefour-bg);
  color: var(--carrefour);
}

.list-card-icon.otro {
  background: var(--accent-subtle);
  color: var(--accent);
}

.list-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.list-card-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.list-card-stats .material-symbols-rounded {
  font-size: 16px;
}

.list-card-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.list-card-progress {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.list-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── List View ────────────────────────────────────────────────────────────── */
.list-header-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.list-meta h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.list-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
}

.store-badge .material-symbols-rounded { font-size: 16px; }

.store-badge.mercadona {
  background: var(--mercadona-bg);
  color: var(--mercadona);
}

.store-badge.carrefour {
  background: var(--carrefour-bg);
  color: var(--carrefour);
}

.store-badge.otro {
  background: var(--accent-subtle);
  color: var(--accent);
}

.progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-subtle);
  color: var(--accent-hover);
}

.progress-badge .material-symbols-rounded { font-size: 16px; }

.list-actions {
  display: flex;
  gap: 4px;
}

/* Progress Bar */
.progress-bar-container {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  margin-bottom: 16px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Active Users */
.active-users {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  color: var(--accent-hover);
  margin-bottom: 16px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.active-users .material-symbols-rounded {
  font-size: 18px;
}

/* ─── Items ────────────────────────────────────────────────────────────────── */
.items-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-group {
  animation: fadeIn 0.3s ease;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.category-emoji {
  font-size: 1.1rem;
}

.category-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Item Card */
.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.item-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.item-card.checked {
  opacity: 0.55;
  background: rgba(34, 197, 94, 0.04);
  border-color: rgba(34, 197, 94, 0.15);
}

.item-card.checked .item-name {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.item-card.just-checked {
  animation: checkPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* Checkbox */
.item-checkbox {
  position: relative;
  width: 24px;
  height: 24px;
  min-width: 24px;
  cursor: pointer;
}

.item-checkbox input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.item-checkbox .checkmark {
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  border: 2px solid var(--text-muted);
  border-radius: 7px;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-checkbox .checkmark .material-symbols-rounded {
  font-size: 18px;
  color: white;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item-checkbox input:checked + .checkmark {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 12px var(--success-glow);
}

.item-checkbox input:checked + .checkmark .material-symbols-rounded {
  opacity: 1;
  transform: scale(1);
}

/* Item Image */
.item-image {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-elevated);
}

.item-image-placeholder {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-image-placeholder .material-symbols-rounded {
  font-size: 24px;
  color: var(--text-muted);
}

/* Item Info */
.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 2px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-details {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.item-quantity {
  padding: 1px 6px;
  background: var(--bg-elevated);
  border-radius: 4px;
  font-weight: 600;
}

.item-price {
  color: var(--success);
  font-weight: 600;
}

.item-notes {
  font-style: italic;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.item-checked-by {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* Item Actions */
.item-actions {
  display: flex;
  gap: 2px;
}

.item-actions .icon-btn {
  width: 32px;
  height: 32px;
  opacity: 0;
  transition: opacity 0.2s;
}

.item-card:hover .item-actions .icon-btn {
  opacity: 1;
}

/* ─── Empty States ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  animation: fadeIn 0.5s ease;
}

.empty-icon {
  font-size: 64px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.empty-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ─── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: var(--max-width);
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-large {
  max-height: 85dvh;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-sm {
  max-height: 70dvh;
}

/* ─── Forms ────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Quantity Control */
.quantity-control {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.quantity-control input {
  width: 60px;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-weight: 600;
  padding: 10px 0;
}

.quantity-control input:focus {
  outline: none;
}

.qty-btn {
  width: 40px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.qty-btn:hover {
  background: var(--accent-subtle);
}

/* Store Selector */
.store-selector {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.store-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.store-option:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.store-option.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.store-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
}

.mercadona-bg {
  background: linear-gradient(135deg, #00a650, #00c853);
}

.carrefour-bg {
  background: linear-gradient(135deg, #004e9e, #1976d2);
}

.other-bg {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
}

.other-bg .material-symbols-rounded {
  font-size: 24px;
}

.store-logo-sm {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: white;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* ─── Search ───────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  transition: all 0.2s;
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar .material-symbols-rounded {
  color: var(--text-muted);
  font-size: 22px;
}

.search-bar input {
  flex: 1;
  padding: 12px 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.search-bar input:focus {
  outline: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Store Tabs */
.store-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  background: var(--bg-card-hover);
}

.tab.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* Search Results */
.search-results {
  max-height: 50dvh;
  overflow-y: auto;
}

.search-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.search-placeholder .material-symbols-rounded {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

.product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.product-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.product-card:active {
  transform: scale(0.98);
}

.product-image {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: white;
  padding: 4px;
}

.product-image-ph {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image-ph .material-symbols-rounded {
  font-size: 28px;
  color: var(--text-muted);
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-name {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-category {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.product-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}

.product-ref-price {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.product-add-icon {
  color: var(--accent);
}

.no-results {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
}

.no-results .material-symbols-rounded {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ─── Menu ─────────────────────────────────────────────────────────────────── */
.menu-body {
  padding: 8px 12px 20px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}

.menu-item:hover {
  background: var(--bg-elevated);
}

.menu-item .material-symbols-rounded {
  font-size: 22px;
  color: var(--text-secondary);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger .material-symbols-rounded {
  color: var(--danger);
}

.menu-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

@keyframes toastIn {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ─── Utilities ────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ─── Mobile Adjustments ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .logo h1 { font-size: 1rem; }
  .view-header h2 { font-size: 1.3rem; }
  .list-meta h2 { font-size: 1.2rem; }
  
  .item-actions .icon-btn {
    opacity: 1;
  }

  .store-selector {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }

  .store-option {
    padding: 12px 4px;
    font-size: 0.78rem;
  }

  .store-logo {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
}

/* ─── Swipe hint for items ─────────────────────────────────────────────────── */
@media (hover: none) {
  .item-actions .icon-btn {
    opacity: 0.7;
  }
}

/* ─── Desktop tweaks ───────────────────────────────────────────────────────── */
@media (min-width: 641px) {
  .modal {
    border-radius: var(--radius-xl);
    margin-bottom: 5dvh;
    max-width: 480px;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal-large {
    max-width: 540px;
  }
}
