/* ============================================
   SAF Radio Player - Fixed Right Center
   ============================================ */

.saf-radio-player {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: row;
  align-items: center;
}

/* Toggle Button */
.radio-toggle-btn {
  position: relative;
  width: 48px;
  height: 48px;
  background: #000;
  color: #73c5eb;
  border: 2px solid #000;
  border-right: none;
  border-radius: 8px 0 0 8px;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
}

.radio-toggle-btn:hover {
  background: #333;
}

.radio-toggle-btn.is-playing {
  background: #000;
}

.radio-toggle-btn.is-playing:hover {
  background: #333;
}

.radio-toggle-btn.is-playing .radio-icon {
  color: #39b54a;
  animation: iconPulse 1.5s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
}

/* Pulse animation when playing */
.radio-icon-pulse {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 8px 0 0 8px;
  animation: none;
  pointer-events: none;
}

.radio-toggle-btn.is-playing .radio-icon-pulse {
  animation: radioPulse 2s ease-in-out infinite;
}

@keyframes radioPulse {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* Panel */
.radio-panel {
  width: 85px;
  background: #000;
  color: #73c5eb;
  border: 2px solid #000;
  border-right: none;
  border-radius: 0;
  box-sizing: border-box;
  box-shadow: none;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  transform: translateX(100%) translateY(-50%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 50%;
}

.radio-panel.is-open {
  transform: translateX(0) translateY(-50%);
  opacity: 1;
  pointer-events: all;
}

/* When panel is open, hide toggle */
.saf-radio-player.panel-open .radio-toggle-btn {
  transform: translateX(-85px);
}

/* Panel Header - Vertical text */
.radio-panel-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  writing-mode: vertical-rl;
  transform: rotate(360deg);
  min-height: 220px;
}

/* Station logo (replaces the old "SAF RADIO" text) */
.radio-station-name {
  display: block;
  line-height: 0;
  text-decoration: none;
}

/* Fit the logo inside the narrow vertical panel. Both max dimensions are set
   with auto width/height so each logo scales down to satisfy both constraints
   while preserving its own aspect ratio (the EN logo is a tall strip, the AR
   logo is near-square). Overrides the global `img { width: 100% }` rule. */
.radio-station-name img {
  display: block;
  width: auto;
  height: auto;
  max-width: 64px;
  max-height: 230px;
  object-fit: contain;
}

/* Status Badge */
.radio-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #73c5eb;
  white-space: nowrap;
  /* Read horizontally even though the header uses vertical writing-mode. */
  writing-mode: horizontal-tb;
}

.radio-status-badge.is-live {
  border-color: #73c5eb;
}

.radio-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}

.radio-status-badge.is-live .radio-status-dot {
  background: #39b54a;
  animation: dotPulse 1.5s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(57, 181, 74, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(57, 181, 74, 0); }
}

.radio-status-text {
  font-family: 'FranklinGothicBook', 'Franklin Gothic Book', sans-serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #73c5eb;
}

.radio-status-badge.is-live .radio-status-text {
  color: #73c5eb;
}

/* Separator */
.radio-controls-separator {
  width: 100%;
  height: 1px;
  background: #73c5eb;
  margin-bottom: 12px;
}

/* Controls */
.radio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
}

.radio-play-btn {
  width: 48px;
  height: 48px;
  background: #000;
  color: #73c5eb;
  border: 1px solid #73c5eb;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.radio-play-btn:hover {
  background: #333;
  transform: scale(1.05);
}

.radio-play-btn:active {
  transform: scale(0.95);
}

.radio-play-btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

/* Play button wrapper */
.radio-play-wrap {
  position: relative;
  display: inline-block;
}

/* Tooltip */
.radio-tooltip {
  display: none;
  position: absolute;
  top: 50%;
  right: calc(100% + 10px);
  transform: translateY(-50%);
  background: #000;
  color: #fff;
  font-family: 'FranklinGothicBook', 'Franklin Gothic Book', sans-serif;
  font-size: 1rem;
  line-height: 1.3;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: normal;
  width: max-content;
  max-width: 300px;
  pointer-events: none;
  z-index: 10;
}

.radio-tooltip::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #000;
}

.radio-play-wrap:hover .radio-tooltip.has-track {
  display: block;
}

/* Loading Spinner */
.radio-loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 3px solid rgba(115, 197, 235, 0.3);
  border-top-color: #73c5eb;
  border-radius: 50%;
  animation: radioSpin 0.7s linear infinite;
}

@keyframes radioSpin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* RTL Support */
html[dir="rtl"] .saf-radio-player {
  right: auto;
  left: 0;
}

/* In the vertical-rl header the flex row runs bottom-to-top under RTL, which
   drops the logo below the ON/OFF badge. Reverse it so the logo sits on top,
   matching the English layout. space-between pushes the (short) Arabic logo to
   the top and the ON/OFF badge to the bottom, just above the separator. */
html[dir="rtl"] .radio-panel-header {
  flex-direction: row-reverse;
  justify-content: space-between;
}

/* A little breathing room above the Arabic logo only. */
html[dir="rtl"] .radio-station-name {
  padding-top: 12px;
}

html[dir="rtl"] .radio-toggle-btn {
  border-right: 2px solid #000;
  border-left: none;
  border-radius: 0 8px 8px 0;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

html[dir="rtl"] .radio-icon-pulse {
  border-radius: 0 8px 8px 0;
}

html[dir="rtl"] .radio-panel {
  border-right: 2px solid #000;
  border-left: none;
  border-radius: 0;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
  right: auto;
  left: 0;
  transform: translateX(-100%) translateY(-50%);
}

html[dir="rtl"] .radio-panel.is-open {
  transform: translateX(0) translateY(-50%);
}

html[dir="rtl"] .saf-radio-player.panel-open .radio-toggle-btn {
  transform: translateX(85px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .radio-toggle-btn {
    width: 40px;
    height: 40px;
  }

  .radio-toggle-btn .radio-icon {
    width: 18px;
    height: 18px;
  }

  html[dir="rtl"] .saf-radio-player.panel-open .radio-toggle-btn {
    transform: translateX(85px);
  }

  .saf-radio-player.panel-open .radio-toggle-btn {
    transform: translateX(-85px);
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .radio-toggle-btn {
    width: 36px;
    height: 36px;
  }

  .radio-toggle-btn .radio-icon {
    width: 16px;
    height: 16px;
  }

  .saf-radio-player.panel-open .radio-toggle-btn {
    transform: translateX(-85px);
  }

  html[dir="rtl"] .saf-radio-player.panel-open .radio-toggle-btn {
    transform: translateX(85px);
  }
}
