/* ======================
   ESTILOS GENERALES
========================= */
* {
  box-sizing: border-box;
}

body {
  font-family: "Montserrat", sans-serif;
  margin: 0;
  background-color: #f5f7fa;
  color: #333;
  overflow-x: hidden;
}

/* Fondo con imagen eco-natural */
.fondo-imagen {
  background: url("../assets/paisaje.png") center/cover no-repeat;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  filter: brightness(0.8) blur(2px);
}

/* Logo común */
.top-logo-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  padding: 10px 0;
  text-align: center;
}

.logo-bar {
  height: 70px;
  max-width: 240px;
  object-fit: contain;
}

/* Oculta el texto del botón en pantallas menores a 576px */
@media (max-width: 576px) {
  .btn-text {
    display: none;
  }
}

@media (min-width: 769px) {
  main {
    padding-left: 3rem;
    padding-right: 3rem;
  }
}

@media (max-width: 768px) {
  main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  main.vh-100 {
    height: auto !important;
    padding-top: 120px;
    padding-bottom: 40px;
  }
}

/* ======================
   ESTILOS LOGIN
========================= */
.login-card {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* ==== Estilo personalizado Select2 para Bootstrap 5 ==== */

.select2-container--bootstrap4 .select2-selection {
  height: 38px !important; /* Altura estándar de .form-select */
  padding: 0.375rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
}

/* Texto seleccionado (alineado a la izquierda, sin salto, máximo espacio) */
.select2-container--bootstrap4 .select2-selection__rendered {
  flex: 1;
  margin: 0;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

/* Ocultar la cruz de limpiar */
.select2-container--bootstrap4 .select2-selection__clear {
  display: none !important;
}

/* Limita la altura del dropdown y agrega scroll */
.select2-container--bootstrap4 .scrollable-dropdown .select2-results__options {
  max-height: 300px; /* puedes ajustar este valor */
  overflow-y: auto;
}

@media (max-width: 768px) {
  .login-card {
    margin: 0 1rem;
    padding: 1.5rem;
  }

  .form-control {
    font-size: 1rem;
  }

  .btn {
    font-size: 1rem;
    padding: 0.6rem;
  }
}

/* ======================
   ESTILOS DASHBOARD
========================= */
.glass-card {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 40px 20px;
  color: white;
  font-size: 1.2rem;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  text-align: center;
}

.glass-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.card-link {
  text-decoration: none;
}

/* Dropdown estilo glass personalizado */
.dropdown-menu {
  border-radius: 20px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  padding: 40px 20px !important;
  min-width: 220px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 500;
  border: none !important;
}

#usuarioDropdown::after {
  display: none !important;
}

@media (max-width: 576px) {
  .glass-card {
    font-size: 1rem;
    padding: 24px 12px;
  }

  .glass-card strong {
    font-size: 1.1rem;
  }

  #logoutBtn {
    max-width: 300px;
    font-size: 1rem;
  }

  .logo-bar {
    height: 50px;
    max-width: 180px;
  }

  main.vh-100 {
    height: auto !important;
    padding-top: 120px;
    padding-bottom: 40px;
  }
}

.glass-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  height: clamp(160px, 24vh, 230px); /* más altas y adaptables */
  padding: 48px 24px; /* más aire */
  font-size: clamp(1.2rem, 1rem + 1vw, 1.8rem); /* icono/texto más grandes */
}

.glass-card strong {
  font-size: 1.1em; /* título un pelín mayor que el icono */
  line-height: 1.2;
}

/* En pantallas grandes, hazlas aún más protagonistas */
@media (min-width: 992px) {
  .glass-card {
    height: 240px;
    font-size: 1.8rem;
  }
}

/* ======================
   ESTILOS NUEVO PEDIDO
========================= */
.pedido-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}

.resumen-pedido {
  position: sticky;
  top: 150px;
  align-self: start;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  width: 100%;
  max-width: 280px;
}

