/* ===== RESPONSIVE DESIGN ===== */

/* ===== MOBILE FIRST APPROACH ===== */
@media (max-width: 991px) {
  /* Asegurar que el body tenga el overflow correcto */
  body {
    overflow-x: hidden;
  }

  /* Header positioning */
  .header-main {
    position: sticky;
    top: 0;
    z-index: 1030;
    background-color: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }

  /* Mobile search bar positioning */
  .header-main .row:nth-child(2) {
    margin-top: 0.75rem !important;
    position: relative;
    z-index: 10;
    padding: 0 1rem;
  }

  /* Offcanvas positioning */
  .offcanvas {
    z-index: 1060 !important;
  }

  .offcanvas-backdrop {
    z-index: 1055 !important;
  }
}

/* ===== HEADER ===== */
@media (max-width: 991px) {
  .header-main {
    padding: 0.75rem 0;
    position: relative;
    z-index: 1030; /* Asegurar que esté por encima de otros elementos */
  }

  .header-main .row {
    align-items: center;
  }

  /* Logo responsive */
  .header-main img {
    max-height: 70px !important;
    height: 70px !important;
  }

  /* Mobile search bar - asegurar interactividad */
  .header-main .row:nth-child(2) {
    margin-top: 0.75rem !important;
    position: relative;
    z-index: 10;
  }

  /* Asegurar que los inputs del search sean clickeables */
  #mobileSearchForm input,
  #mobileSearchForm select,
  #mobileSearchForm button {
    position: relative;
    z-index: 15;
    pointer-events: auto !important;
  }

  #mobileSearchForm .input-group {
    position: relative;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }

  /* Evitar que otros elementos bloqueen el search */
  .header-main .container-fluid {
    position: relative;
    z-index: 20;
  }

  /* Estilos específicos para el search mobile */
  #mobileSearchInput:focus,
  #mobileSearchType:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    border-color: #86b7fe;
  }

  /* Asegurar que el botón del menú hamburguesa no interfiera */
  .header-main .btn-outline-secondary {
    position: relative;
    z-index: 25;
  }

  /* Asegurar que el search mobile sea completamente funcional */
  #mobileSearchForm {
    position: relative;
    z-index: 10;
  }

  #mobileSearchForm .form-control,
  #mobileSearchForm .form-select,
  #mobileSearchForm .btn {
    cursor: pointer;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
  }

  #mobileSearchForm .form-control {
    cursor: text;
  }
}

/* ===== MOBILE OFFCANVAS ===== */
.offcanvas {
  width: 300px !important;
  z-index: 1060 !important; /* Asegurar que esté por encima del header */
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  height: 100vh !important;
  transform: translateX(100%) !important; /* Inicialmente oculto */
}

.offcanvas.show {
  transform: translateX(0) !important; /* Mostrar cuando esté activo */
}

@media (max-width: 576px) {
  .offcanvas {
    width: 100% !important;
  }
}

.offcanvas-backdrop {
  z-index: 1055 !important;
}

/* Estilos adicionales para el offcanvas */
.offcanvas-header {
  border-bottom: 1px solid #dee2e6;
  padding: 1rem;
}

.offcanvas-body {
  padding: 1rem 0;
}

/* Asegurar que el offcanvas tenga el comportamiento correcto */
.offcanvas.offcanvas-end {
  border-left: 1px solid #dee2e6;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.1);
}

/* Estilos para el botón del menú hamburguesa */
.btn-outline-secondary {
  border-color: #6c757d;
  color: #6c757d;
}

.btn-outline-secondary:hover {
  background-color: #6c757d;
  border-color: #6c757d;
  color: white;
}

.offcanvas-body .list-group-item {
  border: none;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
}

.offcanvas-body .list-group-item .badge {
  margin-left: auto;
}

.offcanvas-body .list-group-item:hover {
  background-color: #f8f9fa;
}

.offcanvas-body .accordion-item {
  border: none;
}

.offcanvas-body .accordion-button {
  padding: 0.75rem 1rem;
  background-color: transparent;
  border: none;
  box-shadow: none;
}

.offcanvas-body .accordion-button:not(.collapsed) {
  background-color: #f8f9fa;
  color: #0d6efd;
}

.offcanvas-body .accordion-button:focus {
  box-shadow: none;
}

.offcanvas-body .accordion-body {
  padding: 0;
}

.offcanvas-body .accordion-body .list-group-item {
  padding-left: 2rem;
  font-size: 0.9rem;
}

