/**
 * SABOR URBANO — Core Stylesheet
 * Version: v0.1.0 (SemVer)
 * Standard: Twin Docks Edition / OLED Pure Black / iPadOS & iOS PWA Ready
 */

/* ==========================================================================
   1. DESIGN TOKENS & SYSTEM VARIABLES
   ========================================================================== */
:root {
  /* Brand & Accent (Default: Street Orange) */
  --primary: #ff6b2b;
  --primary-rgb: 255, 107, 43;

  /* Pure OLED Palette (Dark Mode by default) */
  --bg: #000000;
  --surface: #0c0c0e;
  --surface-2: #161618;
  --surface-3: #1f1f22;

  /* Borders & Luminance */
  --border: rgba(255, 255, 255, 0.08);
  --border-lum: rgba(255, 255, 255, 0.16);

  /* Typography Colors */
  --text: #f5f5f7;
  --text-muted: #a1a1a6;
  --text-soft: #6e6e73;

  /* Status Colors */
  --success: #30d158;
  --danger: #ff453a;
  --warning: #ff9f0a;
  --info: #0a84ff;

  /* Layout Geometry */
  --bar-height: 60px;
  --dock-bg: rgba(18, 18, 20, 0.78);
  --dock-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border-lum);

  /* Radiuses */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 26px;

  /* Typography */
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Light Theme Override */
[data-theme="light"] {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #ebebeb;
  --surface-3: #e1e1e4;
  --border: rgba(0, 0, 0, 0.08);
  --border-lum: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-soft: #86868b;
  --dock-bg: rgba(255, 255, 255, 0.82);
  --dock-shadow: 0 14px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--border-lum);
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* Strict iOS Safari Anti-Zoom on Inputs & Selects */
input, textarea, select {
  font-family: inherit;
  font-size: 16px !important;
  color: var(--text);
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  user-select: text;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.25);
}

/* Micro-interaction: Physical tactile press */
.touchable {
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1), opacity 150ms ease;
  cursor: pointer;
}
.touchable:active {
  transform: scale(0.95);
  opacity: 0.82;
}

/* ==========================================================================
   3. TWIN DOCKS (TOP & BOTTOM FLOATING CAPSULES)
   ========================================================================== */
header.top-dock, nav.bottom-dock {
  position: fixed;
  left: 1rem;
  right: 1rem;
  max-width: 640px;
  margin: 0 auto;
  height: var(--bar-height);
  background: var(--dock-bg);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border-radius: var(--r-pill);
  box-shadow: var(--dock-shadow);
  z-index: 1000;
  display: flex;
  align-items: center;
}

/* Top Dock positioned below safe-area */
header.top-dock {
  top: calc(10px + env(safe-area-inset-top));
  justify-content: space-between;
  padding: 0 14px;
}

/* Bottom Dock positioned above safe-area */
nav.bottom-dock {
  bottom: calc(12px + env(safe-area-inset-bottom));
  justify-content: space-around;
  padding: 0 6px;
}

.top-dock-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dock-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.top-dock-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text);
}
.badge-counter {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 17px;
  text-align: center;
  border: 2px solid var(--surface);
}

/* Bottom Nav Items with Total Tap Area */
.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-soft);
  background: none;
  border: none;
  position: relative;
}
.nav-item.active {
  color: var(--primary);
}
.nav-item svg, .nav-item span {
  pointer-events: none;
}
.nav-item span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   4. CANVAS & LAYOUT ARCHITECTURE
   ========================================================================== */
main.canvas {
  max-width: 680px;
  margin: 0 auto;
  padding-top: calc(var(--bar-height) + env(safe-area-inset-top) + 24px);
  padding-bottom: calc(var(--bar-height) + env(safe-area-inset-bottom) + 38px);
  padding-left: 1.2rem;
  padding-right: 1.2rem;
  min-height: 100vh;
}

.large-title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 4px;
}
.subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 24px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

