/* ============================================================
   Rafaels Produce Inc. — Hoja de estilos
   ------------------------------------------------------------
   El diseño de ESCRITORIO se conserva EXACTAMENTE igual al
   original (mismos colores, tamaños, tipografías y layout).
   Solo se limpió CSS muerto/duplicado y se añadieron mejoras
   de accesibilidad táctil en móvil (sin alterar el escritorio).
   ============================================================ */

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; } /* evita reescalado de fuente en iOS */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: white;
  color: #111;
}
img { max-width: 100%; } /* seguridad anti-desbordes, no afecta imágenes con tamaño fijo */

/* ---------- Layout principal (3 columnas) ---------- */
.app {
  display: grid;
  grid-template-columns: 245px 1fr 290px;
  min-height: 100vh;
}

/* ---------- Barra lateral ---------- */
.sidebar {
  background: linear-gradient(180deg, #052a18, #00391d);
  color: white;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 14px; align-items: center; }
.logoLarge {
  width: 74px; height: 74px;
  border-radius: 16px;
  object-fit: cover;
  flex-shrink: 0;
}
.brandText {
  font-size: 25px; font-weight: 900; line-height: 1.0;
  max-width: 130px; word-break: break-word;
}
.brandText span {
  display: block; color: #8bd64d; font-size: 20px; margin-top: 8px;
}
.tag { font-size: 11px; font-weight: 800; margin: 18px 0 24px; }
.navBtn, .navItem {
  border-radius: 10px; padding: 12px; margin: 8px 0;
  font-weight: 700; cursor: pointer;
}
.navBtn { background: #12862f; }
.navItem:hover, .navBtn:hover { filter: brightness(1.08); } /* realce sutil, sin cambiar color base */
.navTitle { color: #92c782; font-size: 13px; margin: 22px 0 8px; }
.whats {
  position: absolute; bottom: 22px; left: 14px; right: 14px;
  background: #107d31; border-radius: 12px; padding: 14px;
}
.callBtn { /* botón "Llamar", antes con estilos en línea */
  display: block; text-align: center; margin-top: 10px; padding: 12px;
  border-radius: 10px; border: 1px solid #087b24; color: #087b24;
  font-weight: 800; text-decoration: none;
}

/* ---------- Zona central ---------- */
.main { padding: 18px 24px; }
.topbar { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 14px; }
.search {
  border: 1px solid #d6dde5; border-radius: 10px;
  padding: 13px 16px; font-size: 15px; background: white;
}
.info {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border: 1px solid #e2e8ee; border-radius: 12px;
  overflow: hidden; margin-bottom: 20px;
}
.info div { padding: 13px; border-right: 1px solid #e2e8ee; font-size: 13px; }
.info b { display: block; color: #08722b; }
.head { display: flex; justify-content: space-between; align-items: center; }
.head h1 { font-size: 27px; margin: 0 0 16px; }
.count { color: #08722b; font-size: 14px; }
.sectionTitle {
  color: #08722b; font-weight: 900; margin: 12px 0 9px; text-transform: uppercase;
}

/* ---------- Catálogo / tarjetas ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.card {
  border: 1px solid #dde5eb; border-radius: 10px;
  overflow: hidden; background: white; box-shadow: 0 3px 8px #0001;
}
.photo { height: 132px; background: #f4f8f3; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.body { padding: 10px; }
.name { font-weight: 900; font-size: 14px; margin-bottom: 5px; }
.pack { font-size: 12px; margin-bottom: 8px; color: #333; min-height: 28px; }
.price { font-weight: 900; font-size: 14px; margin-bottom: 8px; }
.price span { font-weight: 500; }
.add {
  width: 100%; border: 0; background: #087b24; color: white;
  border-radius: 6px; padding: 8px; font-size: 12px; font-weight: 800;
  cursor: pointer;
}

/* ---------- Carrito ---------- */
.cart {
  border-left: 1px solid #e5e9ee; background: #fafafa;
  padding: 18px 16px; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.cartTitle {
  display: flex; justify-content: space-between;
  font-size: 22px; font-weight: 900; margin-bottom: 16px;
}
.cartCount {
  background: #0b8a2d; color: white; border-radius: 50%;
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center; font-size: 14px;
}
.cartItem {
  display: grid; grid-template-columns: 60px 1fr 20px; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid #e4e4e4;
}
.thumb { width: 60px; height: 60px; border-radius: 8px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.ciName { font-weight: 900; font-size: 14px; }
.ciPack { font-size: 12px; color: #666; }
.qty { display: flex; gap: 8px; align-items: center; margin-top: 7px; }
.qty button {
  border: 1px solid #d5dce2; background: #fff; border-radius: 6px;
  width: 26px; height: 24px; font-weight: 900; cursor: pointer;
}
.removeBtn { cursor: pointer; background: none; border: 0; font-size: 16px; padding: 0; }
.line { display: flex; justify-content: space-between; margin: 10px 0; }
.total { font-size: 18px; font-weight: 900; color: #087b24; }
.send {
  display: block; text-align: center; text-decoration: none; color: white;
  background: #09862c; border-radius: 9px; padding: 14px; margin: 12px 0;
  font-weight: 900;
}
.sms { background: white; color: #111; border: 1px solid #087b24; }

/* ---------- Franja de "características" ---------- */
.features {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin: 30px 0 10px;
}
.feature {
  border: 1px solid #e1e7ed; border-radius: 10px;
  padding: 15px; text-align: center; font-size: 13px;
}

/* ============================================================
   RESPONSIVE
   Se conserva el comportamiento original (breakpoints 1100 y
   560px) y se añaden SOLO mejoras táctiles/espaciado en móvil.
   ============================================================ */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar, .cart { position: relative; height: auto; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .info, .features { grid-template-columns: 1fr 1fr; }
  .whats {
    position: relative; left: auto; right: auto; bottom: auto; margin-top: 20px;
  }
  .cart { border-left: 0; border-top: 1px solid #e5e9ee; } /* separador natural al apilar */
}

@media (max-width: 560px) {
  /* Móvil: se muestran DOS productos por fila (varios a la vez, sin scroll
     interminable), manteniendo el mismo estilo de tarjeta. */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .topbar, .info { grid-template-columns: 1fr; }
  .info div { border-right: 0; border-bottom: 1px solid #e2e8ee; } /* evita borde suelto al apilar */
  .info div:last-child { border-bottom: 0; }
}

/* Mejoras de área táctil SOLO en dispositivos táctiles/estrechos.
   No cambian el aspecto en escritorio. */
@media (hover: none), (max-width: 768px) {
  .add { min-height: 44px; }              /* objetivo táctil cómodo */
  .qty button { width: 36px; height: 36px; font-size: 16px; } /* +/- más fáciles de pulsar */
  .removeBtn { padding: 6px; }
  .navBtn, .navItem { padding: 14px 12px; } /* navegación más cómoda al tacto */
  .send { padding: 16px; }
  a, button { -webkit-tap-highlight-color: rgba(8,123,36,.15); }
}

/* ============================================================
   CARRITO FLOTANTE (solo móvil)
   Botón fijo en la esquina inferior derecha, siempre a la vista.
   Muestra la cantidad de productos y al pulsarlo lleva al pedido
   para finalizar. En escritorio NO aparece (el carrito ya está
   siempre visible a la derecha).
   ============================================================ */
.cart-fab { display: none; } /* oculto en escritorio */

@media (max-width: 1100px) {
  .cart-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 45;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #09862c;
    color: #fff;
    text-decoration: none;
    font-size: 26px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  }
  .cart-fab:active { transform: scale(0.94); }
  .cart-fab .fab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    background: #e02424;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  .cart-fab .fab-badge.hidden { display: none; }
  /* Espacio para que el botón flotante no tape el final del pedido. */
  .cart { padding-bottom: 88px; }
}

/* ============================================================
   ENVÍO POR CORREO (3ª opción) + MINI-MODAL
   Solo AGREGA: el botón comparte el estilo de WhatsApp/SMS y el
   modal permanece oculto por defecto (no altera el diseño).
   ============================================================ */

/* El botón "Enviar por Correo" usa la misma base .send que los otros.
   Como es un <button>, normalizamos ancho, fuente y cursor para que
   se vea idéntico a los enlaces WhatsApp/SMS. */
button.send.email {
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
/* Variante visual: blanco con borde verde (como SMS), diferenciable. */
.send.email { background: #fff; color: #087b24; border: 1px solid #087b24; }
.send.email:hover { filter: brightness(1.03); }

/* Bloqueo de scroll de fondo cuando el modal está abierto. */
body.email-modal-open { overflow: hidden; }

/* Contenedor del modal (oculto vía atributo [hidden]). */
.email-modal[hidden] { display: none; }
.email-modal {
  position: fixed;
  inset: 0;
  z-index: 120;               /* por encima del carrito flotante (45) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.email-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 26, 15, .55);
}
.email-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 22px 20px 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .32);
}
.email-modal__x {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
}
.email-modal__x:hover { color: #111; }
.email-modal__title {
  font-size: 19px;
  font-weight: 900;
  margin: 0 26px 4px 0;
  color: #052a18;
}
.email-modal__sub {
  font-size: 13px;
  color: #555;
  margin: 0 0 16px;
}

/* Campos del formulario. */
.email-field { display: block; margin-bottom: 12px; }
.email-field > span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
  color: #08722b;
}
.email-field input {
  width: 100%;
  border: 1px solid #d6dde5;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
}
.email-field input:focus {
  outline: none;
  border-color: #087b24;
  box-shadow: 0 0 0 3px rgba(8, 123, 36, .15);
}

/* Vista previa del pedido dentro del modal. */
.email-preview {
  border: 1px solid #e2e8ee;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0 12px;
  background: #fafafa;
  max-height: 180px;
  overflow: auto;
}
.email-preview__title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: #08722b;
  margin-bottom: 6px;
}
.email-preview-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.email-preview-table td { padding: 5px 0; border-bottom: 1px solid #ececec; vertical-align: top; }
.email-preview-table td.qty { text-align: center; color: #555; width: 44px; white-space: nowrap; }
.email-preview-table td.sub { text-align: right; font-weight: 700; white-space: nowrap; }
.email-preview-table tfoot td {
  border-bottom: 0;
  border-top: 2px solid #d5dce2;
  padding-top: 8px;
  font-weight: 900;
  color: #087b24;
  font-size: 15px;
}
.email-empty { font-size: 13px; color: #666; margin: 4px 0; }

/* Mensajes de estado (éxito / error). */
.email-msg { font-size: 13px; margin: 0 0 12px; min-height: 0; }
.email-msg.is-error { color: #b3261e; }
.email-msg.is-success { color: #0b7a2c; font-weight: 700; }

/* Botón de envío del modal. */
.email-send {
  display: block;
  width: 100%;
  border: 0;
  background: #09862c;
  color: #fff;
  border-radius: 9px;
  padding: 14px;
  font-size: 15px;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
}
.email-send:hover { filter: brightness(1.05); }
.email-send:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 560px) {
  .email-modal__dialog { padding: 20px 16px 16px; }
}
