/* ==========================================================================
   MERCADEO PWA - DESIGN SYSTEM (VANILLA CSS)
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette (HSL tailormade) */
  --bg-color: #080c14;
  --surface-base: rgba(16, 24, 40, 0.6);
  --surface-card: rgba(255, 255, 255, 0.03);
  --surface-border: rgba(255, 255, 255, 0.08);
  --surface-border-glow: rgba(0, 210, 255, 0.2);
  
  --primary-glow: #00d2ff;
  --secondary-glow: #9d50bb;
  --primary-gradient: linear-gradient(135deg, #00d2ff 0%, #9d50bb 100%);
  
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --border-radius-full: 9999px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 20px rgba(0, 210, 255, 0.15);

  /* Surface variants — used to enable light/dark theming */
  --surface-overlay: rgba(12, 17, 29, 0.95);
  --surface-filter: rgba(10, 14, 25, 0.98);
  --surface-modal: #0c111d;
  --surface-nav: rgba(12, 17, 29, 0.95);
  --surface-input: rgba(0, 0, 0, 0.2);
  --surface-input-deep: rgba(0, 0, 0, 0.3);
  --surface-thumb: #1c2536;
  --surface-track: rgba(255, 255, 255, 0.05);
  --surface-subtle: rgba(255, 255, 255, 0.03);
  --surface-chip-bg: rgba(255,255,255,0.05);
  --surface-chip-border: rgba(255,255,255,0.10);
  --surface-chip-hover-bg: rgba(255,255,255,0.10);
  --surface-chip-hover-border: rgba(255,255,255,0.18);
  --surface-auth: rgba(16, 24, 40, 0.8);
  --surface-banner: rgba(18, 24, 40, 0.97);
}

/* ============================================================
   LIGHT THEME OVERRIDES — applied via data-theme="light" on <html>
   ============================================================ */
[data-theme="light"] {
  --bg-color: #f0f4f8;
  --surface-base: rgba(255, 255, 255, 0.9);
  --surface-card: rgba(0, 0, 0, 0.03);
  --surface-border: rgba(0, 0, 0, 0.09);
  --surface-border-glow: rgba(0, 160, 210, 0.3);
  --primary-glow: #0284c7;
  --secondary-glow: #7c3aed;
  --primary-gradient: linear-gradient(135deg, #0284c7 0%, #7c3aed 100%);
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.12);
  --surface-overlay: rgba(248, 250, 252, 0.97);
  --surface-filter: rgba(248, 250, 252, 0.99);
  --surface-modal: #ffffff;
  --surface-nav: rgba(255, 255, 255, 0.97);
  --surface-input: rgba(0, 0, 0, 0.05);
  --surface-input-deep: rgba(0, 0, 0, 0.07);
  --surface-thumb: #dde3ea;
  --surface-track: rgba(0, 0, 0, 0.08);
  --surface-subtle: rgba(0, 0, 0, 0.02);
  --surface-chip-bg: rgba(0,0,0,0.05);
  --surface-chip-border: rgba(0,0,0,0.10);
  --surface-chip-hover-bg: rgba(0,0,0,0.08);
  --surface-chip-hover-border: rgba(0,0,0,0.14);
  --surface-auth: rgba(255, 255, 255, 0.9);
  --surface-banner: rgba(248, 250, 252, 0.97);
}


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

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  /* Ambient glowing blobs in background */
  background-image: 
    radial-gradient(circle at 90% 90%, rgba(157, 80, 187, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 10% 10%, rgba(0, 210, 255, 0.06) 0%, transparent 45%);
  background-attachment: fixed;
}

/* App Wrapper Container */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-base);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--surface-border);
  border-right: 1px solid var(--surface-border);
  position: relative;
  overflow: hidden;
}

/* Desktop styles wrapper logic */
@media (min-width: 768px) {
  body {
    padding: 24px 0;
  }
  .app-container {
    height: 850px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--surface-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 50px rgba(0, 210, 255, 0.05);
    overflow: hidden;
  }
}

/* ==========================================================================
   STATUS TAPE (OFFLINE/ONLINE)
   ========================================================================== */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: var(--transition-smooth);
}

