/* ═══════════════════════════════════════════════════════════════════════
   css/popover.css
   Popover "Estructura de datos" con descargas.
   ═══════════════════════════════════════════════════════════════════════ */

.data-structure-wrapper {
  position: relative;
  display: inline-block;
}

.data-structure-popover {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  width: 340px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.data-structure-popover.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.data-structure-popover::before {
  /* Flechita */
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  border-left: 1px solid #e2e8f0;
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
}

.popover-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.popover-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #64748b;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}

.popover-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.popover-body {
  padding: 16px 18px 18px;
}

.popover-intro {
  margin: 0 0 14px;
  font-size: 13px;
  color: #475569;
  line-height: 1.55;
}

.popover-example {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.popover-example-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.popover-example-csv {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: #334155;
  white-space: pre;
  overflow-x: auto;
}

.popover-downloads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.popover-download-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  color: #1e293b;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.popover-download-btn:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  text-decoration: none;
}

.popover-download-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.popover-download-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.popover-download-text strong {
  font-size: 11.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popover-download-text small {
  font-size: 10px;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.popover-guide-link {
  display: block;
  text-align: center;
  font-size: 12.5px;
  color: #3b82f6;
  text-decoration: none;
  font-weight: 600;
  padding: 8px 0 2px;
  border-top: 1px solid #f1f5f9;
  margin-top: 6px;
}

.popover-guide-link:hover {
  text-decoration: underline;
}

/* En móvil, el popover se centra en la pantalla */
@media (max-width: 640px) {
  .data-structure-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: calc(100vw - 24px);
    max-width: 400px;
  }
  .data-structure-popover.is-open {
    transform: translate(-50%, -50%) scale(1);
  }
  .data-structure-popover::before {
    display: none;
  }
}

/* Fix overflow de los botones dentro del popover */
.popover-downloads {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 8px !important;
  width: 100% !important;
  box-sizing: border-box;
}

.popover-download-btn {
  min-width: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
  overflow: hidden;
}

.popover-download-text {
  min-width: 0;
  overflow: hidden;
}

.popover-download-text strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}