/* ———————————————————————————————  ESTILOS PÁGINA CARRITO  ——————————————————————————————— */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f5f5;
  font-size: 14px;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* ------------------------------------------------------------------
   DISPOSICIÓN GENERAL
------------------------------------------------------------------ */
.carrito-container {
  display: flex;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 15px;
  gap: 30px;
}

/* Asegurar el orden correcto en desktop */
.carrito-items {
  flex: 2;
  min-width: 300px;
  background: #fff;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
  order: 1; /* Lista de items a la izquierda */
}

.carrito-items h1 {
  margin: 0 0 25px;
  font-size: 1.8em;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

/* Ítem de carrito */
.carrito-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #eee;
  padding: 8px 0;
  min-height: 70px;
  transition: opacity .5s, transform .5s;
}

.carrito-item.saliendo {
  opacity: 0;
  transform: translateX(30px);
}

.carrito-item-imagen img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #f0f0f0;
}

.carrito-item-detalles {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.carrito-item-detalles .producto-nombre {
  font: 600 1.1em/1.2 "inherit";
  color: #333;
}

.carrito-item-detalles .producto-precio-unitario {
  font: .85em "inherit";
  color: #777;
}

.carrito-item-acciones {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-cantidad {
  width: 35px;
  height: 35px;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: background .3s;
}

.btn-cantidad.mas {
  background: #4CAF50;
  color: #fff;
}

.btn-cantidad.mas:hover {
  background: #45a049;
}

.btn-cantidad.menos {
  background: #b0b0b0;
  color: #fff;
}

.btn-cantidad.menos:hover {
  background: #999;
}

.input-cantidad {
  width: 60px;
  text-align: center;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin: 0 5px;
  padding: 0 15px;
  box-sizing: border-box;
}

.boton-eliminar {
  background: none;
  border: none;
  color: #e53935;
  font-size: .85em;
  text-decoration: underline;
  cursor: pointer;
}

.boton-eliminar:hover {
  color: #c62828;
}

/* -------- Columna derecha (resumen) -------- */
.carrito-resumen {
  flex: 1;
  min-width: 360px; /* <-- Aumentado para darle más espacio */
  background: #fff;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
  height: fit-content;
  order: 2; /* Resumen a la derecha */
}

.carrito-resumen h2 {
  margin: 0 0 20px;
  font-size: 1.5em;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

/* ------------------------------------------------------------------
   CABECERAS DEL RESUMEN
------------------------------------------------------------------ */
.resumen-cabeceras {
  display: flex;
  font-size: .9em;
  font-weight: 600;
  color: #555;
  padding: 0 6px 6px;
  border-bottom: 1px solid #e0e0e0;
}

.resumen-cabeceras span:nth-child(1) {
  flex: 0 0 40%;
  text-align: left;
}

.resumen-cabeceras span:nth-child(2) {
  flex: 0 0 20%;
  text-align: right;
}

.resumen-cabeceras span:nth-child(3) {
  flex: 0 0 20%;
  text-align: right;
}

.resumen-cabeceras span:nth-child(4) {
  flex: 0 0 20%;
  text-align: right;
}

/* Línea separadora opcional (muestra tu JS al mostrar cabeceras) */
hr.resumen-hr-cabeceras {
  margin: 0 0 10px;
  border: 0;
  border-top: 1px solid #eee;
}

/* ------------------------------------------------------------------
   CADA GRUPO/PRODUCTO (dos líneas)
------------------------------------------------------------------ */
/* Contenedor del grupo */
.resumen-grupo {
  display: flex;
  flex-wrap: nowrap;
  border-bottom: 1px dashed #eee;
  margin: 0 0 8px;
  padding: 8px 0;
}

.resumen-grupo:last-child {
  border-bottom: none;
}

/* Columna izquierda: nombre (puede tener dos líneas) */
.resumen-grupo-linea-principal {
  flex: 0 0 40%;
  padding: 0 6px;
  display: flex;
  flex-direction: column;
}

.resumen-grupo-titulo {
  font-weight: 600;
}

.resumen-grupo-alfa {
  font-size: .85em;
  color: #666;
}

/* Columna derecha: valores en una sola línea */
.resumen-grupo-linea-valores {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
}

.resumen-grupo-cantidad,
.resumen-grupo-precio-u,
.resumen-grupo-total {
  flex: 0 0 33%;
  text-align: right;
}

.resumen-grupo-total {
  font-weight: 700;
  color: #1a4a8d;
}

/* ------------------------------------------------------------------
   GRAN TOTAL + BOTÓN
------------------------------------------------------------------ */
.resumen-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.3em;
  font-weight: 700;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #ccc;
}

.boton-continuar {
  display: block;
  width: 100%;
  padding: 15px;
  margin-top: 25px;
  background: #e53935;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1.05em;
  font-weight: 700;
  cursor: pointer;
  transition: background .3s;
}

.boton-continuar:hover {
  background: #c62828;
}

/* ------------------------------------------------------------------
   DIÁLOGO CONFIRMACIÓN
------------------------------------------------------------------ */
#confirmacion-dialog {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 2em;
  box-shadow: 0 5px 15px rgba(0, 0, 0, .2);
  min-width: 300px;
  max-width: 90vw;
  margin: auto;
}

#confirmacion-dialog::backdrop {
  background: rgba(0, 0, 0, .6);
}