/* ===== PRODUCTS PAGE ===== */
@media (max-width: 768px) {
  /* Product grid */
  .row-cols-md-3 {
    --bs-columns: 2;
  }

  /* Product cards */
  .product-card .card-img-top {
    height: 180px !important;
  }

  /* Filter sidebar */
  aside.sticky-top {
    position: static !important;
    margin-bottom: 2rem;
  }

  aside .card {
    margin-bottom: 1rem;
  }
}

@media (max-width: 576px) {
  .row-cols-sm-2 {
    --bs-columns: 1;
  }

  .product-card .card-img-top {
    height: 160px !important;
  }
}

/* ===== PRODUCT DETAIL ===== */
@media (max-width: 768px) {
  .product-detail .row {
    flex-direction: column;
  }

  .product-gallery img,
  .product-gallery video {
    height: 280px !important;
  }

  .product-info {
    margin-top: 2rem;
  }

  /* Ajustes para títulos y textos en tablets */
  .product-info h1 {
    font-size: 1.75rem !important;
  }

  .product-info .price {
    font-size: 2rem !important;
  }

  .product-info .badge {
    font-size: 0.8rem !important;
  }

  /* Ajustes para botones */
  .product-info .btn {
    padding: 0.75rem 1rem !important;
    font-size: 1rem !important;
  }
}

@media (max-width: 576px) {
  .product-gallery img,
  .product-gallery video {
    height: 200px !important;
  }

  /* Ajustes más agresivos para móviles pequeños */
  .product-info h1 {
    font-size: 1.5rem !important;
    margin-bottom: 0.75rem !important;
  }

  .product-info .price {
    font-size: 1.75rem !important;
    margin: 0.75rem 0 !important;
  }

  .product-info .badge {
    font-size: 0.75rem !important;
    padding: 0.375rem 0.75rem !important;
  }

  .product-info p {
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
  }

  /* Ajustes para botones en móviles */
  .product-info .btn {
    padding: 0.625rem 0.875rem !important;
    font-size: 0.95rem !important;
    margin-bottom: 0.5rem !important;
  }

  /* Ajustes para la galería de miniaturas */
  .gallery-thumbnails img,
  .gallery-thumbnails video {
    width: 60px !important;
    height: 60px !important;
  }

  /* Ajustes para reseñas */
  .review-card {
    padding: 0.75rem !important;
  }

  .review-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }

  /* Ajustes para el contenedor principal */
  .container.py-5 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }

  /* Ajustes para cards */
  .card.shadow-sm {
    margin-bottom: 1rem !important;
  }

  .card-body {
    padding: 1rem !important;
  }

  /* Ajustes para formularios de reseñas */
  .review-form .mb-3 {
    margin-bottom: 1rem !important;
  }

  .review-form .form-label {
    margin-bottom: 0.5rem !important;
    font-size: 0.9rem !important;
  }
}

/* ===== DASHBOARD ===== */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .dashboard-card {
    padding: 1rem;
  }

  .dashboard-stats {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 576px) {
  .dashboard-card h3 {
    font-size: 1.25rem;
  }

  .dashboard-card .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* ===== FORMS ===== */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
  }

  .form-group {
    margin-bottom: 1rem;
  }
}

/* ===== MODALS ===== */
@media (max-width: 576px) {
  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-content {
    border-radius: 12px;
  }

  .modal {
    z-index: 1060 !important;
  }

  .modal-backdrop {
    z-index: 1055 !important;
  }
}

/* ===== CAROUSEL ===== */
@media (max-width: 768px) {
  .carousel-control-prev,
  .carousel-control-next {
    width: 5%;
  }

  .carousel img {
    height: 200px;
    object-fit: contain;
  }
}

@media (max-width: 576px) {
  .carousel img {
        height: 350px;
        object-fit: contain;
    }
}

/* ===== STICKY SIDEBAR ===== */
@media (max-width: 768px) {
  .sticky-top {
    position: static !important;
  }
}

/* ===== HERO SECTION ===== */
@media (max-width: 768px) {
  .hero-section {
    padding: 2rem 0;
  }

  .hero-section h1 {
    font-size: 2rem;
  }

  .hero-section p {
    font-size: 1.1rem;
  }
}

