/* =========================================
   0. PALETA DE COLORES
   Definición de variables de color principal y variantes
   ========================================= */
:root {
  /* Colores Primarios */
  --color-beige: #eae0d5;
  --color-brown: #594b3a;
  --color-red: #842029;
  --color-white: #fff;

  /* Variantes del Beige */
  --color-beige-light: #f5f1e8;
  --color-beige-dark: #d4ccc0;
  --color-beige-muted: #e5dcd1;

  /* Variantes del Brown */
  --color-brown-light: #8b7765;
  --color-brown-dark: #3d3429;
  --color-brown-muted: #6d5f52;

  /* Variantes del Red */
  --color-red-light: #a83a47;
  --color-red-dark: #5c1820;
  --color-red-muted: #9a3841;

  /* Colores Complementarios */
  --color-accent-warm: #c9a574;
  --color-accent-cool: #7a8b9e;
  --color-accent-gold: #b8934d;

  /* Acción 'agregar' (btn-add) */
  --color-add: #648E45;

  /* Neutrals y Grises */
  --color-gray-light: #f8f9fa;
  --color-gray-medium: #d4d4d4;
  --color-gray-dark: #4a4a4a;

  /* Estados */
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-danger: #842029;
  --color-info: #7a8b9e;

  /* Overlay y Transparencias */
  --color-overlay-dark: rgba(59, 52, 41, 0.1);
  --color-overlay-light: rgba(234, 224, 213, 0.15);
}



/* =========================================
   1. ESTILOS GLOBALES / COMUNES
   Se aplican a todo el sitio web (body, botones, paginación, alertas)
   ========================================= */

/* Configuración básica del cuerpo */
body {
  background-color: var(--color-gray-light);
  user-select: none;
  font-family: 'Inter', system-ui, sans-serif !important;
  /* Evita que el usuario seleccione texto */
}

/* Espaciado superior para el contenido principal (debido al navbar fijo) */
.top-primario {
  margin-top: 130px;
}

/* --- Botones Personalizados --- */
.btn-custom {
  color: var(--color-white);
  background-color: #6f42c1;
  border-color: var(--color-gray-medium);
}

.btn-custom:hover {
  color: var(--color-white);
  background-color: #563d7c;
  border-color: #563d7c;
}

.btn-custom:active,
.btn-custom.active {
  color: var(--color-white);
  background-color: #452a5e;
  border-color: #452a5e;
}

.btn-custom:focus,
.btn-custom.focus {
  box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.5);
}

/* --- Paginación --- */
.pagination {
  display: inline-block;
  padding-left: 0;
  margin: 20px 0;
  border-radius: 4px;
}

.pagination>li {
  display: inline;
}

.pagination>li>a,
.pagination>li>span {
  position: relative;
  float: left;
  padding: 6px 12px;
  margin-left: -1px;
  line-height: 1.42857143;
  color: var(--color-info) !important;
  text-decoration: none !important;
  background-color: var(--color-white) !important;
  border: 1px solid var(--color-gray-medium) !important;
}

.pagination>li:first-child>a,
.pagination>li:first-child>span {
  margin-left: 0;
  border-bottom-left-radius: 4px;
  border-top-left-radius: 4px;
}

.pagination>li:last-child>a,
.pagination>li:last-child>span {
  border-bottom-right-radius: 4px;
  border-top-right-radius: 4px;
}

.pagination>li.active>a,
.pagination>li.active>span,
.pagination>li.active>a:hover,
.pagination>li.active>span:hover,
.pagination>li.active>a:focus,
.pagination>li.active>span:focus {
  z-index: 2;
  color: #fff !important;
  background-color: var(--color-info) !important;
  border-color: var(--color-info) !important;
}

/* --- Alertas y Notificaciones --- */
.alert-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1050;
}

.alert {
  margin-bottom: 10px;
  opacity: 0.9;
}

