/* ====== ESTILOS GENERALES ====== */
body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background-color: #f9f9f9;
}

/* ====== NAVBAR ====== */
.nav {
  display: flex;
  background-color: #4c6ca0;

  /* ✅ Navbar flotante */
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav a {
  flex: 1;
  text-align: center;
  padding: 1rem;
  color: white;
  text-decoration: none;
  font-weight: bold;
  background-color: #688cc7;
}

.nav a.active {
  background-color: white;
  color: black;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

/* ====== CONTENEDOR PRINCIPAL ====== */
.contenedor {
  padding: 2rem;
  max-width: 1280px;
  margin: 20px auto 0 auto;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

/* ====== TABLAS ====== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background-color: white;
}

th, td {
  border: 1px solid #ccc;
  padding: 10px;
  text-align: center;
}

th {
  background-color: #e5efff;
}

.estado-verde {
  color: green;
  font-weight: bold;
}

.estado-amarillo {
  color: orange;
  font-weight: bold;
}

.estado-rojo {
  color: red;
  font-weight: bold;
}

/* ====== BOTONES ====== */
button, .btn {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  line-height: 1.2;
}

button:hover, .btn:hover {
  background-color: #0056b3;
}

.btn-secundario {
  background-color: #6c757d;
}

.btn-secundario:hover {
  background-color: #5a6268;
}

.btn-peligro, .btn-danger {
  background-color: #dc3545;
}

.btn-peligro:hover, .btn-danger:hover {
  background-color: #b52a37;
}

.btn-exito {
  background-color: #28a745;
}

.btn-exito:hover {
  background-color: #1e7e34;
}

.btn3 {
  background-color: #17a2b8;
}

.btn3:hover {
  background-color: #117a8b;
}

.btn-cancelar {
  background-color: #6c757d;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
  text-decoration: none;
  display: inline-block;
}

.btn-cancelar:hover {
  background-color: #5a6268;
}

/* ====== FORMULARIOS ====== */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

form label {
  font-weight: bold;
  color: #333;
}

form input,
form select,
form textarea {
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  background-color: #fdfdfd;
}

form input:focus,
form select:focus,
form textarea:focus {
  border-color: #4c6ca0;
  box-shadow: 0 0 5px rgba(76, 108, 160, 0.5);
  outline: none;
}

/* Botones en línea dentro del formulario */
form .botones {
  display: flex;
  gap: 10px;
}

form .botones button,
form .botones .btn {
  margin: 0;
}

form button {
  align-self: flex-start;
  padding: 0.6rem 1.2rem;
}

/* ====== TITULOS ====== */
h2 {
  margin-top: 0;
  color: #4c6ca0;
  font-size: 1.5rem;
}

/* ====== BOTÓN FLOTANTE DE CERRAR SESIÓN ====== */
.btn-logout {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #dc3545;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transition: background-color 0.3s ease, transform 0.2s ease;
  text-decoration: none;
  z-index: 1000;
}

.btn-logout:hover {
  background-color: #b52a37;
  transform: scale(1.05);
}

/* ====== RESPONSIVE ====== */

/* Tablets y móviles */
@media (max-width: 768px) {
  .nav {
    flex-direction: column;
  }

  .nav a {
    text-align: left;
    padding: 0.8rem 1rem;
  }

  .contenedor {
    padding: 1rem;
    margin-top: 10px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.9rem;
  }

  th, td {
    padding: 0.5rem;
  }

  form {
    gap: 0.8rem;
  }

  form input,
  form select,
  form textarea {
    font-size: 0.9rem;
  }

  form .botones {
    flex-direction: column;
    gap: 0.5rem;
  }

  form button,
  form .botones .btn {
    width: 100%;
  }

  h2 {
    font-size: 1.3rem;
  }

  button, .btn, .btn-logout {
    font-size: 0.9rem;
    padding: 0.5rem 0.8rem;
  }
}

/* Móviles muy pequeños */
@media (max-width: 480px) {
  .contenedor {
    width: 95%;
    padding: 0.8rem;
  }
}

/* ====== FACTURACIÓN: LAYOUT PRINCIPAL ====== */

.facturacion-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  position: relative;
}

.facturacion-main {
  flex: 1;
  min-width: 0;
  position: relative;
}

.facturacion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.facturacion-busqueda {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.facturacion-busqueda .campo-busqueda {
  flex: 1 1 260px;
  min-width: 220px;
}

/* Formularios en línea (sobrescriben el form general) */
.form-inline {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

/* ====== Filtros desplegables: menú lateral derecho ====== */

.filtros-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.25);
  display: none;
  justify-content: flex-end;
  align-items: stretch;
  z-index: 1000;
}

.filtros-overlay.activo {
  display: flex;
}

.filtros-panel {
  width: 320px;
  max-width: 90vw;
  background-color: #ffffff;
  height: 100%;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
}

.filtros-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.filtros-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #4c6ca0;
}

.form-filtros {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.form-filtros .fila {
  display: flex;
  flex-direction: column;
}

.form-filtros .botones {
  display: flex;
  gap: 0.5rem;
}

/* Enfoque visual cuando los filtros están abiertos */
#contenedorFacturacion.filtros-abiertos {
  box-shadow: 0 0 0 3px #4c6ca0;
  border-radius: 10px;
}

/* Botón pequeño */
.btn-sm {
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
}

/* ====== Navegación de meses/años dentro del panel ====== */

.facturacion-periodos {
  margin-top: 1rem;
  border-top: 1px solid #ccc;
  padding-top: 0.75rem;
}

.facturacion-periodos h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: #4c6ca0;
}

