/* ==========================================================================
   PIA UX & Tooltips System (v1.0.0)
   Estilos para Tooltips Flotantes, Glosario y Hojas Inferiores (Bottom Sheets)
   Paleta: Slate Profundo, Acentos Esmeralda/Cian, Toques Dorados de Marca
   ========================================================================== */

/* Término subrayado con tooltip */
.pia-tooltip-term {
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px dotted var(--color-cyan, #06b6d4);
  transition: all 0.2s ease;
  outline: none;
}

.pia-tooltip-term:hover,
.pia-tooltip-term:focus-visible {
  color: var(--color-cyan, #06b6d4);
  border-bottom-style: solid;
}

.pia-tooltip-term:focus-visible {
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.4);
  border-radius: 2px;
}

.pia-tooltip-trigger-icon {
  font-size: 0.78em;
  opacity: 0.7;
  color: var(--color-cyan, #06b6d4);
  font-weight: bold;
  vertical-align: super;
  margin-left: 2px;
  user-select: none;
}

.pia-tooltip-term:hover .pia-tooltip-trigger-icon {
  opacity: 1;
  transform: scale(1.15);
}

/* Tooltip Flotante Desktop */
.pia-tooltip-container {
  position: absolute;
  z-index: 9999;
  width: 320px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  will-change: transform, opacity;
}

.pia-tooltip-container.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Tarjeta de Contenido */
.pia-tooltip-card {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.7),
              0 0 0 1px rgba(6, 182, 212, 0.15);
  color: #f1f5f9;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.85rem;
  line-height: 1.45;
}

.pia-tooltip-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pia-tooltip-badge {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.pia-tooltip-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.pia-tooltip-section {
  margin-bottom: 8px;
}

.pia-tooltip-section:last-child {
  margin-bottom: 0;
}

.pia-tooltip-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: 2px;
}

.pia-tooltip-text {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.82rem;
}

/* Caja "En simple" (Resumen humano para 18 años) */
.pia-tooltip-simple-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 8px;
}

.pia-tooltip-simple-box .pia-tooltip-label {
  color: #34d399;
}

.pia-tooltip-simple-text {
  margin: 0;
  color: #e2e8f0;
  font-weight: 500;
  font-size: 0.82rem;
}

/* ==========================================================================
   Mobile Bottom Sheet (Modal Inferior Táctil)
   ========================================================================== */

.pia-bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pia-bottom-sheet-overlay.active {
  visibility: visible;
  opacity: 1;
}

.pia-bottom-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.pia-bottom-sheet-content {
  position: relative;
  width: 100%;
  max-height: 80vh;
  background: #0f172a;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 32px 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pia-bottom-sheet-overlay.active .pia-bottom-sheet-content {
  transform: translateY(0);
}

.pia-bottom-sheet-drag-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  margin: 0 auto 16px auto;
}

.pia-bottom-sheet-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
}

.pia-bottom-sheet-close:active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.pia-bottom-sheet-body .pia-tooltip-card {
  background: transparent;
  backdrop-filter: none;
  border: none;
  box-shadow: none;
  padding: 0;
}

.pia-bottom-sheet-body .pia-tooltip-title {
  font-size: 1.25rem;
}

.pia-bottom-sheet-body .pia-tooltip-text {
  font-size: 0.92rem;
  line-height: 1.5;
}

.pia-bottom-sheet-body .pia-tooltip-simple-text {
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ==========================================================================
   Reproductor modal accesible de video cápsulas pedagógicas (Plan 2026-09-20)
   ========================================================================== */

.pia-video-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.pia-video-modal-overlay.active {
  display: flex;
}

.pia-video-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 7, 13, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pia-video-modal-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 760px;
  background: var(--bg-surface-elevated, #111827);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(6, 182, 212, 0.15);
  overflow: hidden;
  animation: piaModalFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes piaModalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.pia-video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.pia-video-modal-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.14);
  color: var(--color-cyan, #06b6d4);
  white-space: nowrap;
}

.pia-video-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pia-video-modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
  outline: none;
  flex-shrink: 0;
}

.pia-video-modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.pia-video-modal-body {
  padding: 16px 20px 20px 20px;
}

.pia-video-player-wrapper {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
  background: #000;
}

.pia-video-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Botones de cápsula interactiva en tooltips, bottom sheets y tarjetas */
.pia-btn-capsula,
.pia-tooltip-video-btn,
.glosario-card-capsule-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--color-cyan, #06b6d4);
  cursor: pointer;
  transition: all 0.16s ease;
  text-decoration: none;
  line-height: 1.2;
}

.pia-btn-capsula:hover,
.pia-tooltip-video-btn:hover,
.glosario-card-capsule-btn:hover {
  background: rgba(6, 182, 212, 0.22);
  border-color: rgba(6, 182, 212, 0.55);
  transform: translateY(-1px);
  color: #ffffff;
}

.pia-tooltip-video-container {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
}

