/*
 * Siempre Bella v67 — ajustes finales para celular, tableta y escritorio.
 * Esta hoja se carga al final para estabilizar la cascada histórica sin borrar
 * ninguna función ni modificar las hojas de estilo de la entrega v66.
 */

html {
  min-width: 0;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  overflow-x: hidden;
}

@supports (overflow: clip) {
  body { overflow-x: clip; }
}

.topbar,
.brand,
.header-links,
.hero-copy-block,
.catalog,
.catalog-finders,
.catalog-controls,
.card,
.card-content,
.product-information,
.purchase-column,
.manager-card,
.team-user > div,
.video-item > div,
.campaign-item > div {
  min-width: 0;
}

.product-name,
.product-title,
.row-name,
.row-sku,
.team-user,
.team-user-email,
.video-item,
.campaign-item,
.pickup-address {
  overflow-wrap: anywhere;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

/* Cabecera y navegación. */
.topbar {
  isolation: isolate;
  padding-top: env(safe-area-inset-top, 0px);
}

.mobile-menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  place-items: center;
  border: 1px solid #7a3652;
  border-radius: 50%;
  background: #301723;
  color: #fff7fa;
  cursor: pointer;
}

.mobile-menu-toggle span,
.mobile-menu-toggle::before,
.mobile-menu-toggle::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 10px;
  background: currentColor;
  content: "";
  transition: transform .18s ease, opacity .18s ease;
}

.mobile-menu-toggle span { margin: 4px 0; }
.topbar.is-menu-open .mobile-menu-toggle::before { transform: translateY(6px) rotate(45deg); }
.topbar.is-menu-open .mobile-menu-toggle span { opacity: 0; }
.topbar.is-menu-open .mobile-menu-toggle::after { transform: translateY(-6px) rotate(-45deg); }
.light-mode .mobile-menu-toggle { border-color: #e396b6; background: #fff7fa; color: #8f1c4b; }

/* El carrusel conserva una zona separada para texto, imagen y controles. */
.hero {
  min-height: 560px;
}

.hero-controls {
  bottom: 28px;
  left: 10.5%;
}

.hero-arrow,
.theme-toggle,
.favorite-button,
.cart-qty button,
.quantity-picker button,
.dialog-close,
.detail-close {
  min-width: 44px;
  min-height: 44px;
}

/* Los controles del catálogo caben completos y no parecen cortados. */
.catalog-controls > * { min-width: 0; }
.sort-control select { max-width: 100%; }

/* Contraste real en modo oscuro para la dirección y las acciones de compra. */
body:not(.light-mode) .pickup-card h2,
body:not(.light-mode) .pickup-address,
body:not(.light-mode) .pickup-box h3,
body:not(.light-mode) .pickup-box .pickup-address {
  color: #fff7fa;
}

body:not(.light-mode) .quantity-picker span,
body:not(.light-mode) .sale-price-row span {
  color: #ddb7c6;
}

body:not(.light-mode) .product-topbar .cart-link,
body:not(.light-mode) .admin-topbar .cart-link {
  color: #fff7fa;
}

body:not(.light-mode) .product-topbar .cart-link img,
body:not(.light-mode) .admin-topbar .cart-link img {
  filter: brightness(0) invert(1);
}

/* Diálogos y puertas de entrada siempre desplazables, incluso con teclado. */
.detail-dialog,
.product-dialog,
.confirm-dialog {
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.cookie-gate,
.signin-gate {
  box-sizing: border-box;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  padding-left: max(14px, env(safe-area-inset-left, 0px));
}

.entry-gate-card,
.cookie-gate .cookie-gate-card {
  max-width: 100%;
}

#google-button {
  width: 100%;
  min-height: 44px;
  overflow: hidden;
}

#google-button > div,
#google-button iframe {
  max-width: 100% !important;
}

