/* =======================
   PALETA APURAOPE
   ======================= */

:root {
  --color-primary: #1259a8;
  --color-primary-light: #1e7bd8;
  --color-primary-soft: #e5f1ff;
  --color-accent: #16a34a;
  --color-danger: #ef4444;
  --color-bg: #f3f4f8;
  --color-header: #0b1728;

  --color-text-main: #111827;
  --color-text-muted: #6b7280;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

/* =======================
   RESET BÁSICO
   ======================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

/* Evitar scroll cuando el modal esté abierto */
body.no-scroll {
  overflow: hidden;
}

/* =======================
   CONTENEDOR GENERAL
   ======================= */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* =======================
   HEADER
   ======================= */

.header {
  background: var(--color-header);
  color: #ffffff;
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 700;
}

.logo img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.cart-info {
  font-size: 0.9rem;
}

.nav {
  display: flex;
  gap: 12px;
}

.nav a {
  color: #e5e7eb;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* =======================
   MAIN / HERO
   ======================= */

.main {
  padding: 24px 0 32px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr);
  gap: 24px;
  background: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-primary-light)
  );
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 24px;
}

.hero-text h2 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.hero-text p {
  font-size: 0.95rem;
}

.hero-search {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}

.hero-search input {
  flex: 1;
  border: none;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
  outline: none;
}

.hero-small {
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.9;
}

.hero-illustration {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  text-align: right;
  font-size: 0.85rem;
}