.status-bar.online {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.status-bar.offline {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* ==========================================================================
   HEADER & BUDGET
   ========================================================================== */
.app-header {
  padding: 20px 24px 12px 24px;
  border-bottom: 1px solid var(--surface-border);
}

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

.app-title {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.03em;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--border-radius-full);
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background-color: var(--surface-chip-bg);
  color: var(--text-primary);
}

/* Budget Card Component */
.budget-card {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.budget-info {
  display: flex;
  justify-content: space-between;
}

.budget-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.budget-field.align-right {
  align-items: flex-end;
}

.budget-field.align-center {
  align-items: center;
}

.label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.budget-value-wrapper {
  display: flex;
  align-items: center;
  gap: 2px;
}

.currency-symbol {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-glow);
}

#input-budget {
  background: none;
  border: none;
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  width: 110px;
  padding: 0;
  outline: none;
}

#input-budget::-webkit-outer-spin-button,
#input-budget::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#input-budget:focus {
  border-bottom: 1px dashed var(--primary-glow);
}

.value {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

/* Item count badge */
.item-count-value {
  font-size: 22px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Budget bar */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-container {
  height: 6px;
  background-color: var(--surface-track);
  border-radius: var(--border-radius-full);
  overflow: hidden;
  position: relative;
  flex: 1;
}

.progress-bar {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--border-radius-full);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-glow);
}

.budget-percent {
  font-family: var(--font-title);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
  transition: var(--transition-smooth);
}

.budget-alert {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-danger);
  text-align: center;
  animation: pulse 1.5s infinite;
}

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

/* ==========================================================================
   VIEW CONTAINER & VIEWS
   ========================================================================== */
.view-content {
  flex: 1;
  overflow: hidden;
  padding: 12px 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.app-view {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fadeIn 0.3s ease;
}

.app-view.active {
  display: flex;
  min-height: 0;
}

#view-stats.active {
  overflow-y: auto;
}

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

.view-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ==========================================================================
   LIST MANAGER TABS
   ========================================================================== */
.list-tabs-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  width: 100%;
}

.list-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}

.list-tabs::-webkit-scrollbar {
  display: none;
}

.tab-item {
  padding: 8px 14px;
  background-color: var(--surface-subtle);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-smooth);
}

.tab-item .tab-name {
  white-space: nowrap;
}

.btn-tab-del {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.tab-item.active .btn-tab-del {
  color: rgba(255, 255, 255, 0.6);
}

.btn-tab-del:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.15);
}

.btn-tab-ren {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.tab-item.active .btn-tab-ren { color: rgba(255, 255, 255, 0.55); }
.btn-tab-ren:hover { color: var(--primary-glow); background: rgba(0, 210, 255, 0.12); }

.rename-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-input);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
  margin-bottom: .6rem;
}
.rename-input:focus { border-color: var(--primary-glow); }

.tab-item.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 210, 255, 0.15);
}

.btn-tab-add {
  width: 36px;
  height: 36px;
  background-color: var(--surface-chip-bg);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  font-size: 20px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-tab-add:hover {
  background-color: var(--surface-chip-hover-bg);
  border-color: var(--primary-glow);
}

/* ==========================================================================
   SEARCH BAR & POPULAR SUGGESTIONS
   ========================================================================== */
.search-wrapper {
  position: relative;
  margin-bottom: 16px;
  z-index: 10;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--surface-input);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  gap: 10px;
  transition: var(--transition-smooth);
}

.search-box:focus-within {
  border-color: var(--primary-glow);
  box-shadow: var(--shadow-glow);
}

.search-icon {
  color: var(--text-muted);
}

#search-input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  outline: none;
}

#search-input::placeholder {
  color: var(--text-muted);
}

.btn-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
}

.btn-clear:hover {
  color: var(--text-primary);
}

/* Suggestion Overlay Popover */
.search-results-overlay {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--surface-border-glow);
  border-radius: var(--border-radius-md);
  max-height: 440px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  z-index: 50;
  scrollbar-width: thin;
}

/* Filter chips bar — sticky dentro del overlay */
.search-filter-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-filter);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.search-chip {
  flex-shrink: 0;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--surface-chip-border);
  background: var(--surface-chip-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.search-chip:hover {
  background: var(--surface-chip-hover-bg);
  color: var(--text-primary);
}
.search-chip.active {
  background: rgba(99,102,241,0.22);
  border-color: rgba(99,102,241,0.55);
  color: #a5b4fc;
}

/* Pill de tienda en cada resultado */
.store-pill {
  display: inline-block;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
  letter-spacing: 0.03em;
}
.store-pill.sm { background: rgba(16,185,129,0.18); color: #34d399; }
.store-pill.ps { background: rgba(59,130,246,0.18); color: #60a5fa; }

.suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition-smooth);
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.suggest-item:last-child {
  border-bottom: none;
}

.suggest-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.suggest-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--border-radius-sm);
  background-color: var(--surface-thumb);
}

