/* ============================================================
   HORARIOZONTAL - FRONTEND CSS v3.1
   ============================================================ */

/* 1. Variables Globales */
:root {
  --hrz-primary: #007cba;
  --hrz-primary-dark: #005a87;
  --hrz-danger: #e74c3c;
  --hrz-text-dark: #2c3e50;
  --hrz-text-muted: #7f8c8d;
  --hrz-border-light: #e9ecef;
  --hrz-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --hrz-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
  --hrz-radius: 16px;
  --hrz-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Prevención de Desbordamiento */
.hrz-live-container,
.hrz-full-schedule-tabs,
.hrz-days-content,
.hrz-programs-grid {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

.hrz-program-image,
.hrz-mini-image,
.hrz-card-image,
.hrz-program-thumbnail {
  max-width: 100% !important;
  height: auto !important;
}

/* 3. Programa en Vivo */
.hrz-live-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  padding: clamp(18px, 3vw, 40px);
  border-radius: var(--hrz-radius);
  background: #ffffff;
  box-shadow: var(--hrz-shadow);
  margin: 20px 0;
  position: relative;
  overflow: hidden;
}

.hrz-current-program {
  display: flex;
  flex: 1 1 380px;
  align-items: center;
  gap: clamp(14px, 2.5vw, 30px);
  min-width: 0;
  position: relative;
  max-width: 100%;
}

.hrz-program-image-container {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.hrz-program-image {
  width: clamp(110px, 13vw, 160px);
  height: clamp(110px, 13vw, 160px);
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  border: 3px solid #ffffff;
  display: block;
  transition: var(--hrz-transition);
}

.hrz-program-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
}

.hrz-program-info h3 {
  margin: 0;
  font-size: clamp(1.2em, 2.5vw, 1.55em);
  font-weight: 700;
  line-height: 1.2;
  color: var(--hrz-text-dark);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.hrz-program-host,
.hrz-program-time {
  margin: 0;
  font-size: clamp(0.82em, 1.5vw, 0.93em);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Badge En Vivo */
.hrz-live-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--hrz-danger);
  color: #ffffff;
  padding: 7px 16px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  width: fit-content;
  margin-top: 6px;
  animation: hrzPulse 2s ease-in-out infinite;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35);
  cursor: default;
}

.hrz-live-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #ffffff;
  border-radius: 50%;
  animation: hrzDotPulse 1.5s ease-in-out infinite;
}

/* Proximos Programas */
.hrz-next-programs {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 200px;
  flex: 0 1 240px;
  background: rgba(0, 0, 0, 0.025);
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--hrz-border-light);
}

.hrz-next-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hrz-mini-image {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  border: 2px solid #f0f0f0;
  background: #f8f9fa;
  transition: transform 0.2s ease;
}

.hrz-next-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hrz-next-label {
  font-size: 0.72em;
  color: var(--hrz-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.hrz-next-title {
  font-weight: 700;
  color: var(--hrz-text-dark);
  font-size: 0.92em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.hrz-next-time {
  font-size: 0.78em;
  color: var(--hrz-text-muted);
  font-weight: 500;
}

/* 4. Oyentes */
.hrz-listeners {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85em;
  color: var(--hrz-text-muted);
  margin-top: 4px;
}

.hrz-listeners-icon { font-size: 1.1em; }
#hrz-listeners-number { font-weight: 700; color: var(--hrz-text-dark); }

/* 5. Programacion Completa y Tabs */
.hrz-full-schedule-tabs {
  background: #ffffff;
  border-radius: var(--hrz-radius);
  box-shadow: var(--hrz-shadow);
  overflow: hidden;
  margin-top: 24px;
}

.hrz-days-navigation {
  display: flex;
  background: #ffffff;
  border-bottom: 2px solid var(--hrz-border-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  position: relative;
  z-index: 5;
  padding: 0 4px;
}

.hrz-days-navigation::-webkit-scrollbar { height: 5px; }
.hrz-days-navigation::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }

.hrz-day-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 80px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 600;
  color: #6c757d;
  transition: var(--hrz-transition);
  font-size: clamp(0.8em, 1.5vw, 0.95em);
  white-space: nowrap;
  flex: 0 0 auto;
  text-align: center;
}

.hrz-day-tab:hover { background: #f8f9fa; color: #495057; }
.hrz-day-tab.active {
  color: var(--hrz-primary);
  border-bottom-color: var(--hrz-primary);
  background: rgba(0, 124, 186, 0.04);
}

.hrz-hoy-badge {
  display: inline-block;
  background: var(--hrz-danger);
  color: #ffffff;
  font-size: 0.6em;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
  vertical-align: middle;
  line-height: 1;
}

.hrz-days-content {
  padding: clamp(16px, 3vw, 28px);
  overflow: hidden;
}

.hrz-day-content {
  display: none;
  animation: hrzFadeIn 0.4s ease;
}
.hrz-day-content.active { display: block; }

.hrz-day-title {
  font-size: clamp(1.1em, 3vw, 1.6em);
  font-weight: 700;
  margin: 0 0 18px 0;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--hrz-primary);
  color: var(--hrz-text-dark);
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================================
   SCROLL HORIZONTAL - MEJORADO
   ============================================================ */

.hrz-programs-grid {
  display: flex;
  gap: clamp(12px, 2vw, 18px);
  overflow-x: auto;
  overflow-y: visible;
  padding: 20px 10px 30px 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--hrz-primary) #f1f3f5;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}

.hrz-programs-grid:active { cursor: grabbing; }

.hrz-programs-grid::-webkit-scrollbar {
  height: 10px;
  -webkit-appearance: none;
}

.hrz-programs-grid::-webkit-scrollbar-track {
  background: #f1f3f5;
  border-radius: 10px;
  margin: 0 20px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.hrz-programs-grid::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--hrz-primary), var(--hrz-primary-dark));
  border-radius: 10px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.hrz-programs-grid::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, var(--hrz-primary-dark), #003d66);
  box-shadow: 0 4px 12px rgba(0, 124, 186, 0.5);
}

/* 7. Tarjetas de Programa */
.hrz-program-card {
  flex: 0 0 auto;
  width: clamp(240px, 30vw, 340px);
  background: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  border: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  scroll-snap-align: start;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
}

.hrz-program-card .hrz-card-content,
.hrz-program-card .hrz-card-image {
  pointer-events: none;
}

.hrz-program-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--hrz-shadow-hover);
}

