/* ============================================================
   IFSE - Instituto de Formación en Salud y Emergencias
   Estilos personalizados, componentes y animaciones.
   La mayoría del layout se resuelve con Tailwind CSS (CDN).
============================================================ */

:root {
  --navy: #1b1e32;
  --navy-soft: #2a2e4a;
  --accent: #f25c05;
  --accent-red: #e61c0e;
  --clinical: #f8fafc;
  --border: #e2e8f0;
  --text: #475569;
}

/* ---------- Base ---------- */
html {
  scroll-behavior: smooth;
}

section[id] {
  scroll-margin-top: 6rem;
}

body {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
}

/* ============================================================
   NAVBAR
============================================================ */
#site-header.is-scrolled {
  box-shadow: 0 12px 30px -18px rgba(27, 30, 50, 0.35);
}

.nav-link {
  position: relative;
  border-radius: 0.5rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-link:hover {
  background-color: var(--clinical);
  color: var(--navy);
}

.mobile-link {
  display: block;
  border-radius: 0.625rem;
  padding: 0.7rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.mobile-link:hover {
  background-color: var(--clinical);
  color: var(--navy);
}

/* Animación del icono hamburguesa */
.menu-bar {
  transition: transform 0.3s ease, opacity 0.2s ease;
}

#menu-toggle[aria-expanded="true"] .menu-bar:nth-child(1) {
  transform: translateY(10px) rotate(45deg);
}

#menu-toggle[aria-expanded="true"] .menu-bar:nth-child(2) {
  opacity: 0;
}

#menu-toggle[aria-expanded="true"] .menu-bar:nth-child(3) {
  transform: translateY(-10px) rotate(-45deg);
}

#mobile-menu.menu-open {
  animation: menuSlide 0.25s ease both;
}

@keyframes menuSlide {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================
   BOTONES
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 0.8rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease,
    color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.btn svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background-image: linear-gradient(135deg, #f25c05, #e61c0e);
  color: #ffffff;
  box-shadow: 0 12px 24px -14px rgba(230, 28, 14, 0.85);
}

.btn-primary:hover {
  background-image: linear-gradient(135deg, #ff6a12, #f32614);
  transform: translateY(-1px);
  box-shadow: 0 16px 28px -14px rgba(230, 28, 14, 0.9);
}

.btn-primary:active {
  background-image: linear-gradient(135deg, #e05605, #d31a0d);
}

.btn-outline {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: var(--navy);
}

.btn-outline:hover {
  background-color: var(--clinical);
  border-color: var(--navy);
  color: var(--navy);
}

.btn-dark {
  background-color: var(--navy);
  color: #ffffff;
}

.btn-dark:hover {
  background-color: var(--navy-soft);
  transform: translateY(-1px);
  box-shadow: 0 14px 26px -16px rgba(27, 30, 50, 0.9);
}

.btn-lg {
  border-radius: 0.875rem;
  padding: 1rem 1.5rem;
  font-size: 0.9375rem;
}

.btn-sm {
  border-radius: 0.625rem;
  padding: 0.625rem 0.9rem;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

/* Botones compactos de las tarjetas de programa */
.btn-course {
  border-radius: 0.625rem;
  padding: 0.6rem 0.45rem;
  min-height: 2.5rem;
  font-size: 0.6875rem;
  line-height: 1.25;
  white-space: normal;
}

@media (min-width: 400px) {
  .btn-course {
    font-size: 0.75rem;
  }
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(242, 92, 5, 0.25);
}

/* ============================================================
   FORMULARIOS
============================================================ */
.field-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}

.field-input {
  display: block;
  width: 100%;
  height: 2.875rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background-color: var(--clinical);
  padding: 0 0.875rem;
  font-size: 0.875rem;
  color: #0f172a;
  transition: border-color 0.2s ease, box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.field-input::placeholder {
  color: #94a3b8;
}

.field-input:hover {
  border-color: #cbd5e1;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(242, 92, 5, 0.14);
}

textarea.field-input {
  height: auto;
  min-height: 5.5rem;
  padding: 0.75rem 0.875rem;
  resize: vertical;
}

/* Select con flecha personalizada (sin librerías) */
select.field-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.5rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 1rem;
}

/* Estado de error */
.input-invalid,
.input-invalid:hover {
  border-color: var(--accent-red);
  background-color: #fff5f4;
}

.input-invalid:focus {
  border-color: var(--accent-red);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(230, 28, 14, 0.12);
}

.field-error {
  display: none;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-red);
}

.field-error.is-visible {
  display: block;
  animation: alertIn 0.2s ease both;
}

/* Alertas de éxito */
.form-success {
  display: none;
}

.form-success.is-visible {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-bottom: 1rem;
  padding: 0.875rem 1rem;
  border: 1px solid rgba(242, 92, 5, 0.28);
  border-radius: 0.75rem;
  background-color: #fff7f1;
  color: var(--navy);
  font-size: 0.8125rem;
  line-height: 1.5;
  animation: alertIn 0.3s ease both;
}

.form-success strong {
  display: block;
  font-weight: 700;
  color: var(--accent-red);
}

.form-success svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  margin-top: 1px;
}

@keyframes alertIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================
   SECCIONES / COMPONENTES GENERALES
============================================================ */
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-red);
}