.hero-box {
  width: 160px;
  height: 110px;
  border-radius: 18px;
  background: linear-gradient(135deg, #e0f2ff, #f9fafb);
}

/* =======================
   BOTONES
   ======================= */

.btn {
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.1s;
}

.btn:hover {
  background: var(--color-primary-light);
  box-shadow: 0 4px 12px rgba(18, 89, 168, 0.4);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-clear {
  background: #e5e7eb;
  color: var(--color-text-main);
}

.btn-clear:hover {
  background: #d1d5db;
}

.btn-checkout {
  background: var(--color-accent);
}

.btn-checkout:hover {
  background: #15803d;
}

.btn-whatsapp {
  background: #25d366;
}

.btn-whatsapp:hover {
  background: #16a34a;
}

.btn-modal-add {
  width: 100%;
  margin-top: 16px;
}

/* Botón para productos sin stock */
.btn-out-of-stock {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-out-of-stock:hover {
  background: #e5e7eb;
  color: #9ca3af;
  box-shadow: none;
}

/* =======================
   CATEGORÍAS / CHIPS
   ======================= */

.categories {
  margin-bottom: 16px;
}

.categories h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: none;
  background: #e5e7eb;
  color: var(--color-text-main);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.chip.active {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(18, 89, 168, 0.45);
}

/* =======================
   PANEL DEL CARRITO
   ======================= */

.cart-panel {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

.cart-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.cart-header-summary {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.cart-panel h3 {
  font-size: 1.05rem;
}

#cart-items {
  list-style: none;
  margin: 8px 0 10px;
  padding: 0;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  padding: 6px 0;
  border-bottom: 1px solid #e5e7eb;
  gap: 8px;
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-item-name {
  max-width: 220px;
}

.cart-item-qty-badge {
  background: #e5e7eb;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.cart-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-item-subtotal {
  font-weight: 600;
}

.cart-item button.cart-remove {
  border: none;
  background: transparent;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 0.8rem;
}

.cart-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* =======================
   PRODUCTOS
   ======================= */

.products {
  margin-bottom: 24px;
}

.products-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.products-header h3 {
  font-size: 1.1rem;
}

.products-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* flex para que se mantengan bien incluso con 1 producto */
.products-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.product-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 12px 12px 14px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 230px;
  max-width: 260px;
}

.product-image {
  border-radius: 16px;
  overflow: hidden;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fondos de respaldo para cada categoría si no hay imagen */
.product-image-pharmacy {
  background: linear-gradient(135deg, #f97316, #fde047);
}
.product-image-cleaning {
  background: linear-gradient(135deg, #06b6d4, #a855f7);
}
.product-image-snacks {
  background: linear-gradient(135deg, #f97373, #fbbf24);
}
.product-image-drink {
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
}
.product-image-water {
  background: linear-gradient(135deg, #22c55e, #67e8f9);
}
.product-image-hygiene {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-card h4 {
  font-size: 1.02rem;
  font-weight: 600;
}

.product-tag {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.product-price {
  font-size: 1.02rem;
  font-weight: 650;
  margin-bottom: 4px;
}

/* =======================
   CHECKOUT
   ======================= */

.checkout-panel {
  margin-top: 8px;
  margin-bottom: 24px;
  padding: 16px 18px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  display: none;
}

.checkout-note {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.checkout-list {
  list-style: none;
  margin: 6px 0 8px;
  padding-left: 0;
}

.checkout-list li {
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.checkout-subtotal,
.checkout-delivery {
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.checkout-delivery {
  color: var(--color-text-muted);
}

.checkout-total {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 4px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.form-row label {
  font-size: 0.8rem;
  color: #4b5563;
}

.form-row input,
.form-row textarea,
.form-row select {
  font-size: 0.9rem;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  outline: none;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px rgba(18, 89, 168, 0.35);
}

.checkout-success {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--color-accent);
}

/* =======================
   MODAL PRODUCTO
   ======================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: 18px;
  max-width: 600px;
  width: 90%;
  padding: 18px 20px 20px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 8px;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-main {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.modal-image {
  border-radius: 14px;
  background: #f3f4f6;
  overflow: hidden;
}

.modal-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-tag {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.modal-price {
  font-size: 0.9rem;
  margin-top: 2px;
}

.modal-section {
  margin-top: 10px;
}

.modal-section label {
  font-size: 0.85rem;
  color: #4b5563;
  display: block;
  margin-bottom: 4px;
}

.quantity-selector {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  overflow: hidden;
}

.quantity-selector button {
  border: none;
  background: #e5e7eb;
  padding: 4px 10px;
  font-size: 1.1rem;
  cursor: pointer;
}

.quantity-selector span {
  padding: 4px 12px;
  font-size: 0.95rem;
}

/* Textarea del modal */
#modal-note {
  width: 100%;
  resize: none;
  min-height: 60px;
  max-height: 100px;
  font-size: 0.9rem;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  outline: none;
}

#modal-note:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px rgba(18, 89, 168, 0.35);
}

/* =======================
   PANEL ADMIN
   ======================= */

.admin-panel {
  margin-top: 16px;
  margin-bottom: 24px;
  padding: 16px 18px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  display: none;
}

.admin-panel.open {
  display: block;
}

.admin-note {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.admin-subtitle {
  font-size: 0.9rem;
  margin: 10px 0 6px;
}

.admin-table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.admin-table th,
.admin-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
}

.admin-table th {
  text-align: left;
  background: #f3f4f6;
}

.admin-actions button {
  font-size: 0.78rem;
  padding: 4px 6px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  margin-right: 4px;
}

.admin-actions button[data-action="edit"] {
  background: #e0f2fe;
}

.admin-actions button[data-action="delete"] {
  background: #fee2e2;
}

/* Bloque de código generado por el admin */
.admin-code-block {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  display: none;
}

.admin-code-block.visible {
  display: block;
}

#admin-code-output {
  width: 100%;
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.82rem;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  resize: vertical;
  background: #f9fafb;
  box-sizing: border-box;
}

.admin-code-title {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.admin-code-hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.admin-copy-btn {
  margin-top: 8px;
  background: #111827;
  color: #ffffff;
}

.admin-copy-btn:hover {
  background: #020617;
}

/* =======================
   HELP / AYUDA
   ======================= */

.help-section {
  margin-top: 40px;
  margin-bottom: 32px;
  padding: 24px 28px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

.help-section h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.help-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--color-primary-soft);
}

.help-card h4 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.help-card p {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* =======================
   FOOTER (opcional)
   ======================= */

.footer {
  border-top: 1px solid #e5e7eb;
  padding: 12px 0;
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* =======================
   RESPONSIVE
   ======================= */

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .container {
    padding: 0 12px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 18px 16px;
  }

  .hero-illustration {
    align-items: center;
    text-align: center;
  }

  .cart-panel,
  .checkout-panel,
  .help-section {
    padding: 14px 14px;
    border-radius: 16px;
  }

  .products-grid {
    flex-direction: column;
  }

  .product-card {
    max-width: 100%;
  }

  .modal-main {
    grid-template-columns: 1fr;
  }
}