.dialog-mensaje {
  margin: 0 0 1.5em;
  font-size: 1.1em;
  color: #333;
  text-align: center;
}

.dialog-acciones {
  display: flex;
  justify-content: space-around;
  gap: 1em;
}

.boton-dialog {
  padding: .7em 1.5em;
  border: none;
  border-radius: 5px;
  font-size: .9em;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.boton-dialog:active {
  transform: scale(.98);
}

.boton-dialog.cancelar {
  background: #eee;
  color: #555;
  border: 1px solid #ccc;
}

.boton-dialog.cancelar:hover {
  background: #ddd;
}

.boton-dialog.confirmar {
  background: #e53935;
  color: #fff;
}

.boton-dialog.confirmar:hover {
  background: #c62828;
}

dialog:not([open]) {
  display: none;
}

/* ------------------------------------------------------------------
   MENSAJE CARRITO VACÍO
------------------------------------------------------------------ */
.carrito-vacio-mensaje {
  text-align: center;
  color: #777;
  padding: 40px 0;
  font-size: 1.1em;
}




/* =========================================
   AJUSTES PARA VISTA PC - MAYOR ANCHO
   ========================================= */

   #btn-continuar-mobile{
    display: block;
   }
   @media (min-width: 914px) {
    /* Contenedor principal más ancho en PC */
    #btn-continuar-mobile{
      display: none;
     }
    .carrito-container {
      max-width: 100%;
      width: calc(100% - 42%);
      margin: 30px auto;
      padding: 0 15px;
      gap: 30px;
    }
  
    /* Ajustar proporciones de las columnas para el nuevo ancho */
    .carrito-items {
      flex: 3;
      min-width: 400px;
      order: 1; /* <-- AÑADE ESTO para forzarlo a la izquierda */
    }
  
    .carrito-resumen {
      flex: 1.5;
      min-width: 420px;
      order: 2; /* <-- AÑADE ESTO para forzarlo a la derecha */
    }
  }


/* =========================================
   VISTA TABLET (769px - 1024px)
   ========================================= */
   @media (min-width: 1532px) {
    .carrito-container {
      width: 1200px;
    }
   }
   @media (max-width: 1532px) {
  
    /* 1. Apila los elementos verticalmente */
    .carrito-container {
      flex-direction: column;
      /* Ajusta el ancho para que no ocupe toda la pantalla */
      max-width: 90%; 
    }
  
    /* 2. Pone los datos de pago ARRIBA */
    .carrito-resumen {
      order: 1; 
    }
  
    /* 3. Pone la lista de ítems ABAJO */
    .carrito-items {
      order: 2; 
    }
  }

@media (min-width: 1400px) {
  .carrito-container {
    max-width: 1600px; /* Limitar el ancho máximo en pantallas muy grandes */
  }
}

