﻿/* /pages/tienda/tienda.css */
/* =========================
   TIENDA DASUR — MODERNA
   ========================= */

:root{
  --ds-card: #fff;
  --ds-border: var(--ds-gray-100);
  --ds-shadow: var(--shadow);
  --ds-ring: rgba(30, 64, 175, .18);
}

.ds-shop{ padding: 18px 0 40px; }
.ds-shop__wrap{ display:grid; grid-template-columns: 1fr; gap: 18px; }

.ds-shop__sidebar{
  border: 1px solid var(--ds-border);
  border-radius: calc(var(--radius) + 6px);
  background: var(--ds-card);
  box-shadow: var(--ds-shadow);
  padding: 14px;
  position: relative;
}

.ds-side__top{ display:grid; gap: 10px; }

.ds-side__title{
  display:flex; align-items:center; justify-content:space-between;
}
.ds-side__title h2{ margin: 0; font-size: 1.05rem; }

.ds-link{
  background: transparent; border: 0; padding: 6px 8px;
  color: var(--ds-blue-900); font-weight: 700; cursor:pointer;
  border-radius: 10px;
}
.ds-link:hover{ background: rgba(0,0,0,.04); }

.ds-search input{
  width:100%;
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  padding: .65rem .75rem;
  outline: none;
}
.ds-search input:focus{
  border-color: rgba(30,64,175,.35);
  box-shadow: 0 0 0 6px var(--ds-ring);
}

.ds-chips{ display:flex; flex-wrap:wrap; gap:8px; }
.ds-chip{
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid var(--ds-border);
  background:#fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight:700;
}
.ds-chip button{
  border:0; background:transparent; cursor:pointer; font-weight:900;
  opacity:.65;
}
.ds-chip button:hover{ opacity:1; }

/* CONTENT */
.ds-shop__content{ min-width:0; }
.ds-shop__head{
  display:flex; align-items:flex-start; justify-content:space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.ds-title h1{ margin: 0; }
.ds-sub{ margin: 4px 0 0; opacity:.7; }

.ds-actions{ display:flex; align-items:center; gap: 10px; flex-wrap:wrap; justify-content:flex-end; }
.ds-sort{ display:flex; align-items:center; gap: 8px; }
.ds-sort span{ font-weight:800; opacity:.8; }
.ds-sort select{
  border:1px solid var(--ds-border);
  border-radius: 12px;
  padding: .55rem .65rem;
  background:#fff;
}

/* ✅ botón filtros (solo móvil) */
.ds-filtersbtn{
  border-radius: 999px;
  padding: .55rem .9rem;
  font-weight: 900;
}
@media (min-width: 992px){
  .ds-filtersbtn{ display:none !important; }
}

.ds-cartbtn{
  border: 1px solid var(--ds-border);
  background:#fff;
  border-radius: 999px;
  padding: .55rem .75rem;
  display:inline-flex; align-items:center; gap: 10px;
  box-shadow: 0 10px 22px rgba(0,0,0,.06);
  cursor:pointer;
  font-weight: 900;
}
.ds-cart__count{
  background: var(--ds-blue-700);
  color: #fff;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display:grid;
  place-items:center;
  font-weight: 900;
  padding: 0 8px;
}

/* GRID PRODUCTOS */
.ds-products{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
  align-items: stretch;
}

.ds-product{
  border:1px solid var(--ds-border);
  border-radius: 18px;
  background:#fff;
  box-shadow: 0 14px 30px rgba(0,0,0,.06);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  height: 100%;
  min-height: 420px;
}

.ds-product__img{
  width: 100%;
  height: 210px;
  aspect-ratio: auto;
  object-fit: contain;
  padding: 12px;
  background: #f2f4f7;
}

.ds-product__body{
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap: 8px;
  height: 100%;
}

.ds-product__title{
  margin: 0;
  line-height: 1.2;
  min-height: 48px;
}

.ds-product__meta{
  display:flex; gap: 8px; flex-wrap:wrap;
  opacity:.9;
  font-weight: 600;
  font-size: .82rem;
}

.ds-badge{
  border:1px solid var(--ds-border);
  background:#fff;
  border-radius: 999px;
  padding: 4px 8px;
}

.ds-price{
  margin-top: auto;
  padding-top: 6px;
  font-weight: 600;
  font-size: 1.02rem;
  color: #111;
}

.ds-buy{
  margin-top: 10px;
}

.ds-buy .ds-btn{
  width: 100%;
  border-radius: 12px;
}

/* PAGINACIÓN */
.ds-pagination{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  margin-top: 18px;
}

/* ============ CART DRAWER ============ */
.ds-cartdim{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  z-index: 5000;
}
.ds-cartdrawer{
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 92vw);
  background:#fff;
  border-left: 1px solid var(--ds-border);
  box-shadow: -18px 0 44px rgba(0,0,0,.18);
  z-index: 5100;
  transform: translateX(110%);
  transition: transform .22s ease;
  display:grid;
  grid-template-rows: auto 1fr auto;
}
.ds-cartdrawer.is-open{ transform: translateX(0); }