.hrz-program-current {
  border: 2px solid var(--hrz-danger);
  box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.12), 0 6px 24px rgba(0, 0, 0, 0.1);
  position: sticky;
  left: 0;
  z-index: 10;
  scroll-snap-align: start;
}

/* Programas Finalizados */
.hrz-program-finished {
  opacity: 0.6;
  filter: grayscale(40%);
  background: rgba(0, 0, 0, 0.03);
}

.hrz-program-finished::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  z-index: 2;
  pointer-events: none;
}

.hrz-program-finished .hrz-card-image { filter: grayscale(60%); }

.hrz-program-finished::after {
  content: 'FINALIZADO';
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.6em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 3;
}

/* Contenido de Tarjeta */
.hrz-card-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: center;
  display: block;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.hrz-card-content {
  padding: clamp(12px, 2vw, 16px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: center;
  flex: 1;
}

.hrz-card-content h3 {
  margin: 0;
  font-size: clamp(0.95rem, 1.8vw, 1.15em);
  font-weight: 700;
  line-height: 1.25;
  color: var(--hrz-text-dark);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.hrz-conductor {
  margin: 0;
  font-size: clamp(0.75rem, 1.5vw, 0.88em);
  font-weight: 500;
  color: #555555;
}

.hrz-time {
  margin: 0;
  font-size: clamp(0.75rem, 1.5vw, 0.85em);
  font-weight: 600;
  color: var(--hrz-primary);
}

.hrz-description {
  margin: 4px 0 0;
  font-size: clamp(0.7rem, 1.4vw, 0.82em);
  line-height: 1.45;
  color: #666666;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 8. Badges "En Vivo" en Tarjetas */
.hrz-live-badge-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e74c3c;
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(231, 76, 60, 0.4);
  animation: hrzPulse 1.5s ease-in-out infinite;
}

.hrz-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ffffff;
  border-radius: 50%;
  animation: hrzDotPulse 1s ease-in-out infinite;
}

.hrz-day-content:not(.active) .hrz-live-badge-card { display: none !important; }
.hrz-day-content:not(.active) .hrz-program-current {
  border-color: #f0f0f0 !important;
  box-shadow: none !important;
}

/* 9. Miscelaneos */
.hrz-no-programs {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
  font-size: 1em;
  background: #f8f9fa;
  border-radius: 12px;
  border: 2px dashed #dee2e6;
}

.hrz-schedule-footer {
  display: flex;
  justify-content: space-between;
  padding: 12px 20px;
  font-size: 12px;
  color: #6c757d;
  border-top: 1px solid var(--hrz-border-light);
  background: #f8f9fa;
  flex-wrap: wrap;
  gap: 8px;
}

/* 10. Animaciones */
@keyframes hrzPulse {
  0%, 100% {
    box-shadow: 0 4px 16px rgba(231, 76, 60, 0.4), 0 0 0 0 rgba(231, 76, 60, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 6px 24px rgba(231, 76, 60, 0.6), 0 0 0 10px rgba(231, 76, 60, 0);
    transform: scale(1.02);
  }
}

@keyframes hrzDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.2; transform: scale(0.6); }
}