.suggest-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  overflow: hidden;
}

.suggest-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggest-brand {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.suggest-price-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.suggest-price-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-glow);
}

.suggest-unit-badge {
  font-size: 10px;
  color: var(--text-muted);
}

.suggest-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================================================
   SHOPPING LIST & PRODUCTS
   ========================================================================== */
.list-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 12px 0;
}

.sort-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-full);
  padding: 4px 12px;
  gap: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.sort-icon {
  color: var(--primary-glow);
}

.sort-select {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-base);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 4px;
}

.sort-select option {
  background-color: var(--surface-card);
  color: var(--text-primary);
}

.list-items-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 8px;
}

.shopping-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item-card {
  display: flex;
  flex-direction: column;
  background-color: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-md);
  padding: 10px 12px;
  gap: 8px;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.15s;
  overflow: hidden;
  cursor: pointer;
}

.list-item-card:active {
  border-color: rgba(0, 210, 255, 0.18);
  background-color: rgba(0, 210, 255, 0.015);
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.card-top .product-checkbox {
  margin-top: 2px;
  flex-shrink: 0;
}

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

.card-bottom .product-thumb {
  flex-shrink: 0;
  cursor: pointer;
}

.product-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

/* Swipe-to-delete indicator background */
.list-item-card.slide-left {
  transform: translateX(-80px);
}

.list-item-card.slide-right {
  transform: translateX(80px);
}

.product-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.product-checkbox:checked {
  background: var(--primary-gradient);
  border-color: transparent;
}

.product-checkbox:checked::after {
  content: '✓';
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.product-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--border-radius-sm);
  background-color: var(--surface-thumb);
}

.product-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  transition: var(--transition-smooth);
}

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

.product-category-chip {
  font-size: 9px;
  font-weight: 600;
  color: var(--secondary-glow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.product-unit-price {
  font-size: 12px;
  color: var(--text-secondary);
}

.qty-controls {
  display: flex;
  align-items: center;
  background-color: var(--surface-subtle);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-full);
  padding: 2px;
  gap: 6px;
}

.btn-qty {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-qty:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.qty-val {
  font-size: 12px;
  font-weight: 700;
  min-width: 14px;
  text-align: center;
}

.product-subtotal {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-glow);
}

.btn-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-delete:hover {
  color: var(--color-danger);
  background-color: rgba(239, 68, 68, 0.05);
}

/* Empty State Styling */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
  flex: 1;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 10px rgba(0,210,255,0.2));
}

.empty-state h2 {
  font-family: var(--font-title);
  color: var(--text-primary);
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  line-height: 1.5;
}

/* ==========================================================================
   STATISTICS & CHARTS (VIEW 2)
   ========================================================================== */