.tabla-articulos {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.moderna-table {
  background-color: white;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.moderna-table thead th {
  background-color: #0d6efd;
  color: white;
  font-weight: 600;
  top: 0;
  z-index: 2;
  text-align: center;
  vertical-align: middle;
}

.moderna-table td {
  background-color: white;
  vertical-align: middle;
  text-align: center;
  padding: 0.75rem;
  font-size: 0.95rem;
}

.moderna-table tbody tr:hover {
  background-color: #f6f9fc;
}

.pt-150 {
  padding-top: 150px;
}

.pt-100 {
  padding-top: 100px;
}

.alerta-portes {
  background-color: #dc3545;
  font-weight: 600;
  font-size: 0.95rem;
}

@media (min-width: 768px) {
  .resumen-pedido {
    max-height: calc(100dvh - 120px);
    display: flex;
    flex-direction: column;
  }

  .resumen-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.5rem;
  }

  .resumen-footer {
    position: sticky;
    bottom: 0;
    background: inherit;
    padding-top: 1rem;
  }

  #resumenPedido {
    font-size: 0.8rem;
  }

  #resumenPedido input,
  #resumenPedido label,
  #resumenPedido button,
  #resumenPedido h5,
  #resumenPedido p {
    font-size: 0.8rem !important;
  }
}

@media (max-width: 768px) {
  #domicilioSelect,
  #buscador {
    width: 95% !important;
  }

  /* Ocultar tabla en móvil */
  .tabla-articulos {
    display: none;
  }

  /* Mostrar tarjetas */
  #articulos-movil {
    display: block !important;
  }

  .tarjeta-articulo {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
    padding: 1rem;
    font-size: 0.9rem;
  }

  .tarjeta-articulo .campo {
    margin-bottom: 0.4rem;
  }

  .pedido-layout {
    display: block;
  }

  .resumen-pedido {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 90%;
    max-width: 400px;
    background: white;
    z-index: 1050;
    padding: 1.5rem;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .resumen-pedido.abierta {
    transform: translateX(0%);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  #btnResumenToggle {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1100;
    background-color: #0d6efd;
    color: white;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  }
}

.img-mini {
  max-width: 70px;
  max-height: 70px;
  object-fit: contain;
  border-radius: 6px;
}

.img-codigo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.img-codigo-wrapper img {
  margin-bottom: 4px;
}

/* Colores de stock con mayor especificidad dentro de la tabla */
.moderna-table td.stock-verde {
  color: #1e8449 !important;
  font-weight: 600;
}
.moderna-table td.stock-ambar {
  color: #d35400 !important;
  font-weight: 600;
}
.moderna-table td.stock-rojo {
  color: #c0392b !important;
  font-weight: 600;
}

.stock-bloque .stock-verde {
  color: #1e8449 !important;
  font-weight: 600;
}
.stock-bloque .stock-ambar {
  color: #d35400 !important;
  font-weight: 600;
}
.stock-bloque .stock-rojo {
  color: #c0392b !important;
  font-weight: 600;
}

/* ======================
   ESTILOS CONSULTAR PEDIDOS
========================= */
.detalle-pedido {
  position: fixed;
  top: 100px;
  right: 30px;
  width: calc(66.666% - 60px);
  height: calc(100vh - 120px);
  overflow-y: auto;
  border-radius: 12px;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

/* Scroll solo cuando el ratón está encima */
.detalle-pedido.scroll-activo {
  overflow-y: auto;
}

/* Scrollbar más fino y estético */
.detalle-pedido.scroll-activo::-webkit-scrollbar {
  width: 6px;
}
.detalle-pedido.scroll-activo::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.pagination {
  gap: 4px;
  margin-bottom: 0;
}

.pagination .page-item .page-link {
  color: white;
  border: none;
  background: none;
  font-weight: 500;
  padding: 6px 12px;
}

.pagination .page-item.active .page-link {
  background-color: white;
  color: #0d6efd;
  border-radius: 50%;
}

.pagination .page-item.disabled .page-link {
  color: #aaa;
  cursor: default;
}

/* ======================
   ESTILOS PLANES HIGIENE
========================= */

#tbodyLineasNuevo td {
  vertical-align: middle;
}

/* Asegura centrado vertical y horizontal de los botones dentro del contenedor */
#tbodyLineasNuevo td .d-flex {
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