.section-eyebrow::before {
  content: "";
  width: 1.5rem;
  height: 2px;
  border-radius: 9999px;
  background-image: linear-gradient(90deg, var(--accent), var(--accent-red));
}

.hero-highlight {
  background-image: linear-gradient(
    transparent 68%,
    rgba(242, 92, 5, 0.2) 68%
  );
  background-repeat: no-repeat;
}

.status-dot {
  animation: pulseDot 2.4s infinite;
}

@keyframes pulseDot {
  0% {
    box-shadow: 0 0 0 0 rgba(242, 92, 5, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(242, 92, 5, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(242, 92, 5, 0);
  }
}

.hero-blob {
  animation: floatBlob 9s ease-in-out infinite;
}

.hero-blob-delay {
  animation-delay: -4.5s;
}

@keyframes floatBlob {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -14px, 0);
  }
}

/* ============================================================
   FILTROS Y TARJETAS DE PROGRAMAS
============================================================ */
.filter-btn {
  border: 1px solid var(--border);
  border-radius: 9999px;
  background-color: #ffffff;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.filter-btn:hover {
  border-color: #94a3b8;
  color: var(--navy);
}

.filter-btn.is-active {
  border-color: var(--navy);
  background-color: var(--navy);
  color: #ffffff;
  box-shadow: 0 10px 20px -12px rgba(27, 30, 50, 0.8);
}

.filter-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(242, 92, 5, 0.22);
}

.course-card.is-hidden {
  display: none;
}

.course-card.card-enter {
  animation: cardIn 0.35s ease both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================
   DIFERENCIALES
============================================================ */
.feature-card {
  border: 1px solid #f1f5f9;
  border-radius: 1rem;
  background-color: #ffffff;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.3s ease, box-shadow 0.3s ease,
    border-color 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: rgba(242, 92, 5, 0.28);
  box-shadow: 0 22px 40px -24px rgba(27, 30, 50, 0.35);
}

.icon-tile {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.875rem;
}

.icon-tile svg {
  width: 1.5rem;
  height: 1.5rem;
}

.icon-tile-sm {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 0.75rem;
}

.icon-tile-sm svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ============================================================
   CERTIFICACIÓN
============================================================ */
.cert-grid {
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.55) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 1px, transparent 1px);
  background-size: 48px 48px;
}

.diploma-card {
  transform: rotate(-1.2deg);
  transition: transform 0.4s ease;
}

.diploma-card:hover {
  transform: rotate(0deg) translateY(-3px);
}

.validator-box {
  display: none;
}

.validator-box.is-visible {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-top: 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 0.75rem 0.875rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  animation: alertIn 0.3s ease both;
}

.validator-box svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.validator-box strong {
  display: block;
  margin-bottom: 0.125rem;
  font-weight: 700;
}