.floating-whatsapp {
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

/* Las imágenes de cosméticos se muestran completas. */
.detail-image img,
.main-product-image img,
.image-thumbnail img {
  object-fit: contain;
  object-position: center;
}

.image-thumbnail.is-image-error { display: none; }

/* Formularios de administración: las columnas nunca fuerzan el ancho. */
.users-card { display: block; }
.users-card .user-form {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  margin-top: 18px;
}
.google-settings label,
.user-form label,
.store-form label,
.google-settings input,
.user-form input,
.user-form select,
.store-form input {
  min-width: 0;
  width: 100%;
}

@media (max-width: 1100px) {
  .users-card .user-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .users-card .user-form .primary-admin-button { width: 100%; }
}

@media (max-width: 900px) {
  .hero { max-width: calc(100% - 30px); }
  .beauty-video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar {
    min-height: calc(68px + env(safe-area-inset-top, 0px));
    height: auto;
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px));
  }

  .topbar.has-mobile-menu .mobile-menu-toggle { display: grid; }

  .topbar.has-mobile-menu .header-links {
    position: absolute;
    z-index: 120;
    top: calc(100% + 8px);
    right: max(12px, env(safe-area-inset-right, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    display: none;
    max-height: calc(100dvh - 92px);
    margin: 0;
    padding: 12px;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    border: 1px solid #6f304b;
    border-radius: 17px;
    background: rgba(27, 13, 20, .98);
    box-shadow: 0 20px 55px rgba(0, 0, 0, .45);
    backdrop-filter: blur(18px);
  }

  .topbar.has-mobile-menu.is-menu-open .header-links { display: flex; }

  .topbar.has-mobile-menu .header-links > * {
    display: flex !important;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: flex-start;
    padding: 0 14px;
    border: 1px solid #593044;
    border-radius: 11px;
    background: #2b1621;
    color: #fff7fa;
    font-size: 13px;
  }

  .topbar.has-mobile-menu .header-links .cart-link img { filter: brightness(0) invert(1); }
  .topbar.has-mobile-menu .header-links .theme-toggle { border-radius: 11px; }
  .topbar.has-mobile-menu .header-links .theme-toggle-text { display: inline; margin-left: 9px; }

  .light-mode .topbar.has-mobile-menu .header-links {
    border-color: #ebafc5;
    background: rgba(255, 249, 251, .98);
    box-shadow: 0 20px 55px rgba(91, 30, 56, .2);
  }
  .light-mode .topbar.has-mobile-menu .header-links > * {
    border-color: #efd2dd;
    background: #fff;
    color: #20171b;
  }
  .light-mode .topbar.has-mobile-menu .header-links .cart-link img { filter: none; }

  .product-topbar .header-whatsapp,
  .admin-topbar .header-whatsapp {
    display: grid !important;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    padding: 0;
    place-items: center;
    border: 1px solid #7a3652;
    border-radius: 50%;
    font-size: 0;
  }
  .product-topbar .header-whatsapp::before,
  .admin-topbar .header-whatsapp::before { content: "←"; font-size: 20px; }

  .hero {
    min-height: clamp(690px, 112vw, 770px);
    max-width: none;
    margin-right: 10px;
    margin-left: 10px;
  }

  .hero-slide,
  .hero-slide.hero-card-left {
    align-items: flex-start;
    padding: 42px 22px 300px;
    visibility: hidden;
    transform: none;
    transition: opacity .22s ease;
  }

  .hero-slide.is-active,
  .hero-slide.hero-card-left.is-active { visibility: visible; }

  .hero-slide .hero-copy-block,
  .hero-slide.hero-card-left .hero-copy-block {
    width: 100%;
    max-width: 520px;
    margin-left: 0;
  }

  .hero-brand-art {
    top: auto;
    right: 50%;
    bottom: 82px;
    width: min(84%, 470px);
    transform: translateX(50%);
  }

  .hero-message-card,
  .hero-slide.hero-card-left .hero-message-card {
    top: auto;
    right: auto;
    bottom: 82px;
    left: 50%;
    width: min(80%, 390px);
    height: 205px;
    transform: translateX(-50%);
  }

  .hero-controls {
    right: auto;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
  }

  .hero-arrow { width: 44px; height: 44px; }

  .catalog-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    gap: 8px;
    margin-right: 0;
    padding-right: 0;
    overflow: visible;
  }
  .catalog-controls .sort-control {
    grid-column: 1 / -1;
    width: 100%;
  }
  .catalog-controls .sort-control select { flex: 1; min-width: 0; }
  .catalog-controls .catalog-tool { width: 100%; padding-right: 8px; padding-left: 8px; }

  .categories {
    position: relative;
    padding-bottom: 18px;
  }

  .detail-dialog,
  .product-dialog,
  .confirm-dialog {
    width: calc(100% - 12px);
    max-height: calc(100dvh - 12px);
    margin: auto;
    border-radius: 16px;
  }

  .dialog-actions {
    position: sticky;
    z-index: 4;
    bottom: -18px;
    padding: 12px 0 max(2px, env(safe-area-inset-bottom, 0px));
    background: inherit;
  }

  .auth-card {
    width: 100%;
    max-width: 520px;
    margin: 24px auto;
    padding: 28px 24px;
  }

  .users-card .user-form { grid-template-columns: 1fr; }
  .users-card .user-form .primary-admin-button { width: 100%; }

  .team-user-actions { width: 100%; }
  .team-user-actions button { min-height: 44px; }

  .beauty-video-actions button {
    min-width: 44px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 520px) {
  .brand strong { font-size: 14px; }
  .brand small { font-size: 7px; letter-spacing: 1.3px; }

  .hero {
    min-height: 700px;
    margin-right: 0;
    margin-left: 0;
  }
  .hero-slide,
  .hero-slide.hero-card-left { padding: 36px 18px 292px; }
  .hero h1 { font-size: clamp(39px, 11.8vw, 49px); }
  .hero-copy { font-size: 14px; }
  .hero-brand-art { bottom: 82px; width: 88%; }
  .hero-message-card,
  .hero-slide.hero-card-left .hero-message-card { bottom: 82px; width: 86%; }

  .beauty-video-grid { grid-template-columns: 1fr; gap: 16px; }
  .beauty-video-stage { aspect-ratio: 4 / 5; }
  .beauty-video-card.is-landscape .beauty-video-stage { aspect-ratio: 16 / 10; }
  .beauty-video-card.is-landscape .beauty-video-stage video { object-fit: contain; background: #090608; }
  .beauty-video-copy h3 { min-height: 0; font-size: 14px; }
  .beauty-product-action { line-height: 1.35; }

  .cookie-gate .cookie-gate-card,
  .entry-gate-card { padding: 24px 18px; border-radius: 19px; }
  .cookie-gate-copy h2,
  .entry-gate-card h2 { font-size: clamp(29px, 9vw, 37px); }

  .auth-card { padding: 24px 18px; border-radius: 19px; }

  .product-page,
  .cart-page,
  .policies-page,
  .admin-shell { padding-right: 12px; padding-left: 12px; }

  .main-product-image { min-height: 0; }
  .image-thumbnails {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }
  .image-thumbnail { flex: 0 0 72px; scroll-snap-align: start; }
}

@media (max-width: 360px) {
  .brand span { display: none; }
  .hero { min-height: 690px; }
  .products-grid { grid-template-columns: 1fr; gap: 14px; }
  .product-image { height: 260px; }
  .catalog-controls { grid-template-columns: 1fr; }
  .catalog-controls .sort-control { grid-column: auto; }
}

@media (max-height: 620px) and (max-width: 900px) {
  .cookie-gate,
  .signin-gate { align-items: start; }
  .entry-gate-card,
  .cookie-gate .cookie-gate-card { margin: auto 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-menu-toggle span,
  .mobile-menu-toggle::before,
  .mobile-menu-toggle::after { transition: none; }
}