.ds-iconbtn{
  border: 1px solid var(--ds-border);
  background:#fff;
  border-radius: 12px;
  width: 38px;
  height: 38px;
  display:grid;
  place-items:center;
  cursor:pointer;
}
.ds-iconbtn:hover{ background: rgba(0,0,0,.04); }

/* ============ MODAL (por clase) ============ */
.ds-paymodal{
  position: fixed;
  inset: 0;
  z-index: 5200;
  place-items:center;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  padding: 16px;
  display:none;
}
.ds-paymodal.is-open{ display:grid; }

.ds-modal__card{
  width: min(980px, 96vw);
  max-height: 92vh;
  overflow:auto;
  background:#fff;
  border-radius: 18px;
  border: 1px solid var(--ds-border);
  box-shadow: 0 18px 60px rgba(0,0,0,.22);
}
.ds-modal__head{
  padding: 14px;
  border-bottom: 1px solid var(--ds-border);
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.ds-modal__head .ds-iconbtn{
  pointer-events:auto;
  position:relative;
  z-index:5;
}
.ds-modal__body{ padding: 14px; }

.ds-pay{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
}

.ds-pay__left{
  display:grid;
  gap: 14px;
  align-content:start;
}

.ds-pay__methods{
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  padding: 12px;
  display:grid;
  gap: 10px;
  height: fit-content;
}
.ds-radio{
  display:flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--ds-border);
  border-radius: 14px;
  cursor:pointer;
}
.ds-radio:hover{ background: rgba(0,0,0,.03); }
.ds-radio input{ margin-top: 3px; }
.ds-radio small{ display:block; opacity:.7; font-weight:700; margin-top: 2px; }

.ds-paybox{
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  height: fit-content;
}

