/* ==========================================================================
   PRODUCTION POLISH
   Capa final de coherencia visual, responsive, accesibilidad y ecommerce.
   ========================================================================== */

:root {
  --site-max: 1280px;
  --site-gutter: 24px;
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 36px;
  --card-radius: 10px;
  --control-radius: 8px;
  --focus-ring: 0 0 0 3px rgba(255, 107, 0, 0.2);
  --shadow-card: 0 10px 26px rgba(58, 18, 7, 0.08);
  --shadow-card-hover: 0 18px 40px rgba(58, 18, 7, 0.14);
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  min-width: 320px;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
}

main {
  min-width: 0;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

img {
  background: #fff4ea;
}

a,
button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
.btn,
.btn-primary,
.btn-secondary,
.btn-action,
.btn-add-to-cart,
.btn-cotizar,
.btn-ver-producto,
.btn-cta,
.cta-button,
.hero-link,
.product-cta,
input[type="submit"] {
  min-height: 44px;
  border-radius: var(--control-radius) !important;
  font-weight: 800;
  letter-spacing: 0;
  touch-action: manipulation;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-link {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px !important;
  text-decoration: none;
}

.hero-link.primary {
  background: var(--naranja-cta, #ff6b00);
  color: #fff;
}

.hero-link.secondary {
  background: #fff;
  color: var(--primary, #6b1b00);
  border: 1px solid rgba(107, 27, 0, 0.16);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none !important;
  box-shadow: var(--focus-ring) !important;
}

input,
select,
textarea {
  min-height: 44px;
  border-radius: var(--control-radius);
  font-size: 1rem;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* Header y navegación */
.top-bar,
.main-header,
.main-nav {
  backface-visibility: hidden;
}

.main-header {
  border-bottom: 1px solid rgba(107, 27, 0, 0.08);
}

.main-nav {
  border-bottom: 2px solid var(--naranja-cta, #ff6b00);
}

.nav-menu {
  justify-content: center;
}

.nav-link {
  min-height: 40px;
  font-weight: 750;
}

.nav-split-item {
  display: inline-flex;
  align-items: center;
}

.nav-split-item > .nav-link {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.nav-split-item.has-mega > .nav-link::after {
  display: none;
}

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  height: 40px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-dropdown-trigger:hover,
.nav-dropdown-trigger:focus-visible,
.nav-item.has-mega.is-open > .nav-dropdown-trigger {
  background: rgba(255, 255, 255, 0.18);
  color: var(--accent, #ff6b00);
  outline: none;
}

.nav-item.has-mega.is-open > .mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.compact-mega {
  width: min(880px, 92vw) !important;
  min-width: min(860px, 92vw) !important;
  max-width: min(880px, 92vw) !important;
  padding: 18px !important;
}

.compact-mega .mega-menu-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mega-category-card {
  border: 1px solid rgba(107, 27, 0, 0.1) !important;
  border-radius: 12px;
  padding: 14px !important;
  background: #fff;
  min-height: 160px;
  display: flex;
  flex-direction: column;
}

.mega-category-card h4 {
  margin-bottom: 8px !important;
}

.mega-category-card p {
  margin: 0 0 14px;
  color: #5f5049;
  font-size: 0.82rem;
  line-height: 1.45;
}

.mega-category-featured {
  background: linear-gradient(135deg, #fff7f0, #fff) !important;
}

.mega-menu-cta {
  margin-top: auto;
  font-weight: 800;
  color: var(--primary, #6b1b00) !important;
}

.nav-item.has-dropdown > .nav-link::after,
.nav-item.has-mega > .nav-link::after {
  content: "\f107";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.72rem;
  margin-left: 2px;
  opacity: 0.85;
}

.nav-item.has-dropdown:hover > .nav-link::after,
.nav-item.has-mega:hover > .nav-link::after {
  transform: translateY(1px);
}

.dropdown-menu,
.mega-menu,
.search-results {
  border-radius: 10px !important;
}

.dropdown-item,
.mega-menu-link,
.mobile-dropdown-item {
  min-height: 44px;
}

.mobile-nav-item.has-dropdown {
  position: relative;
}

.mobile-nav-link-primary {
  padding-right: 56px !important;
}

.mobile-dropdown-trigger {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: #f5ede8;
  color: var(--primary, #6b1b00);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.mobile-dropdown-trigger:hover,
.mobile-dropdown-trigger:focus-visible {
  background: #ffe3d0;
  outline: 2px solid rgba(255, 107, 0, 0.24);
  outline-offset: 2px;
}

.mobile-nav-item.active > .mobile-dropdown-trigger {
  transform: rotate(180deg);
  background: #ffe3d0;
}

.mobile-dropdown-all {
  background: #fff7f0;
  color: var(--primary, #6b1b00) !important;
  font-weight: 800;
}

.search-input {
  font-size: 0.95rem;
}

.search-result-title {
  font-weight: 800;
}

.top-bar .top-bar-item,
.top-bar .social-link {
  min-height: 32px;
}

.top-bar .social-link {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px;
}

.breadcrumb a,
.breadcrumbs a,
.product-breadcrumb a,
.row-link,
.info-card a,
.view-map-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

/* Secciones y contenedores */
.index-main section,
.products-content > section,
.events-main section,
.blog-main section,
.galeria-main section,
.personalizar-section,
.contact-section {
  min-width: 0;
}

.section-header,
.section-header.compact,
.products-hero,
.events-hero,
.blog-hero,
.page-hero {
  text-wrap: balance;
}

.section-header h2,
.products-hero h1,
.events-hero h1,
.blog-hero h1,
.personalizar-header h1 {
  letter-spacing: 0;
}

.section-description,
.hero-description,
.product-description,
.event-description,
.blog-excerpt {
  color: var(--muted, #6f5d55);
}

/* Grids comerciales */
.home-product-grid,
.products-grid,
.catalog-section-grid,
.events-grid,
.eventos-grid,
.blog-grid,
.gallery-grid,
#step2 .productos-grid,
#step2 .paquetes-rapidos {
  align-items: stretch;
}

.home-product-card,
.product-card,
.event-card,
.blog-card,
.gallery-item,
.home-category-card,
.search-product-card .card-inner,
#step2 .producto-card,
#step2 .paquete-card,
.sidebar-card,
.help-card,
.contact-form,
.form-step {
  border-radius: var(--card-radius) !important;
  border: 1px solid rgba(107, 27, 0, 0.14) !important;
  box-shadow: var(--shadow-card) !important;
}

.home-product-card,
.product-card,
.event-card,
.blog-card,
#step2 .producto-card,
#step2 .paquete-card {
  min-width: 0;
  overflow: hidden;
  background: #fff;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.home-product-card:hover,
.product-card:hover,
.event-card:hover,
.blog-card:hover,
#step2 .producto-card:hover,
#step2 .paquete-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 107, 0, 0.42) !important;
  box-shadow: var(--shadow-card-hover) !important;
}

.home-product-card img,
.product-image-wrapper img,
.event-image-wrapper img,
.blog-card img,
.card-image img,
.gallery-image img,
.main-product-image img,
.product-main-image img {
  width: 100%;
  object-fit: cover;
  object-position: center;
}

.product-image-wrapper,
.event-image-wrapper,
.blog-image,
.card-image,
.gallery-image {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #fff4ea;
}

.product-image-wrapper img,
.event-image-wrapper img,
.blog-image img,
.card-image img,
.gallery-image img {
  height: 100% !important;
}

.product-title,
.event-title,
.blog-card h3,
.home-product-card strong {
  color: var(--text, #221a16);
  line-height: 1.18;
  text-wrap: balance;
}

.product-price,
.event-price,
.home-product-price,
.price-final,
.precio-actual {
  color: var(--naranja-cta, #ff6b00) !important;
  font-weight: 900;
}

.product-footer,
.event-footer,
.card-actions,
.blog-actions {
  margin-top: auto;
}

.product-badge,
.event-badge,
.home-product-tag,
.promo-badge,
.status-badge,
.discount-badge {
  border-radius: 999px !important;
  font-weight: 900;
  letter-spacing: 0;
}

/* Productos: sidebar y filtros */
.products-layout {
  background: linear-gradient(180deg, #fff8f1 0%, #fffaf6 40%, #fff8f1 100%);
}

.products-sidebar {
  border-right-color: rgba(107, 27, 0, 0.12);
}

.filter-chip,
.category-filter,
.search-product-card .card-inner {
  cursor: pointer;
}

/* Personalizador */
.personalizar-section {
  max-width: 980px;
}

.form-step {
  background: rgba(255, 255, 255, 0.96);
}

#step2 .paquetes-rapidos,
#step2 .productos-grid {
  gap: var(--space-md);
}

#step2 .paquete-card,
#step2 .producto-card {
  cursor: pointer;
}

#step2 .producto-card input,
#step2 .paquete-card input {
  accent-color: var(--naranja-cta, #ff6b00);
}

/* Carrito, checkout y modales */
.cart-modal,
.product-config-modal,
.event-summary-modal {
  z-index: 10000;
}

.cart-modal-content,
.config-modal-content,
.event-summary-content {
  width: min(94vw, 760px) !important;
  max-height: min(92vh, 860px) !important;
  border-radius: 12px !important;
  border: 1px solid rgba(107, 27, 0, 0.14);
  box-shadow: 0 24px 70px rgba(34, 26, 22, 0.25) !important;
}

.config-modal-body,
.cart-modal-body,
.event-summary-body {
  scrollbar-width: thin;
}

.bank-card,
.payment-method,
.checkout-section {
  border-radius: var(--card-radius) !important;
}

/* Toast global */
.algodon-toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 11000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.algodon-toast {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: #221a16;
  background: #fff;
  border: 1px solid rgba(107, 27, 0, 0.16);
  border-left: 4px solid var(--naranja-cta, #ff6b00);
  border-radius: 10px;
  box-shadow: 0 16px 38px rgba(58, 18, 7, 0.18);
  pointer-events: auto;
  animation: toastIn 180ms ease both;
}

.algodon-toast[data-type="success"] {
  border-left-color: var(--verde-ok, #16a34a);
}

.algodon-toast[data-type="error"] {
  border-left-color: var(--rojo-promo, #e0311f);
}

.algodon-toast-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--naranja-cta, #ff6b00);
  border-radius: 8px;
}

.algodon-toast[data-type="success"] .algodon-toast-icon {
  background: var(--verde-ok, #16a34a);
}

.algodon-toast[data-type="error"] .algodon-toast-icon {
  background: var(--rojo-promo, #e0311f);
}

.algodon-toast-message {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.35;
  font-weight: 700;
}

.algodon-toast-close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6f5d55;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

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

/* Responsive real */
@media (min-width: 1400px) {
  :root {
    --site-gutter: 32px;
  }

  .home-product-grid,
  .products-grid,
  .catalog-section-grid {
    gap: 22px;
  }
}

@media (max-width: 1024px) {
  .products-layout {
    display: block;
  }

  .products-sidebar {
    position: static !important;
    width: auto !important;
    max-height: none !important;
    border-right: 0;
    border-bottom: 1px solid rgba(107, 27, 0, 0.12);
  }

  .products-content {
    padding: 18px;
  }

  .nav-menu {
    justify-content: flex-start;
  }

  .compact-mega .mega-menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  body {
    padding-top: calc(var(--topbar-height, 28px) + var(--header-height, 52px) + var(--nav-height, 40px));
  }

  .products-content,
  .home-recommended-section,
  .personalizar-section {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

@media (max-width: 576px) {
  :root {
    --topbar-height: 32px;
    --header-height: 96px;
    --nav-height: 40px;
  }

  body {
    padding-top: calc(var(--topbar-height, 32px) + var(--header-height, 96px) + var(--nav-height, 40px));
  }

  .main-header-container {
    min-height: var(--header-height);
  }

  .main-nav {
    display: block !important;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .main-nav::-webkit-scrollbar {
    display: none;
  }

  .main-nav-container {
    padding: 0 8px !important;
  }

  .nav-menu {
    width: max-content;
    min-width: 100%;
    justify-content: flex-start !important;
    gap: 4px !important;
  }

  .nav-item,
  .nav-item.has-dropdown {
    display: block !important;
    flex: 0 0 auto;
  }

  .nav-link {
    min-height: var(--nav-height, 40px);
    padding: 0 10px !important;
    font-size: 0.74rem !important;
    border-radius: 8px !important;
  }

  .nav-link i {
    font-size: 0.78rem !important;
  }

  .nav-dropdown-trigger,
  .nav-item.has-mega > .nav-link::after {
    display: none !important;
  }

  .mega-menu {
    display: none !important;
  }

  .nav-item.services-dropdown.is-open .dropdown-menu,
  .nav-item.has-dropdown.is-open .dropdown-menu {
    display: block !important;
    position: fixed !important;
    top: calc(var(--topbar-height, 32px) + var(--header-height, 96px) + var(--nav-height, 40px) + 8px) !important;
    left: 10px !important;
    right: 10px !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: min(58vh, 360px);
    overflow: auto;
    transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 1100;
  }

  .dropdown-menu::before,
  .dropdown-menu::after {
    display: none !important;
  }

  .header-search {
    margin-top: 2px;
  }

  .top-bar .social-link {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
  }

  .top-bar .top-bar-item {
    min-height: 32px;
  }

  .search-results {
    position: fixed;
    top: calc(var(--topbar-height, 32px) + var(--header-height, 96px));
    left: 10px;
    right: 10px;
    max-height: min(62vh, 420px);
  }

  .home-product-grid,
  .products-grid,
  .catalog-section-grid,
  .events-grid,
  .eventos-grid,
  .blog-grid,
  .gallery-grid,
  #step2 .productos-grid,
  #step2 .paquetes-rapidos {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .home-product-card,
  .product-card,
  .event-card,
  .blog-card,
  .gallery-item,
  #step2 .producto-card,
  #step2 .paquete-card {
    padding: 10px !important;
  }

  .home-product-card img,
  .product-image-wrapper,
  .event-image-wrapper,
  .blog-image,
  .card-image,
  .gallery-image {
    aspect-ratio: 1.12 / 1;
  }

  .home-product-card img {
    height: auto !important;
  }

  .product-title,
  .event-title,
  .blog-card h3,
  .home-product-card strong {
    font-size: 0.88rem !important;
  }

  .product-description,
  .event-description,
  .blog-excerpt,
  .home-product-card small {
    font-size: 0.76rem !important;
    line-height: 1.35 !important;
  }

  .product-price,
  .event-price,
  .home-product-price {
    font-size: 0.9rem !important;
  }

  .btn-add-to-cart,
  .btn-cotizar,
  .btn-ver-producto,
  .btn-add-event,
  .btn-action {
    width: 100%;
    min-height: 42px;
    padding: 8px !important;
    font-size: 0.78rem !important;
  }

  .cart-modal-content,
  .config-modal-content,
  .event-summary-content {
    width: calc(100vw - 18px) !important;
  }

  .algodon-toast-wrap {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }

  .contact-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 18px !important;
  }

  .contact-form-section,
  .contact-info-section,
  .contact-form,
  .section-header,
  .header-text,
  .form-row,
  .form-group {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .header-text p,
  .contact-form label,
  .info-card p,
  .info-card a,
  .info-content,
  .info-content h3 {
    overflow-wrap: anywhere;
  }

  .info-card {
    min-width: 0 !important;
    max-width: 100% !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
  }

  .blog-hero .hero-actions {
    margin-top: 14px;
  }

  .blog-hero .hero-link {
    flex: 1 1 130px;
  }

  .trust-slider-track {
    overflow-x: auto;
  }

  .trust-slider-item {
    flex: 0 0 100% !important;
    justify-content: center;
    white-space: normal !important;
    text-align: center;
  }

  .recommended-grid {
    display: grid !important;
    grid-auto-flow: row !important;
    grid-auto-columns: initial !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    overflow: visible !important;
    gap: 10px !important;
  }

  .recommended-grid .recommended-item {
    min-width: 0;
  }
}

@media (max-width: 380px) {
  :root {
    --topbar-height: 32px;
    --header-height: 92px;
    --nav-height: 38px;
  }

  body {
    padding-top: calc(var(--topbar-height, 32px) + var(--header-height, 92px) + var(--nav-height, 38px));
  }

  .main-nav {
    display: block !important;
  }

  .nav-link {
    min-height: var(--nav-height, 38px);
    padding: 0 8px !important;
    font-size: 0.69rem !important;
  }

  .home-product-card,
  .product-card,
  .event-card,
  .blog-card,
  #step2 .producto-card,
  #step2 .paquete-card {
    padding: 8px !important;
  }

  .product-title,
  .event-title,
  .blog-card h3,
  .home-product-card strong {
    font-size: 0.82rem !important;
  }

  .product-description,
  .event-description,
  .blog-excerpt,
  .home-product-card small {
    font-size: 0.7rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-product-card,
  .product-card,
  .event-card,
  .blog-card,
  .algodon-toast {
    animation: none !important;
    transition: none !important;
  }
}