.validator-success {
  border-color: rgba(242, 92, 5, 0.28);
  background-color: #fff7f1;
  color: var(--navy);
}

.validator-success strong {
  color: var(--accent-red);
}

.validator-error {
  border-color: rgba(230, 28, 14, 0.28);
  background-color: #fff5f4;
  color: #9b1c14;
}

/* ============================================================
   TESTIMONIOS Y GALERÍA
============================================================ */
.testimonial-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background-color: #ffffff;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.testimonial-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 40px -26px rgba(27, 30, 50, 0.4);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 132px;
  gap: 0.75rem;
}

.gallery-tile {
  position: relative;
  overflow: hidden;
  border-radius: 1rem;
  background-image: linear-gradient(135deg, var(--navy), var(--navy-soft));
}

.gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.gallery-tile:hover img {
  transform: scale(1.05);
}

.gallery-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(27, 30, 50, 0.82),
    rgba(27, 30, 50, 0.08) 55%,
    transparent
  );
  transition: opacity 0.3s ease;
}

.gallery-tile figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  padding: 0.9rem;
  color: #ffffff;
}

.gallery-tile figcaption span {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
}

.gallery-tile figcaption small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.6875rem;
  color: #cbd5e1;
}

.gallery-feature {
  grid-column: span 2;
  grid-row: span 2;
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 150px;
    gap: 0.875rem;
  }
}

/* ============================================================
   CONTACTO
============================================================ */
.contact-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background-color: #ffffff;
  padding: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease,
    transform 0.2s ease;
}

.contact-card:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 92, 5, 0.3);
  box-shadow: 0 14px 28px -22px rgba(27, 30, 50, 0.4);
}

/* ============================================================
   FOOTER
============================================================ */
.footer-link {
  color: #94a3b8;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: #ffffff;
}

.social-link {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.625rem;
  background-color: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, transform 0.2s ease;
}

.social-link:hover {
  transform: translateY(-2px);
  border-color: transparent;
  background-image: linear-gradient(135deg, #f25c05, #e61c0e);
  color: #ffffff;
}

.social-link svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* ============================================================
   WHATSAPP FLOTANTE
============================================================ */
.whatsapp-float {
  background-image: linear-gradient(135deg, #f25c05, #e61c0e);
  animation: waPulse 2.8s infinite;
}

.whatsapp-float:hover {
  transform: scale(1.06);
}

.whatsapp-tooltip {
  position: absolute;
  right: calc(100% + 0.75rem);
  top: 50%;
  transform: translateY(-50%) translateX(0.25rem);
  opacity: 0;
  pointer-events: none;
  border-radius: 0.5rem;
  background-color: var(--navy);
  padding: 0.45rem 0.7rem;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 24px -12px rgba(27, 30, 50, 0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.whatsapp-float:hover .whatsapp-tooltip,
.whatsapp-float:focus-visible .whatsapp-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

@keyframes waPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(242, 92, 5, 0.45),
      0 18px 35px -12px rgba(27, 30, 50, 0.5);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(242, 92, 5, 0),
      0 18px 35px -12px rgba(27, 30, 50, 0.5);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(242, 92, 5, 0),
      0 18px 35px -12px rgba(27, 30, 50, 0.5);
  }
}

/* ============================================================
   MODAL DE TEMARIOS
============================================================ */
#course-modal {
  display: none;
}

#course-modal.is-open {
  display: flex;
  animation: modalFade 0.2s ease both;
}

.modal-panel {
  animation: modalIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes modalFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body.no-scroll {
  overflow: hidden;
}

/* Elementos del listado de módulos generados desde JS */
.module-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid #f1f5f9;
  border-radius: 0.75rem;
  background-color: var(--clinical);
  padding: 0.7rem 0.8rem;
}

.module-number {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background-color: var(--navy);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
}

.module-text {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  color: #334155;
}

/* ============================================================
   RESPONSIVE / ACCESIBILIDAD
============================================================ */
@media (max-width: 640px) {
  .whatsapp-tooltip {
    display: none;
  }

  .diploma-card {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