.ds-form{
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  padding: 12px;
  display:grid;
  gap: 10px;
}
.ds-form label{ display:grid; gap: 6px; font-weight: 850; }
.ds-form input{
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  padding: .65rem .75rem;
  outline:none;
}
.ds-form input:focus{
  border-color: rgba(30,64,175,.35);
  box-shadow: 0 0 0 6px var(--ds-ring);
}
.ds-form__row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Desktop layout */
@media (min-width: 1080px){
  .ds-shop__wrap{ grid-template-columns: 280px 1fr; align-items:start; }
  .ds-shop__sidebar{ position: sticky; top: calc(var(--nav-h, 64px) + 12px); }
  .ds-products{ grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (min-width: 1440px){
  .ds-products{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}
@media (max-width: 540px){
  .ds-products{ grid-template-columns: 1fr; }
  .ds-shop__head{ flex-direction:column; align-items:flex-start; }
  .ds-actions{ width:100%; justify-content:space-between; }
}

/* Sidebar: líneas / familias */
.ds-cat__list{ list-style:none; padding:0; margin:0; display:grid; gap:10px; }
.ds-line{ border:1px solid var(--ds-border); border-radius:14px; overflow:hidden; background:#fff; }
.ds-line__btn{
  width:100%; display:flex; justify-content:space-between; align-items:center;
  padding:10px 12px; border:0; background:#fff; cursor:pointer;
  font-weight: 400;
  color: #111;
}
.ds-line__btn span{ opacity:.7; font-weight: 400; }

.ds-fams{ list-style:none; margin:0; padding:6px; border-top:1px solid var(--ds-border); }
.ds-fams a{
  display:flex; justify-content:space-between; align-items:center;
  padding:8px 10px; border-radius:12px; text-decoration:none;
  color:#111;
  font-weight: 400;
}
.ds-fams a:hover{ background: rgba(0,0,0,.04); }
.ds-fams small{
  opacity:.65;
  font-weight: 400;
  color:#111;
}

/* 🔥 FIX */
[hidden]{ display:none !important; }
#ds-cart-dim[hidden]{ display:none !important; pointer-events:none !important; }

/* =========================================================
   ✅ MOBILE: HEADER TIENDA STICKY + FILTROS DRAWER
   ========================================================= */
@media (max-width: 991.98px){

  .ds-shop__head{
    position: sticky;
    top: calc(var(--nav-h, 64px) + 8px);
    z-index: 1200;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(6px);
    border: 1px solid var(--ds-border);
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 10px 22px rgba(0,0,0,.06);
  }

  /* Sidebar en móvil como drawer */
  .ds-shop__sidebar{
    position: fixed;
    top: var(--nav-h, 64px);
    left: 0;
    height: calc(100vh - var(--nav-h, 64px));
    width: min(380px, 92vw);
    z-index: 4800;
    overflow: auto;

    transform: translateX(-110%);
    transition: transform .22s ease;

    border-radius: 0 18px 18px 0;
    box-shadow: 18px 0 44px rgba(0,0,0,.18);
  }

  .ds-shop__sidebar.is-open{
    transform: translateX(0);
  }

  /* Overlay del drawer de filtros */
  .ds-filterdim{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(3px);
    z-index: 4700;
    display: none;
  }
  .ds-filterdim.is-open{ display:block; }

  /* ✅ botón X visible en móvil */
  #ds-close-filters{ display:inline-grid; }
}

/* ✅ en desktop el botón X no estorba */
@media (min-width: 992px){
  #ds-close-filters{ display:none !important; }
}

/* ===============================
   CARRITO SOBRE FILTROS (PC)
   CENTRADO + AIRE ARRIBA/ABAJO
   =============================== */
@media (min-width: 992px){

  .ds-shop__sidebar{
    position: sticky;
    top: calc(var(--nav-h, 64px) + 12px);
  }

  .ds-side__top{
    position: relative;
    padding-top: 48px;
    padding-bottom: 12px;
  }

  .ds-cartbtn--sidebar{
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;

    box-shadow: 0 14px 30px rgba(0,0,0,.18);
    padding: .6rem 1.1rem;
    border-radius: 999px;
  }

  .ds-side__title{
    margin-top: 14px;
  }

  .ds-shop__content #ds-open-cart{
    display: none !important;
  }
}


/* =========================================================
   ✅ FIX: MODAL "FINALIZAR COMPRA" PERFECTO EN MÓVIL
   (sin scroll horizontal, 1 columna, padding correcto)
   ========================================================= */

/* evita scroll horizontal del modal */
.ds-modal__card{
  overflow-x: hidden;     /* 👈 clave */
}

/* en móvil: modal a pantalla, 1 columna, sin desbordes */
@media (max-width: 991.98px){

  .ds-paymodal{
    padding: 10px;        /* menos borde */
  }

  .ds-modal__card{
    width: 100%;
    max-width: 100%;
    border-radius: 16px;
    max-height: 92vh;
    overflow-y: auto;
    overflow-x: hidden;   /* 👈 clave */
  }

  /* ✅ 1 columna siempre */
  .ds-pay{
    display: grid;
    grid-template-columns: 1fr !important; /* 👈 fuerza 1 col */
    gap: 12px;
  }

  /* evita que algo empuje el ancho */
  .ds-pay__left,
  .ds-form{
    min-width: 0;
  }

  /* formulario: filas 1 columna */
  .ds-form__row{
    grid-template-columns: 1fr !important;
  }

  /* inputs y botones a ancho real */
  .ds-form input,
  .ds-form button,
  .ds-pay__methods,
  .ds-paybox{
    width: 100%;
    max-width: 100%;
  }

  /* el header del modal más compacto */
  .ds-modal__head{
    padding: 12px;
  }
  .ds-modal__body{
    padding: 12px;
  }
}

/* móvil chico: aún más compacto */
@media (max-width: 540px){
  .ds-paymodal{ padding: 8px; }
  .ds-modal__card{ border-radius: 14px; }
  .ds-modal__body{ padding: 10px; }
}


/* =========================================================
   ✅ MÓVIL: Filtros + Ordenar + Carrito en 1 sola fila
   ========================================================= */
@media (max-width: 991.98px){

  /* la barra del header como fila única */
  .ds-shop__head{
    display:flex !important;
    align-items:center !important;
    justify-content:space-between !important;
    flex-wrap: nowrap !important;      /* 👈 NO bajar a otra fila */
    gap: 10px !important;
  }

  /* el grupo de acciones: 3 items en fila */
  .ds-actions{
    display:flex !important;
    align-items:center !important;
    justify-content:flex-end !important;
    flex-wrap: nowrap !important;      /* 👈 clave */
    width: 100% !important;
    gap: 10px !important;
  }

  /* Filtros y Carrito no se encogen demasiado */
  .ds-filtersbtn,
  .ds-cartbtn{
    flex: 0 0 auto !important;
    white-space: nowrap;
  }

  /* Ordenar ocupa el espacio del medio */
  .ds-sort{
    flex: 1 1 auto !important;
    min-width: 0 !important;
    justify-content:flex-end;
  }

  /* el select se adapta sin romper fila */
  .ds-sort select{
    width: 100%;
    min-width: 0 !important;
  }

  /* opcional: ocultar el texto "Ordenar" en móvil para que entre perfecto */
  .ds-sort span{
    display:none;
  }
}

/* si en móviles muy chicos aún no entra, reduce paddings */
@media (max-width: 420px){
  .ds-filtersbtn{ padding: .5rem .7rem !important; }
  .ds-cartbtn{ padding: .5rem .7rem !important; }
  .ds-cart__count{ min-width: 24px; height: 24px; }
}