/* --- Tablas General --- */
/* Contenedores para hacer tablas responsivas con scroll */
.table-overflow {
  max-height: 75vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.container-adjust {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Estilos limpios para tablas */
.table thead th {
  border: none;
}

.table td,
.table th {
  border: none;
}

/* Filas alternadas (violeta claro) */
.table-striped tbody tr:nth-of-type(odd) {
  background-color: var(--color-beige-light);
}

.table-striped tbody tr:hover {
  background-color: var(--color-beige-muted);
}


/* =========================================
   2. NAVBAR (Barra de Navegación)
   Estilos específicos para la vista Navbar.php
   ========================================= */
.navbar {
  background-color: var(--color-beige);
  font-weight: 500;
}

.navbar a {
  padding: 0;
}

.navbar img {
  max-width: 150px;
}

.navbar-toggler {
  color: var(--color-brown-muted);
}

/* Contenedor de acciones */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Dropdown in navbar: match site palette */
.navbar .dropdown-menu {
  background-color: var(--color-beige) !important;
  border: 1px solid var(--color-beige-dark) !important;
  box-shadow: 0 8px 24px rgba(89,75,58,0.08);
  min-width: 180px;
}

.navbar .dropdown-item {
  color: var(--color-brown) !important;
  padding: 0.5rem 1rem;
}

.navbar .dropdown-item:hover, .navbar .dropdown-item:focus {
  background-color: var(--color-beige-muted) !important;
  color: var(--color-brown-dark) !important;
}

.navbar .dropdown-toggle svg {
  stroke: var(--color-brown);
}

/* Links del navbar */
.navbar-actions .nav-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.6rem;
  color: var(--color-brown) !important;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

/* Iconos */
.navbar-actions svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
  opacity: 0.85;
}

.navbar-actions .nav-link i {
  font-size: 1.1rem;
  opacity: 0.85;
}

/* Hover general */
.navbar-actions .nav-link:hover {
  background-color: var(--color-brown);
  color: var(--color-beige) !important;
}

.navbar-actions .nav-link:hover svg {
  stroke: var(--color-beige);
}

/* Separador */
.nav-separator {
  width: 1px;
  height: 28px;
  background-color: rgba(0, 0, 0, 0.15);
  margin: 0 0.75rem;
  align-self: center;
}

/* Logout destacado */
.nav-link.logout {
  color: var(--color-red) !important;
}

.nav-link.logout:hover {
  background-color: var(--color-red);
  color: var(--color-white) !important;
}

.nav-link.logout:hover svg {
  stroke: var(--color-white);
}

/* Logout móvil (fuera del menú) */
.logout-mobile {
  display: none;
}

/* Responsive */
@media (max-width: 991px) {
  .navbar-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .nav-separator {
    display: none;
  }

  .logout-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    padding: 0.45rem;
    border-radius: 0.6rem;
    color: var(--color-red);
  }

  .logout-mobile svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
  }
}



/* =========================================
   3. PRODUCTOS (Vista Principal)
   Estilos para la cuadrícula de productos, tarjetas y búsqueda
   ========================================= */

/* Buscador mejorado */
.search-form {
  display: flex;
  justify-content: center;
  margin-bottom: 3rem;
  margin-top: 0;
}

.search-form .input-group {
  width: 100%;
  max-width: 500px;
  border-radius: 0.7rem;
  overflow: hidden;
  border: 2px solid var(--color-beige-dark);
  background-color: var(--color-white);
  transition: border-color 0.25s ease;
}

.search-form .input-group:focus-within {
  border-color: var(--color-brown);
}

.search-form .form-control {
  border: none !important;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  color: var(--color-brown-dark);
  background-color: transparent;
}

.search-form .form-control::placeholder {
  color: var(--color-brown-muted);
}

.search-form .form-control:focus {
  box-shadow: none;
  border: none !important;
}

.search-form .input-group-append .btn {
  border: none;
  padding: 0 1rem;
  background-color: transparent;
  transition: all 0.25s ease;
  cursor: pointer;
}

.search-form .input-group-append .btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--color-brown);
  stroke-width: 2;
}

.search-form .input-group-append .btn:hover svg {
  stroke: var(--color-brown-dark);
}

/* Tarjetas de Productos */
.product-card {
  border: none;
  background-color: var(--color-white);
  border-radius: 1.2rem;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(89, 75, 58, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
  display: flex;
  flex-direction: column;
}
/* Responsive modal: en móviles mostrar Título -> Foto -> Detalle */
@media (max-width: 767px) {
  #productModal .modal-body .d-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  /* Mostrar el bloque de texto (nombre + detalle) antes de la foto */
  #productModal .modal-body .d-flex > div:first-child {
    order: 1; /* imagen pasa abajo */
  }
  #productModal .modal-body .d-flex > div:last-child {
    order: 0; /* texto arriba */
  }

  /* Foto a 100% ancho y centrada */
  #modal-photo {
    width: 100% !important;
    height: auto !important;
    display: block;
    margin: 0 auto;
    object-fit: contain;
  }

  /* Ajustes tipográficos para móvil */
  #modal-name {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  #modal-detail {
    font-size: 0.95rem;
    line-height: 1.45;
  }
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 16px 36px rgba(89, 75, 58, 0.16);
}