/* ==========================================================================
   5. CARDS, BADGES & INTERACTIVE COMPONENTS
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 18px;
  margin-bottom: 14px;
}
.card-lum {
  border: 1px solid var(--border-lum);
}

.overview-card {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.28) 0%, rgba(var(--primary-rgb), 0.05) 100%), var(--surface);
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  border-radius: var(--r-xl);
  padding: 20px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

/* Plan Badges with WCAG Contrast Calibration */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.level-bronce { background: rgba(184, 115, 51, 0.22); color: #cd7f32; border: 1px solid rgba(184, 115, 51, 0.45); }
.level-silver { background: rgba(192, 192, 192, 0.28); color: #8e8e93; border: 1px solid rgba(192, 192, 192, 0.55); }
[data-theme="dark"] .level-silver { color: #f2f2f7; }
[data-theme="light"] .level-silver { color: #48484a; }
.level-gold { background: rgba(255, 215, 0, 0.22); color: #ffd700; border: 1px solid rgba(255, 215, 0, 0.45); }
.level-diamond { background: rgba(90, 200, 250, 0.22); color: #5ac8fa; border: 1px solid rgba(90, 200, 250, 0.45); }

/* Horizontal Carousels */
.horizontal-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.horizontal-scroll::-webkit-scrollbar { display: none; }
.scroll-card {
  flex: 0 0 160px;
  scroll-snap-align: start;
}

/* ==========================================================================
   6. PRODUCT GRID & CARDS
   ========================================================================== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 600px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.product-thumb-wrap {
  width: 100%;
  height: 125px;
  position: relative;
  background: var(--surface-2);
}
.product-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fav-heart-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fav-heart-btn.active { color: #ff375f; }

.product-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.product-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
  line-height: 1.25;
}
.product-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.product-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 4px;
}
.price-net {
  font-weight: 700;
  font-size: 1rem;
}
.price-iva {
  font-size: 10px;
  color: var(--text-soft);
}
.add-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Category Pills */
.cat-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.cat-pills::-webkit-scrollbar { display: none; }
.cat-pill {
  padding: 8px 16px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  border: none;
  cursor: pointer;
}
.cat-pill.active {
  background: var(--primary);
  color: #ffffff;
}

/* ==========================================================================
   7. BUTTONS & CONTROLS
   ========================================================================== */
.btn-primary {
  width: 100%;
  height: 52px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--r-pill);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-secondary {
  width: 100%;
  height: 48px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.btn-danger {
  background: rgba(255, 69, 58, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 69, 58, 0.4);
}

/* Delivery vs Pickup Segmented Control */
.segmented-control {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}
.segment-btn {
  flex: 1;
  height: 40px;
  border-radius: var(--r-pill);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.segment-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   8. CART & VOUCHER ITEMS
   ========================================================================== */
.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 14px;
  margin-bottom: 10px;
}
.cart-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--surface-2);
}
.cart-item-info { flex: 1; }
.qty-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 4px 8px;
}
.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Voucher Container in History */
.voucher-card {
  background: var(--surface-2);
  border: 1px dashed var(--border-lum);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-top: 10px;
  font-size: 0.85rem;
}
.voucher-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* ==========================================================================
   9. BOTTOM SHEETS MODALES (DRAG-TO-DISMISS)
   ========================================================================== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-overlay.open {
  opacity: 1;
  visibility: visible;
}
.sheet-modal {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border-top-left-radius: var(--r-xl);
  border-top-right-radius: var(--r-xl);
  border: 1px solid var(--border-lum);
  border-bottom: none;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
.sheet-overlay.open .sheet-modal {
  transform: translateY(0);
}
.sheet-handle-bar {
  width: 100%;
  padding: 12px 0 6px;
  display: flex;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}
.sheet-handle {
  width: 44px;
  height: 5px;
  background: var(--border-lum);
  border-radius: 4px;
}
.sheet-content {
  padding: 12px 20px 20px;
  overflow-y: auto;
}

/* ==========================================================================
   10. TOAST FLOTANTE DE CRISTAL
   ========================================================================== */
#toastContainer {
  position: fixed;
  bottom: calc(var(--bar-height) + env(safe-area-inset-bottom) + 20px);
  left: 1rem;
  right: 1rem;
  max-width: 420px;
  margin: 0 auto;
  z-index: 3000;
  pointer-events: none;
}
.toast {
  background: var(--dock-bg);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-lum);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  border-radius: var(--r-pill);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}
@keyframes toastIn {
  from { transform: translateY(20px) scale(0.92); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.toast-undo-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ==========================================================================
   11. COLOR GRID & SETTINGS
   ========================================================================== */
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0;
}
.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   12. THERMAL PRINT STYLES (KDS 58mm / 80mm RECEIPT PRINTING)
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  header.top-dock, nav.bottom-dock, .sheet-overlay, #toastContainer, .no-print {
    display: none !important;
  }
  .print-ticket {
    width: 100% !important;
    max-width: 80mm !important;
    margin: 0 auto !important;
    padding: 6px !important;
    font-family: monospace !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
  }
  .print-ticket-title {
    font-size: 16px !important;
    font-weight: bold !important;
    text-align: center !important;
  }
}