@keyframes hrzFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   11. DISENO RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  .hrz-program-card { width: clamp(220px, 40vw, 300px); }
}

@media (max-width: 767px) {
  .hrz-live-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px;
    gap: 16px;
  }
  .hrz-current-program {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .hrz-program-info {
    align-items: center;
    width: 100%;
  }
  .hrz-next-programs {
    width: 100%;
    flex: 1 1 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 12px;
    gap: 12px;
  }
  .hrz-next-item {
    flex: 1 1 45%;
    min-width: 120px;
    text-align: left;
  }
  .hrz-program-card { width: clamp(200px, 75vw, 280px); }
  .hrz-days-content { padding: 12px 8px; }
  .hrz-day-tab {
    min-width: 60px;
    padding: 10px;
    font-size: 0.8em;
  }
  .hrz-programs-grid {
    padding: 15px 6px 25px 6px;
    gap: 10px;
  }
  .hrz-programs-grid::-webkit-scrollbar { height: 6px; }
  .hrz-programs-grid::-webkit-scrollbar-track { margin: 0 10px; }
}

@media (max-width: 480px) {
  .hrz-live-container { padding: 12px; }
  .hrz-program-image { width: 90px; height: 90px; }
  .hrz-program-info h3 { font-size: 1em; }
  .hrz-next-item { flex: 1 1 100%; }
  .hrz-mini-image { width: 36px; height: 36px; }
  .hrz-program-card { width: 80vw; max-width: 280px; }
  .hrz-card-content { padding: 10px; gap: 3px; }
  .hrz-description { -webkit-line-clamp: 2; }
  .hrz-live-badge-card {
    top: 6px;
    left: 6px;
    font-size: 0.6em;
    padding: 3px 8px;
  }
  .hrz-program-finished::after {
    font-size: 0.5em;
    padding: 2px 6px;
    top: 8px;
    right: 8px;
  }
  .hrz-programs-grid {
    padding: 10px 4px 20px 4px;
    gap: 8px;
  }
}

/* ============================================================
   AJUSTE FULL-SCHEDULE - IMÁGENES COMPLETAS
   ============================================================ */

/* `fill` adapta cada imagen exactamente al contenedor, permitiendo deformación. */
.hrz-full-schedule-tabs .hrz-program-card .hrz-card-image,
.hrz-full-schedule-tabs .hrz-program-card .hrz-program-thumbnail {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 10 !important;
  object-fit: fill !important;
  object-position: center !important;
  box-sizing: border-box !important;
  background: #f8f9fa !important;
}

/* Compatibilidad con posibles envoltorios de imagen. */
.hrz-full-schedule-tabs .hrz-program-card .hrz-card-image-container,
.hrz-full-schedule-tabs .hrz-program-card .hrz-thumbnail-container {
  width: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

@media (max-width: 767px) {
  .hrz-full-schedule-tabs .hrz-program-card .hrz-card-image,
  .hrz-full-schedule-tabs .hrz-program-card .hrz-program-thumbnail {
    width: 100% !important;
    aspect-ratio: 16 / 10 !important;
    object-fit: fill !important;
  }
}

/* ============================================================
   AJUSTE MÓVIL - PROGRAMA EN VIVO NO FIJO
   ============================================================ */

/* En pantallas pequeñas, la tarjeta en vivo forma parte del flujo normal
   y no bloquea las demás tarjetas de programación. */
@media (max-width: 767px) {
  .hrz-full-schedule-tabs .hrz-program-current,
  .hrz-full-schedule-tabs .hrz-program-card.hrz-program-current {
    position: static !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
    scroll-snap-align: start !important;
  }
}

@media (max-width: 480px) {
  .hrz-full-schedule-tabs .hrz-program-current,
  .hrz-full-schedule-tabs .hrz-program-card.hrz-program-current {
    position: static !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
  }
}

/* ============================================================
   AJUSTE MÓVIL - LIVE_PROGRAM COMPACTO
   ============================================================ */

@media (max-width: 767px) {
  .hrz-live-container {
    padding: 8px !important;
    gap: 6px !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
  }

  .hrz-current-program {
    gap: 4px !important;
    margin: 0 !important;
  }

  .hrz-next-programs {
    gap: 6px !important;
    padding: 6px !important;
    margin: 0 !important;
  }

  .hrz-next-item {
    gap: 6px !important;
    margin: 0 !important;
  }
}

@media (max-width: 480px) {
  .hrz-live-container {
    padding: 6px !important;
    gap: 4px !important;
  }

  .hrz-current-program {
    gap: 2px !important;
  }

  .hrz-next-programs {
    gap: 4px !important;
    padding: 4px !important;
  }

  .hrz-next-item {
    gap: 4px !important;
  }
}
