/* Estilos para la tabla de detalle */
.detalle-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Contenedor principal del modal */
.detalle-modal-content {
  position: relative;
  background: linear-gradient(135deg,#ffffff,#f7f9fc);
  padding: clamp(1rem, 3vw, 1.75rem) clamp(.9rem, 3.5vw, 1.75rem) clamp(1.1rem, 3.5vw, 2.1rem);
  border-radius: 18px;
  width: min(660px, 90vw);
  max-width: calc(100vw - 2rem);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 28px rgba(0,0,0,0.24), 0 4px 12px rgba(0,0,0,0.12);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-sizing: border-box;
}
.detalle-modal-content::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 18px;
  mix-blend-mode: overlay;
}
.detalle-modal-content * { box-sizing: border-box; }

.detalle-modal-table-wrapper {
  position: relative;
  margin-top: .55rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto; /* 🔹 Siempre permitir scroll horizontal */
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  padding-right: .25rem;
  max-height: calc(82vh - 140px);
  background: linear-gradient(#ffffff,#ffffff) padding-box;
}
.detalle-modal-table-wrapper::after {
  content: "";
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255,255,255,0), #ffffff 70%);
}
.detalle-modal-table-wrapper::-webkit-scrollbar { width: 8px; height: 8px; }
.detalle-modal-table-wrapper::-webkit-scrollbar-track { background: transparent; }
.detalle-modal-table-wrapper::-webkit-scrollbar-thumb { background: #b0b9c5; border-radius: 4px; }
.detalle-modal-table-wrapper::-webkit-scrollbar-thumb:hover { background: #88939f; }

.detalle-modal-content h3 {
  margin-top: 0;
}
.detalle-modal-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: .55rem;
  font-size: clamp(.72rem, 2.9vw, .85rem);
  table-layout: fixed;
  overflow-wrap: anywhere;
  max-width: 100%;
  min-width: 600px; /* 🔹 fuerza scroll en pantallas pequeñas */
}
.detalle-modal-content th, .detalle-modal-content td {
  border: 1px solid #e2e6f0;
  padding: .5rem .65rem;
  text-align: left;
  line-height: 1.25;
}
.detalle-modal-content th {
  background: linear-gradient(120deg,#eef2f7,#e2e8f0);
  font-weight: 600;
  letter-spacing: .5px;
  color: #334155;
  position: sticky;
  top: 0;
  z-index: 1;
}
.detalle-modal-content tbody tr:nth-child(even) {
  background: #f8fafc;
}
.detalle-modal-content tbody tr:hover {
  background: #eef6ff;
}
.detalle-modal-close {
  position: absolute;
  top: .65rem;
  right: .65rem;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 0;
  background: linear-gradient(135deg,#ff7a7a,#e03131);
  box-shadow: 0 4px 12px -2px rgba(224,49,49,.55), 0 2px 4px rgba(0,0,0,.18);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .3s ease;
}
.detalle-modal-close:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px -2px rgba(224,49,49,.6), 0 3px 6px rgba(0,0,0,.22);
}
.detalle-modal-close:active {
  transform: translateY(0) scale(.95);
  box-shadow: 0 3px 10px -2px rgba(224,49,49,.55), 0 2px 4px rgba(0,0,0,.2);
}
.detalle-modal-close:focus-visible {
  outline: 3px solid #94a3b8;
  outline-offset: 2px;
}

/* Scroll interno para tabla si crece */
.detalle-modal-content > table, .detalle-modal-content .tabla-wrapper {
  overflow-y: auto;
}

/* 📱 Ajustes en móviles */
@media (max-width: 600px) {
  .detalle-modal {
    padding: 0.5rem;
    align-items: flex-start;
  }

  .detalle-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 1rem);
    border-radius: 12px;
    padding: 0.75rem 0.75rem 1rem;
  }

  .detalle-modal-table-wrapper {
    max-height: calc(100dvh - 160px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .detalle-modal-content table {
    min-width: 450px;
  }

  .detalle-modal-content h3 {
    font-size: 1rem;
    padding-right: 2.5rem;
  }

  .detalle-modal-close {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    top: 0.4rem;
    right: 0.4rem;
    border-radius: 8px;
  }

  .detalle-modal-content th, 
  .detalle-modal-content td {
    padding: .4rem .5rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 380px) {
  .detalle-modal-content {
    padding: .9rem .8rem 1.3rem;
  }
  .detalle-modal-close {
    width: 32px;
    height: 32px;
    font-size: 1.15rem;
  }
  .detalle-modal-table-wrapper {
    max-height: calc(100dvh - 165px);
  }
}

@media (max-width: 360px) {
  .detalle-modal-content td { font-size: .72rem; }
  .detalle-modal-table-wrapper { max-height: calc(100dvh - 155px); }
}
