/* ============================================
   LASSO — Design System
   Estilo: Claro minimalista (Stripe/Airbnb)
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --border: #e5e5e5;
  --border-light: #f0f0f0;
  --text-primary: #171717;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --accent: #171717;
  --accent-light: #404040;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bottom-nav-h: 72px;
  --topbar-h: 56px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* --- App Shell --- */
#appShell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* --- Top Bar --- */
#topBar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
  height: var(--topbar-h);
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.cart-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.cart-btn:hover {
  background: var(--surface-hover);
}

.cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--text-primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 100px;
  padding: 0 5px;
}

/* --- Main Content --- */
#app {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px calc(var(--bottom-nav-h) + 24px);
}

/* --- Bottom Nav --- */
#bottomNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  height: var(--bottom-nav-h);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 24px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font);
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

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

.nav-item svg {
  transition: transform var(--transition);
}

.nav-item.active svg {
  stroke-width: 2.5;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* --- Product Grid --- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all var(--transition);
  cursor: default;
}

.product-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.product-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
}

.product-name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.product-stock {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.product-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.btn-primary {
  background: var(--text-primary);
  color: white;
}

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

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

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

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  flex-shrink: 0;
}

.btn-added {
  background: var(--success);
  color: white;
}

/* --- Forms --- */
.input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.08);
}

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

.select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a3a3a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  outline: none;
}

.select:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.08);
}

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

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--text-primary);
}

/* --- Info Banners --- */
.banner {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.banner-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

.banner-info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
}

.banner strong {
  color: var(--text-primary);
}

/* --- Section titles --- */
.section-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* --- Cart Summary (floating) --- */
.cart-summary {
  position: fixed;
  bottom: var(--bottom-nav-h);
  left: 0;
  right: 0;
  z-index: 35;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
  padding: 16px 20px;
  max-height: 50vh;
  overflow-y: auto;
}

.cart-summary-inner {
  max-width: 640px;
  margin: 0 auto;
}

/* --- Cart Item Row --- */
.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.cart-row:last-of-type {
  border-bottom: none;
}

.cart-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cart-row-name {
  font-size: 14px;
  font-weight: 500;
}

.cart-row-meta {
  font-size: 12px;
  color: var(--text-muted);
}

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

.cart-row-price {
  font-size: 14px;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
}

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

.qty-btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.qty-count {
  font-size: 14px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

/* --- Total bar in summary --- */
.cart-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.cart-total-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.cart-total-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* --- Discount tag --- */
.discount-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--success);
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 16px 0;
}

/* --- Messages --- */
.msg {
  font-size: 13px;
  text-align: center;
  font-weight: 500;
  padding: 8px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.msg-error {
  color: var(--danger);
  background: var(--danger-bg);
}

.msg-info {
  color: var(--text-secondary);
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* --- Order item row (pago view) --- */
.order-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

.order-row:last-of-type {
  border-bottom: none;
}

.order-row-label {
  color: var(--text-secondary);
}

.order-row-value {
  font-weight: 600;
}

/* --- Profile card --- */
.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-name {
  font-size: 16px;
  font-weight: 600;
}

.profile-email {
  font-size: 13px;
  color: var(--text-muted);
}

.profile-role {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 100px;
  display: inline-block;
  margin-top: 4px;
}

/* --- Purchase history --- */
.purchase-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.purchase-item:last-of-type {
  border-bottom: none;
}

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

.purchase-name {
  font-size: 14px;
  font-weight: 500;
}

.purchase-amount {
  font-size: 14px;
  font-weight: 600;
}

.purchase-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100px;
}

.status-completado {
  background: var(--success-bg);
  color: var(--success);
}

.status-pendiente {
  background: #fefce8;
  color: #a16207;
}

/* --- Steps list (pago) --- */
.steps-list {
  list-style: none;
  counter-reset: steps;
}

.steps-list li {
  counter-increment: steps;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.steps-list li::before {
  content: counter(steps);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.copyable {
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px dashed var(--text-muted);
  transition: opacity var(--transition);
}

.copyable:hover {
  opacity: 0.7;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  transition: opacity 0.3s ease;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

/* --- Link style --- */
.link {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 2px;
  cursor: pointer;
  transition: text-decoration-color var(--transition);
}

.link:hover {
  text-decoration-color: var(--text-primary);
}

/* --- Overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 45;
}

/* --- Sidebar (kept for compatibility, visually hidden) --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 280px;
  background: var(--surface);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  border-right: 1px solid var(--border-light);
}

/* --- Spacing utils --- */
.stack-sm > * + * { margin-top: 8px; }
.stack > * + * { margin-top: 12px; }
.stack-md > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.flex-gap { display: flex; gap: 12px; }

/* --- Success screen --- */
.success-screen {
  text-align: center;
  padding: 60px 20px;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.success-icon svg {
  color: var(--success);
}

.success-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Hidden util --- */
.hidden {
  display: none !important;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#app > * {
  animation: fadeIn 0.25s ease;
}

/* --- Responsive: larger screens --- */
@media (min-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