.stats-summary-card {
  display: flex;
  background-color: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.summary-metric {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-metric:first-child {
  border-right: 1px solid var(--surface-border);
}

.summary-metric.align-right {
  align-items: flex-end;
}

.summary-metric:last-child {
  padding-left: 16px;
}

.summary-metric .value {
  font-size: 22px;
}

/* CSS Native bar charts */
.chart-section {
  margin-bottom: 24px;
}

.chart-section h3 {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.category-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chart-row-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.chart-category-name {
  color: var(--text-primary);
}

.chart-category-amount {
  color: var(--text-secondary);
}

.chart-bar-track {
  height: 8px;
  background-color: var(--surface-track);
  border-radius: var(--border-radius-full);
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: var(--border-radius-full);
  width: 0;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Category Specific Color Gradients */
.chart-row:nth-child(1) .chart-bar-fill {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}
.chart-row:nth-child(2) .chart-bar-fill {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}
.chart-row:nth-child(3) .chart-bar-fill {
  background: linear-gradient(90deg, #ec4899, #f472b6);
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.2);
}
.chart-row:nth-child(4) .chart-bar-fill {
  background: linear-gradient(90deg, #10b981, #34d399);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}
.chart-row:nth-child(5) .chart-bar-fill {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  box-shadow: 0 0 10px rgba(245, 158, 11);
}
.chart-row:nth-child(6) .chart-bar-fill {
  background: linear-gradient(90deg, #14b8a6, #2dd4bf);
  box-shadow: 0 0 10px rgba(20, 184, 166, 0.2);
}
.chart-row:nth-child(n+7) .chart-bar-fill {
  background: linear-gradient(90deg, #6b7280, #9ca3af);
}

/* Saved Lists Grid Section */
.saved-lists-section h3 {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

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

.list-card {
  background-color: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-md);
  padding: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-card:hover {
  border-color: var(--primary-glow);
  box-shadow: var(--shadow-glow);
}

.list-card.active {
  border-color: var(--secondary-glow);
  background-color: rgba(157, 80, 187, 0.03);
}

.list-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-card-items-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.list-card-total {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-glow);
}

/* ==========================================================================
   NAVIGATION BAR (STICKY BOTTOM)
   ========================================================================== */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  background-color: var(--surface-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--surface-border);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)) 0;
  z-index: 40;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex: 1;
  transition: var(--transition-smooth);
}

.nav-item.active {
  color: var(--primary-glow);
  text-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

.nav-item svg {
  transition: transform 0.2s ease;
}

.nav-item:active svg {
  transform: scale(0.9);
}

/* ==========================================================================
   SETTINGS MODAL (POPUP)
   ========================================================================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: flex-end; /* Mobile style popup sheets upward */
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  background-color: var(--surface-modal);
  border-top-left-radius: var(--border-radius-lg);
  border-top-right-radius: var(--border-radius-lg);
  border-top: 1px solid var(--surface-border);
  max-height: 85%;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--surface-border);
}

.modal-header h2 {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-group h3 {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* Button stylings inside settings */
.btn-primary {
  background: var(--primary-gradient);
  border: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 12px rgba(0, 210, 255, 0.15);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px rgba(0, 210, 255, 0.25);
}

.sync-status {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.modal-divider {
  border: none;
  height: 1px;
  background-color: var(--surface-border);
}

/* Custom Product Form */
.custom-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

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

.form-row {
  display: flex;
  gap: 12px;
}

.form-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.form-field input {
  background-color: var(--surface-input-deep);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: var(--transition-smooth);
}

.form-field input:focus {
  border-color: var(--primary-glow);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 12px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-glow);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.danger-desc {
  font-size: 10px;
  color: var(--text-muted);
}

/* Spinner Icon */
.icon-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   SNACKBAR (UNDO TOAST)
   ========================================================================== */
.snackbar {
  position: absolute;
  bottom: 80px; /* Above the nav bar */
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  padding: 12px 16px;
  border-radius: var(--border-radius-full);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 1000;
  width: 90%;
  max-width: 360px;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  overflow: hidden;
}

.snackbar.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#snackbar-text {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.btn-undo {
  background: none;
  border: none;
  color: var(--primary-glow);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

.btn-undo:hover {
  background-color: rgba(0, 210, 255, 0.1);
}

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

/* Modal Desktop alignment adjustment */
@media (min-width: 768px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-card {
    width: 90%;
    max-width: 400px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--surface-border);
  }
}

/* ==========================================================================
   AUTH SCREEN
   ========================================================================== */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
  background-image:
    radial-gradient(circle at 80% 80%, rgba(157, 80, 187, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 20% 20%, rgba(0, 210, 255, 0.10) 0%, transparent 50%);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-auth);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-lg);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-logo {
  text-align: center;
}

.auth-logo img {
  border-radius: 12px;
  margin-bottom: .5rem;
}

.auth-logo h1 {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .2rem;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: .85rem;
}

.auth-tabs {
  display: flex;
  background: var(--surface-subtle);
  border-radius: var(--border-radius-md);
  padding: 4px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  padding: .5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.auth-tab.active {
  background: rgba(0, 210, 255, 0.12);
  color: var(--primary-glow);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.auth-error {
  color: var(--color-danger);
  font-size: .82rem;
  text-align: center;
  margin: 0;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .8rem;
  cursor: pointer;
  text-align: center;
  padding: .25rem;
  transition: color .2s;
}
.btn-link:hover { color: var(--text-secondary); }

/* User button in header */
.btn-user {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.user-initial {
  font-family: var(--font-title);
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
}

/* ==========================================================================
   PRODUCT DETAIL BOTTOM SHEET
   ========================================================================== */
.detail-sheet {
  padding: 0;
  max-height: 80vh;
  overflow-y: auto;
}

.detail-handle-bar {
  width: 36px;
  height: 4px;
  background: var(--surface-border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.detail-close-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-chip-bg);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.detail-close-btn:hover {
  background: var(--surface-chip-hover-bg);
  color: var(--text-primary);
}

.detail-img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--surface-border);
  margin-top: 16px;
  display: block;
}

.detail-body {
  padding: 16px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.detail-meta {
  font-size: 10px;
  font-weight: 600;
  color: var(--secondary-glow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--surface-border);
  border-bottom: 1px solid var(--surface-border);
}

.detail-unit-price {
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-subtotal {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-glow);
}

.detail-qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.detail-qty-row .btn-qty {
  width: 38px;
  height: 38px;
  font-size: 20px;
  border: 1px solid var(--surface-border);
}

.detail-qty-row .qty-val {
  font-size: 22px;
  font-weight: 700;
  min-width: 36px;
  text-align: center;
}

/* User menu modal */
.modal-card--sm {
  max-width: 320px;
}

.user-info-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .5rem 0;
}

.user-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-avatar-lg span {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.user-name-lg {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text-primary);
}

.user-email-lg {
  font-size: .8rem;
  color: var(--text-secondary);
}

/* Share link modal */
.share-link-box {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}

.share-url-input {
  flex: 1;
  background: var(--surface-chip-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: .8rem;
  padding: .5rem .75rem;
  outline: none;
  font-family: var(--font-body);
}

.btn-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .75rem;
  background: #25d366;
  color: #fff;
  border-radius: var(--border-radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
  transition: opacity .2s;
}
.btn-whatsapp:hover { opacity: .9; }

/* ==========================================================================
   IN-LIST FILTER BOX
   ========================================================================== */
.list-filter-box {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface-input);
  border: 1px solid var(--surface-border);
  border-radius: var(--border-radius-full);
  padding: 4px 10px;
  gap: 6px;
  min-width: 0;
  transition: border-color 0.2s;
}

.list-filter-box:focus-within {
  border-color: var(--primary-glow);
}

.search-icon-sm {
  color: var(--text-muted);
  flex-shrink: 0;
}

.list-filter-input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  width: 100%;
  outline: none;
  min-width: 0;
}

.list-filter-input::placeholder {
  color: var(--text-muted);
}

/* ==========================================================================
   SEARCH ACTIVE — BLUR LIST BEHIND RESULTS
   ========================================================================== */
#list-items-container {
  transition: opacity 0.25s ease, filter 0.25s ease;
}

#list-items-container.search-active {
  opacity: 0.15;
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

/* ==========================================================================
   SNACKBAR TIMER BAR
   ========================================================================== */
.snackbar-timer-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--primary-gradient);
  border-radius: 0 0 var(--border-radius-full) var(--border-radius-full);
}

/* ==========================================================================
   CATEGORY BROWSE CHIPS BAR
   ========================================================================== */
.category-chips-bar {
  display: flex;
  gap: 7px;
  padding: 8px 0 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.category-chips-bar::-webkit-scrollbar { display: none; }

.cat-browse-chip {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: var(--border-radius-full);
  border: 1px solid var(--surface-chip-border);
  background: var(--surface-chip-bg);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cat-browse-chip:hover {
  background: var(--surface-chip-hover-bg);
  color: var(--text-primary);
  border-color: var(--surface-chip-hover-border);
}
.cat-browse-chip.active {
  background: rgba(99,102,241,0.22);
  border-color: rgba(99,102,241,0.55);
  color: #a5b4fc;
}

/* Browse mode header inside overlay */
.browse-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 2px;
}
.browse-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ==========================================================================
   PWA INSTALL BANNER
   ========================================================================== */
.install-banner {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 420px;
  background: var(--surface-banner);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 16px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(99,102,241,0.15);
  animation: bannerSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.install-banner.hidden { display: none; }

@keyframes bannerSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(24px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.install-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.install-banner-left img {
  flex-shrink: 0;
  border-radius: 9px;
}
.install-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.install-banner-text strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.install-banner-text span {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.install-banner-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.btn-install-app {
  font-size: 12px;
  font-weight: 700;
  padding: 7px 15px;
  border-radius: 10px;
  background: rgba(99,102,241,0.85);
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-install-app:hover { background: rgba(99,102,241,1); }
.btn-install-app.hidden { display: none; }
.btn-install-dismiss {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-chip-bg);
  border: 1px solid var(--surface-chip-border);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-install-dismiss:hover { background: var(--surface-chip-hover-bg); color: var(--text-primary); }