/* Banner carousel styles */
.banner-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 1.5rem auto;
}
.banner-image {
  width: 100%;
  height: 260px;
  object-fit: cover;
}

@media (max-width: 991px) {
  .banner-image { height: 200px; }
}
@media (max-width: 576px) {
  .banner-image { height: 140px; }
}

/* Imagen del Producto */
.product-image-wrapper {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.product-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brown-muted);
  background-color: var(--color-beige);
}

/* Cuerpo del Producto */
.product-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.product-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-brown-dark);
  line-height: 1.4;
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* Sección de Precio */
.product-price-section {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.product-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-red);
  letter-spacing: -0.5px;
}

/* Sección de Cantidad */
.quantity-section {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.quantity-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-brown);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
  white-space: nowrap;
}

.quantity-control {
  display: flex;
  align-items: center;
  gap: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background-color: transparent;
}

.btn-quantity {
  background-color: transparent;
  border: none;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--color-brown);
}


.btn-quantity:hover {
  background-color: transparent;
  color: var(--color-red);
}

.btn-quantity:active {
  transform: scale(0.95);
}

.btn-quantity svg {
  stroke: currentColor;
}

.quantity-input {
  text-align: center;
  border: none;
  padding: 0.3rem 0.4rem;
  font-weight: 700;
  color: var(--color-brown-dark);
  width: 2.5rem;
  background-color: transparent;
  font-size: 0.9rem;
}

.quantity-input:focus {
  outline: none;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.quantity-input[type=number] {
  -moz-appearance: textfield;
}

/* Ajustes responsivos para controlar el espacio entre 768px y 1199px (tablet / small desktop)
   Hace el control de cantidad más compacto para evitar que el botón '+' quede fuera de pantalla */
@media (min-width: 768px) and (max-width: 1199px) {
  .quantity-section {
    gap: 0.35rem;
  }

  .quantity-control {
    gap: 0;
    display: inline-flex;
    align-items: center;
  }

  .btn-quantity {
    padding: 0.2rem 0.35rem;
  }

  .quantity-input {
    width: 1.9rem;
    padding: 0.2rem 0.25rem;
    font-size: 0.85rem;
  }

  /* Reduce ligeramente la altura de la imagen para dar más espacio al cuerpo en pantallas medianas */
  .product-image-wrapper {
    height: 200px;
  }
}

/* Formulario del Producto */
.product-form {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Botón Agregar al Carrito */
.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.85rem;
  border-radius: 0.8rem;
  font-size: 0.95rem;
  font-weight: 600;
  background-color: var(--color-add);
  color: var(--color-white);
  border: 2px solid var(--color-add);
  transition: all 0.25s ease;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-add:hover {
  background-color: #5a7c3c;
  border-color: #5a7c3c;
  transform: scale(1.02);
  box-shadow: 0 6px 16px rgba(100, 142, 69, 0.2);
  color: var(--color-white);
}

.btn-add:active {
  transform: scale(0.98);
}

.btn-add svg {
  stroke-width: 2;
  width: 18px;
  height: 18px;
}

/* --- Botones para el formulario de filtros --- */
.btn-buscar {
  background-color: var(--color-add);
  border-color: var(--color-add);
  color: var(--color-white);
}
.btn-buscar:hover {
  background-color: #5a7c3c;
  border-color: #5a7c3c;
}

.btn-limpiar {
  background-color: var(--color-info);
  border-color: var(--color-info);
  color: var(--color-white);
}
.btn-limpiar:hover {
  background-color: #6b7f92;
  border-color: #6b7f92;
}

/* Filter controls sizing to match the datepicker and keep consistent layout */
.filter-control {
  min-width: 210px;
  max-width: 260px;
  height: 42px;
  padding: 0.45rem 0.75rem;
  display: inline-block;
  box-sizing: border-box;
}

@media (max-width: 767px) {
  .filter-control {
    min-width: 100%;
    max-width: 100%;
  }
}

/* Select2 height adjustments to match .filter-control */
.select2-container .select2-selection--single {
  height: 42px !important;
  padding: 0.2rem 0.6rem !important;
  box-sizing: border-box;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 42px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px !important;
}

@media (max-width: 767px) {
  .select2-container .select2-selection--single {
    height: 44px !important;
  }
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 44px !important;
  }
}



/* =========================================
   4. CARRITO Y PEDIDOS
   Estilos para la lista de items en el carrito y lista de pedidos
   ========================================= */

/* Carrusel del Carrito */
.carousel-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  height: 500px;
}

.carousel-btn {
  background: var(--color-brown);
  border: none;
  color: var(--color-beige);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  font-weight: bold;
}