/* ===== BENEFITS SECTION ===== */
@media (max-width: 576px) {
  .benefits-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* ===== PRICING CARDS ===== */
@media (max-width: 768px) {
  .pricing-card {
    margin-bottom: 2rem;
  }
}

/* ===== PRODUCT CARDS ===== */
@media (max-width: 576px) {
  .product-card .card-img-top {
    height: 160px !important;
  }

  .product-card .card-body {
    padding: 1rem;
  }

  .product-card .card-title {
    font-size: 1rem;
  }
}

/* ===== TABLES ===== */
@media (max-width: 768px) {
  .table-responsive {
    font-size: 0.875rem;
  }

  .table td,
  .table th {
    padding: 0.5rem;
  }
}

/* ===== UTILITIES ===== */
@media (max-width: 576px) {
  .text-center-mobile {
    text-align: center !important;
  }

  .mb-mobile-3 {
    margin-bottom: 1rem !important;
  }

  .px-mobile-2 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
}

/* ===== OFFCANVAS MENU ===== */
.offcanvas {
  width: 280px !important;
}

@media (max-width: 576px) {
  .offcanvas {
    width: 100% !important;
  }
}

  @media (max-width: 991px) {
    .hamburger-menu {
      display: block;
    }

    .nav-main .nav {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background: white;
      border: 1px solid #dee2e6;
      border-radius: 0 0 0.375rem 0.375rem;
      box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
      z-index: 1000;
    }

    .nav-main .nav.show {
      display: flex;
      flex-direction: column;
    }

    .nav-main .nav-link {
      border-bottom: 1px solid #f8f9fa;
      padding: 0.75rem 1rem;
    }

    .nav-main .nav-link:last-child {
      border-bottom: none;
    }
  }
  /* --- PRIORIDAD DEL MEGA MENÚ SOBRE EL ASIDE STICKY --- */
/* header, .nav-main, #megaDropdown { position: relative; z-index: 2100; }  asegura stacking context alto */
#categoriasMenu, .dropdown-menu { position: absolute; z-index: 2100; }   /* por encima de sticky-top (1020) */
aside.sticky-top { z-index: 900; }                                        /* opcional: bajar un poco el aside */

/* si algún contenedor cortaba el menú */

/* ===== ADDITIONAL PRODUCT DETAIL IMPROVEMENTS ===== */
@media (max-width: 576px) {
  /* Mejorar espaciado general */
  .product-detail .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Ajustes para el carousel */
  .carousel-control-prev,
  .carousel-control-next {
    width: 8% !important;
  }

  /* Mejorar botones de acción */
  .product-actions .btn {
    min-height: 48px !important; /* Mejor accesibilidad táctil */
  }

  /* Ajustes para formularios */
  .review-form .star-rating-widget {
    justify-content: center !important;
  }

  .review-form .star-rating-widget label {
    margin: 0 1px !important;
  }

  /* Mejorar títulos de sección */
  h4 {
    font-size: 1.25rem !important;
    margin-bottom: 1rem !important;
  }

  /* Ajustes para badges */
  .badge {
    display: inline-block !important;
    white-space: normal !important;
    word-wrap: break-word !important;
  }
}
.nav-main, .header-main, .header-main .container { overflow: visible !important; }

/* ====== Inputs (login + registro) ====== */
.form-control,
.form-select {
  height: 52px;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  border: 1px solid #d6e4ff;        /* borde clarito */
  background-color: #f1f5ff;        /* fondo azulado suave */
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  font-size: 1.05rem;
}

.form-control::placeholder {
  color: #8aa1c2;
  opacity: 1;
}

/* Estado focus (anillo azul como en login) */
.form-control:focus,
.form-select:focus {
  background-color: #ffffff;
  border-color: #1a73e8;
  box-shadow: 0 0 0 .25rem rgba(26, 115, 232, .15);
  outline: 0;
}

/* Corrige altura de inputs dentro de input-group (si los usás) */
.input-group > .form-control,
.input-group > .form-select {
  height: 52px;
  border-radius: 12px;
}

/* ====== Botones ====== */
.btn-primary {
  height: 40px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  background-color: #1366ff;
  border-color: #1366ff;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #0f57d5;
  border-color: #0f57d5;
}

/* Botón Google estilo outline rojo (como login) */
.btn-google,
.btn-outline-danger {
  height: 52px;
  border-radius: 12px;
  font-weight: 600;
}

/* ====== Checkbox de términos (registro) ====== */
.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: .35rem;
  border-color: #c9d6f3;
}

.form-check-input:checked {
  background-color: #1366ff;
  border-color: #1366ff;
}

.form-check-label {
  color: #334155;
  font-size: .98rem;
}

/* ====== Cards de auth (si el registro está dentro de una card) ====== */
.auth-card,
.card.auth-card {
  border: 1px solid #eef2ff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .06);
}

/* Espaciados más cómodos en formularios largos */
.auth-form .form-control,
.auth-form .form-select {
  margin-bottom: 14px;
}