@media (max-width: 914px) {

  /* =================================================================== */
  /* == NUEVOS ESTILOS RESPONSIVOS PARA PÁGINA DE CARRITO              == */
  /* =================================================================== */
  
  /* Estructura principal para móvil */
  body {
    padding-bottom: 80px; /* Espacio para el botón fijo */
  }

  .carrito-container {
    flex-direction: column;
    margin: 0;
    gap: 0;
    max-width: 100%;
    background: #f8f9fa;
  }
  .carrito-container {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Vista unificada: Resumen + Items como una sola capa que se desplaza */
  .carrito-resumen {
    position: static; /* Eliminar sticky para que se desplace con el contenido */
    z-index: auto;
    margin: 0 0 20px 0;
    border-radius: 12px 12px 0 0; /* Solo redondeado arriba */
    box-shadow: none;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 20px;
    background-color: #ffffff;
    order: 1; /* El resumen va primero */
  }
  
  .carrito-resumen h2 { 
    font-size: 1.3em; 
    margin-bottom: 15px; 
    text-align: center;
    color: #333;
  }
  
  .resumen-total { 
    font-size: 1.2em; 
    margin-top: 15px; 
    padding-top: 15px;
    justify-content: space-between; /* Volver al diseño original */
    gap: normal;
  }

  /* Ocultar el botón del resumen en móvil */
  .carrito-resumen .boton-continuar {
    display: none;
  }

  /* Lista de artículos conectada visualmente con el resumen */
  .carrito-items {
    background: #ffffff; /* Mismo fondo que el resumen */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); /* Sombra unificada */
    
    order: 2; /* Los items van después */
    margin-bottom: 20px;
    border-radius: 0 0 12px 12px; /* Solo redondeado abajo */
  }

  .carrito-items h1 {
    font-size: 1.5em;
    padding: 20px 0 15px 0;
    text-align: center;
    margin-bottom: 20px;
  }

  .carrito-item {
    display: grid;
    /* Ajustamos las columnas para que el total y eliminar se ajusten a su contenido */
    grid-template-columns: 70px 1fr auto; 
    grid-template-rows: 1fr 1fr; /* Dos filas de igual tamaño */
    gap: 4px 12px;
    grid-template-areas:
      "imagen detalles  eliminar"
      "imagen cantidad  total"; /* Nueva distribución más lógica */
    background-color: #fff;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-height: auto;
  }

  .carrito-item-imagen { 
    grid-area: imagen; 
    align-self: center; 
  }
  
  .carrito-item-imagen img { 
    width: 70px; 
    height: 70px; 
    border-radius: 8px;
  }
  
  .carrito-item-detalles { 
    grid-area: detalles; 
    padding-right: 8px; 
    justify-self: start;
  }
  
  .carrito-item-detalles .producto-nombre { 
    font-size: 1em; 
    font-weight: 600; 
    margin-bottom: 4px;
    line-height: 1.3;
  }
  
  .carrito-item-detalles .producto-precio-unitario { 
    font-size: 0.9em; 
    color: #666; 
  }

  /* El total del item va debajo de la imagen */
  .carrito-item-total-mobile {
    grid-area: total;
    font-size: 1em;
    color: #333;
    font-weight: 500;
    /* Propiedades añadidas/modificadas */
    align-self: center;
    justify-self: end;
    text-align: right;
  }

  .carrito-item-total-mobile p {
    margin: 0;
    font-size: 0.85em;
  }

  .carrito-item-total-mobile p:first-child {
    color: #666;
  }
  
  .carrito-item-total-mobile p:last-child {
    font-size: 1.2em; /* Aumenta el tamaño de la fuente del precio */
    font-weight: 600; /* Le da un poco más de grosor */
  }
  
  .carrito-item-acciones { 
    grid-area: cantidad; 
    /* Propiedad modificada */
    justify-self: start; 
    margin-top: 0; 
    gap: 0;
    align-items: center;
    align-self: center; /* Centrado verticalmente */
  }

  /* Selector de cantidad como un grupo unificado */
  .selector-cantidad {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 8px;
  }
  
  .input-cantidad { 
    padding: 0; 
    height: 36px;
    width: 60px;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    border-radius: 0;
    font-size: 16px;
    text-align: center;
    margin: 0;
  }
  
  .btn-cantidad { 
    width: 36px; 
    height: 36px; 
    font-size: 18px;
    border-radius: 6px;
    border: 1px solid #ddd;
    margin: 0;
  }

  .btn-cantidad.menos {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  .btn-cantidad.mas {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .boton-eliminar {
    grid-area: eliminar;
    font-size: 0;
    text-decoration: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #fee;
    color: #e53935;
    position: relative;
    justify-self: end;
    align-self: start;
    margin-top: 4px;
  }

  .boton-eliminar:hover { 
    background-color: #e53935; 
    color: #fff; 
  }

  .boton-eliminar::before {
    content: '\f2ed';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  /* TERCERA CAPA: Botón fijo para proceder al pago */
  .mobile-checkout-button {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  }

  .mobile-checkout-button .boton-continuar {
    width: 100%;
    padding: 16px;
    font-size: 1.1em;
    font-weight: 700;
    border-radius: 12px;
    margin: 0;
    background: #e53935;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background .3s;
  }

  .mobile-checkout-button .boton-continuar:hover {
    background: #c62828;
  }

  .mobile-checkout-button .boton-continuar:disabled {
    background: #ccc;
    cursor: not-allowed;
  }
}

/* styles.css - Menú centralizado */