.facturacion-aside-list {
  list-style: none;
  padding-left: 0;
  margin-top: 0.25rem;
}

.btn-mes {
  width: 100%;
  display: block;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  text-align: left;
  margin-bottom: 4px;
}

.btn-mes-activo {
  background-color: #4c6ca0;
  color: white;
}

/* ====== RESPONSIVE FACTURACIÓN ====== */

@media (max-width: 768px) {
  .facturacion-layout {
    flex-direction: column;
  }

  .filtros-panel {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }

  .facturacion-busqueda .campo-busqueda {
    min-width: 100%;
  }
}

/* ====== FACTURACIÓN: CHECKBOX MARCADO (✔ / ✖) ====== */

.campo-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-container {
  display: flex;
  align-items: center;
}

/* Checkbox grande con cuadro y símbolo ✔ / ✖ */
.checkbox-marcado {
  width: 1.6em;
  height: 1.6em;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #4c6ca0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3em;
  cursor: pointer;
  background: #fff;
}

/* ✔ cuando está marcado */
.checkbox-marcado:checked::before {
  content: "✔";
  color: #28a745;
  font-weight: bold;
}

/* ✖ cuando NO está marcado */
.checkbox-marcado:not(:checked)::before {
  content: "✖";
  color: #dc3545;
  font-weight: bold;
}

/* ====== ICONO EN TABLA ====== */

.marcado-icon {
  width: 1.6em;
  height: 1.6em;
  border: 2px solid #4c6ca0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
}

.marcado-icon.marcado-si::before {
  content: "✔";
  color: #28a745;
  font-weight: bold;
}

.marcado-icon.marcado-no::before {
  content: "✖";
  color: #dc3545;
  font-weight: bold;
}

/* === ACCIONES EN TABLA: EDITAR + ARCHIVOS (botones) === */

.col-acciones {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.2rem;
}

.btn-archivos {
  font-size: 0.9rem;
  padding: 0.35rem 0.7rem;
}

/* === OVERLAY / PANEL LATERAL DE ARCHIVOS (similar a filtros) === */

.adj-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.25);
  display: none;
  justify-content: flex-end;
  align-items: stretch;
  z-index: 1100;
}

.adj-overlay.activo {
  display: flex;
}

.adj-panel {
  width: 340px;
  max-width: 90vw;
  background-color: #ffffff;
  height: 100%;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
}

.adj-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.adj-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #4c6ca0;
}

.adj-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  color: #666;
}

.adj-close:hover {
  color: #c00;
}

.adj-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Contenido interno del panel de archivos */

.archivos-vacio {
  font-size: 0.85rem;
  color: #666;
  margin: 0;
}

.archivos-lista {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.archivos-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid #eee;
}

.archivos-item:last-child {
  border-bottom: none;
}

.archivo-nombre {
  flex: 1;
  font-size: 0.85rem;
  text-decoration: none;
  color: #007bff;
  word-break: break-all;
}

.archivo-nombre:hover {
  text-decoration: underline;
}

.form-adjuntos-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.form-adjuntos-menu input[type="file"] {
  font-size: 0.8rem;
}

.btn-borrar-adjunto {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #c00;
  font-size: 0.8rem;
}

.btn-borrar-adjunto:hover {
  text-decoration: underline;
}

.orden-productos {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
}

.fila-3pl {
  background-color: #fff7e0;   /* un amarillo suave */
}

.badge-3pl {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background-color: #ffb74d;
  color: #000;
  font-weight: 600;
}

/* ====== FACTURACIÓN: 3 ESTADOS MARCADO (0/1/2) ====== */

/* fila cancelada (rojo suave) */
.fila-cancelada {
  background-color: #ffecec;
}

/* icon base ya lo tienes: .marcado-icon */
.marcado-icon.marcado-no::before {
  content: "";            /* pendiente = vacío */
}

/* pagado */
.marcado-icon.marcado-si::before {
  content: "✔";
  color: #28a745;
  font-weight: bold;
}

/* cancelado */
.marcado-icon.marcado-cancelado::before {
  content: "✖";
  color: #dc3545;
  font-weight: bold;
}

/* =======================================================
   ✅ NUEVO: Encabezado de tabla sticky PEGADO al navbar
   (sin tocar tu diseño)
   ======================================================= */
:root{
  --alto-navbar: 0px;
  --thead-gap: 0px; /* 👈 separa 2px para que se vea completo */
}

table thead th{
  position: sticky;
  top: calc(var(--alto-navbar) + var(--thead-gap));
  z-index: 30;

  background-color: #e5efff;
  box-shadow: inset 0 -1px 0 #ccc;

  /* 👇 asegura que el texto no se corte */
  line-height: 1.2;
  padding-top: 12px;
  padding-bottom: 12px;
}