.carousel-btn:hover:not(:disabled) {
  background-color: var(--color-brown-dark);
  border-color: var(--color-brown-dark);
  transform: scale(1.1);
}

.carousel-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.carousel-container {
  flex: 1;
  overflow: hidden;
  height: 100%;
}

.carousel-track {
  display: flex;
  flex-wrap: nowrap;
  transition: transform 0.3s ease;
  height: 100%;
}

.my-carousel-item {
  flex: 0 0 100%;
  min-width: 100%;
  width: 100%;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.my-carousel-item .product-card {
  width: 100%;
  max-width: 400px;
  box-shadow: none;
}

/* Items del Carrito */
.cart-item {
  border-bottom: 1px solid var(--color-gray-medium);
  padding: 15px 0;
}

.cart-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item:hover {
  background-color: var(--color-gray-medium);
}

.cart-total {
  font-weight: bold;
  font-size: 24px;
}

/* Tarjetas de Pedidos */
.order-card {
  border: none;
  background-color: var(--color-white);
  border-radius: 1.2rem;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(89, 75, 58, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.order-header {
  padding: 1.5rem;
  background: var(--color-beige-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.order-date {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-brown-dark);
}

.order-status {
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Colores por estado (por defecto info) */
.order-status {
  background-color: var(--color-info);
  color: var(--color-white);
}

.order-status.status-cancelado {
  background-color: var(--color-red);
  color: var(--color-white);
}

.order-status.status-finalizado {
  background-color: var(--color-success);
  color: var(--color-white);
}

.order-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.order-info {
  font-size: 0.9rem;
  color: var(--color-brown);
}

.order-info p {
  margin: 0.5rem 0;
}


/* =========================================
   5. ADMIN (Tablas de gestión)
   Estilos específicos para tablas de administración
   ========================================= */
#admin-table tr td {
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
}

#admin-table td,
#admin-table th {
  vertical-align: middle !important;
}

/* Responsive para tablas de admin en móviles */
@media (max-width: 768px) {
  #admin-table tr td {
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    max-width: 100px;
  }

  #admin-table tr td a {
    width: 100%;
    display: block;
  }
}

/* Pager and admin table tweaks: compact pagination and keep tables readable */
.container.top-primario .pagination {
  margin-top: 1rem;
}

/* Smaller page link padding for admin and ocultos modal */
.container.top-primario .pagination .page-link,
#paginationOcultos .page-link {
  padding: 6px 9px;
  font-size: 0.9rem;
}

/* Ensure table images are compact in admin and ocultos modal */
.table img{
  max-width: 80px;
  max-height: 80px;
  object-fit: cover;
}

/* Reduce modal padding a bit for large modal (ocultos) while keeping table responsive */
.modal-xl .modal-body {
  padding: 1rem 1.25rem;
}

/* Make the admin table text a bit smaller on narrow screens to avoid wrapping */
@media (max-width: 768px) {
  #admin-table td, #admin-table th {
    font-size: 0.95rem;
  }
}

/* Custom pager styles: compact, rounded and consistent with theme */
.pagination.custom-pager {
  gap: 0.4rem;
}

.pagination.custom-pager .page-item .page-link {
  color: var(--color-info);
  background: var(--color-white);
  border: 1px solid var(--color-gray-medium);
  padding: 6px 8px;
  border-radius: 0.6rem;
  min-width: 36px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.pagination.custom-pager .page-item.active .page-link {
  background-color: var(--color-info);
  border-color: var(--color-info);
  color: #fff;
}

.pagination.custom-pager .page-item.disabled .page-link {
  opacity: 0.55;
  pointer-events: none;
}

@media (max-width: 576px) {
  .pagination.custom-pager .page-item .page-link {
    padding: 5px 6px;
    min-width: 30px;
    font-size: 0.85rem;
  }
}

/* Botones de acción: editar / ocultar usando variables de color */
.btn-edit {
  background-color: var(--color-accent-gold);
  border-color: var(--color-accent-gold);
  color: var(--color-white);
}
.btn-edit:hover {
  background-color: #9a773a;
  border-color: #9a773a;
}

.btn-hide {
  background-color: var(--color-red);
  border-color: var(--color-red);
  color: var(--color-white);
}
.btn-hide:hover {
  background-color: var(--color-red-dark);
  border-color: var(--color-red-dark);
}

/* Mostrar (usar color de btn-add) */
.btn-show {
  background-color: var(--color-add);
  border-color: var(--color-add);
  color: var(--color-white);
}
.btn-show:hover {
  background-color: #5a7c3c;
  border-color: #5a7c3c;
}