/**
 * SASHA - Tema Default
 * 
 * Tema di default per il player Sasha con aspect ratio 3.45:1 (slim)
 * Design moderno con play button in overlay e controlli accattivanti
 * Template HTML incluso nel tema per massima flessibilità
 */

:host {
  display: block;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  
  /* CSS Custom Properties del tema - OBBLIGATORIE da v2.4.0+ */
  --sasha-bg-color: #1a1a2e;
  --sasha-accent-color: #00d4ff;
  --sasha-text-color: #ffffff;
  --sasha-waveform-color: #00d4ff;
  --sasha-waveform-background-color: rgba(0, 212, 255, 0.1);
}

.sasha-container {
  background: var(--sasha-bg-color, #1a1a2e);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  position: relative;
  width: 100%;
  min-height: 180px;
  display: flex;
  flex-direction: row;
  align-items: stretch; /* assicura che cover e content si estendano */
}

/* Cover con play button in overlay */
.sasha-cover {
  position: relative;
  width: 35%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  overflow: hidden;
  flex-shrink: 0;
}

.sasha-cover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Play button in overlay - grande ed evidente */
.sasha-btn-play-overlay {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 80px;
  height: 80px;
  background: color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 25%, transparent);
  backdrop-filter: blur(10px);
  border: 2px solid color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 60%, transparent);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 40%, transparent), 
              0 0 0 0 color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 70%, transparent);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  color: #ffffff;
  animation: pulse 2s infinite;
}

.sasha-btn-play-overlay:hover {
  transform: translateY(-50%) scale(1.1);
  background: color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 35%, transparent);
  border-color: color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 80%, transparent);
  box-shadow: 0 6px 28px color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 60%, transparent), 
              0 0 0 8px color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 20%, transparent);
}

.sasha-btn-play-overlay:active {
  transform: translateY(-50%) scale(0.95);
}

/* Icone play/pause */
.sasha-btn-play-overlay .play-icon,
.sasha-btn-play-overlay .pause-icon {
  position: absolute;
  transition: all 0.3s ease;
}

/* Stato di default: mostra play, nascondi pause */
.sasha-btn-play-overlay .play-icon {
  opacity: 1;
  transform: scale(1);
}

.sasha-btn-play-overlay .pause-icon {
  opacity: 0;
  transform: scale(0.5);
}

/* Stato playing: nascondi play, mostra pause */
.sasha-container.playing .sasha-btn-play-overlay .play-icon {
  opacity: 0;
  transform: scale(0.5);
}

.sasha-container.playing .sasha-btn-play-overlay .pause-icon {
  opacity: 1;
  transform: scale(1);
}

.sasha-container.playing .sasha-btn-play-overlay {
  animation: none;
}

/* Animazione pulse per play button */
@keyframes pulse {
  0% {
    box-shadow: 0 4px 20px color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 40%, transparent), 
                0 0 0 0 color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 70%, transparent);
  }
  50% {
    box-shadow: 0 4px 20px color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 40%, transparent), 
                0 0 0 12px transparent;
  }
  100% {
    box-shadow: 0 4px 20px color-mix(in srgb, var(--sasha-accent-color, #00d4ff) 40%, transparent), 
                0 0 0 0 transparent;
  }
}

.sasha-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  min-width: 0;
  justify-content: space-between;
}

.sasha-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--sasha-text-color, #ffffff);
  margin-bottom: 12px;
}

.sasha-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--sasha-text-color, #ffffff);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.sasha-subtitle {
  font-size: 14px;
  opacity: 0.75;
  margin: 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* Sponsor logo in alto a destra */
.sasha-sponsor {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-decoration: none;
  z-index: 20;
  transition: all 0.3s ease;
}

.sasha-sponsor:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.sasha-sponsor-claim {
  font-size: 10px;
  color: var(--sasha-text-color, #ffffff);
  opacity: 0.85;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sasha-sponsor-logo {
  max-height: 32px;
  max-width: 120px;
  height: auto;
  width: auto;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 8px;
  border-radius: 6px;
}

.sasha-status {
  text-align: center;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--sasha-accent-color, #00d4ff);
  font-weight: 600;
  background: rgba(0, 212, 255, 0.15);
  border-radius: 6px;
  margin-bottom: 10px;
  display: none;
}

.sasha-waveform {
  width: 100%;
  height: 48px;
  background: var(--sasha-waveform-bg, rgba(0, 212, 255, 0.1));
  border-radius: 8px;
  flex-shrink: 0;
}

/* Riga con waveform e controlli a destra */
.sasha-waveform-row {
  display: grid;
  grid-template-columns: 2fr 3fr; /* waveform molto più stretta, controlli hanno più spazio */
  align-items: center;
  gap: 16px;
  margin: 12px 0;
}

.sasha-right-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.sasha-right-controls .sasha-volume-slider {
  width: 120px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sasha-right-controls .sasha-volume-slider:hover {
  height: 5px;
}

.sasha-right-controls .sasha-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--sasha-accent-color, #00d4ff);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.5);
  transition: all 0.2s ease;
}

.sasha-right-controls .sasha-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.sasha-right-controls .sasha-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--sasha-accent-color, #00d4ff);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.5);
  transition: all 0.2s ease;
}

.sasha-right-controls .sasha-volume-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* Area controlli con skip e progress */
.sasha-controls-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

/* Controlli skip sopra la progress bar */
.sasha-skip-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.sasha-btn-skip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 16px;
  color: var(--sasha-text-color, #ffffff);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 80px;
}

.sasha-btn-skip:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--sasha-accent-color, #00d4ff);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

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

.sasha-btn-skip svg {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.skip-seconds {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--sasha-accent-color, #00d4ff);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  line-height: 1;
}

/* Progress bar */
.sasha-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sasha-time {
  font-size: 12px;
  color: var(--sasha-text-color, #ffffff);
  opacity: 0.9;
  min-width: 40px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sasha-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: height 0.2s ease;
}

.sasha-progress-bar:hover {
  height: 8px;
}

.sasha-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sasha-accent-color, #00d4ff), var(--sasha-waveform-color, #00d4ff));
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
  position: relative;
}

.sasha-progress-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: var(--sasha-accent-color, #00d4ff);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.6);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sasha-progress-bar:hover .sasha-progress-fill::after {
  opacity: 1;
}

/* Stili base bottoni */
.sasha-btn {
  background: transparent;
  border: none;
  color: var(--sasha-text-color, #ffffff);
  cursor: pointer;
  padding: 10px;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sasha-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

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

.sasha-btn:focus-visible {
  outline: 2px solid var(--sasha-accent-color, #00d4ff);
  outline-offset: 2px;
}

/* Bottone volume (ora in right-controls) */
.sasha-btn-volume {
  padding: 8px;
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sasha-btn-volume .volume-icon,
.sasha-btn-volume .mute-icon {
  position: absolute;
  transition: all 0.3s ease;
}

.sasha-btn-volume .mute-icon {
  opacity: 0;
  transform: scale(0.5);
}

/* Mostra icona mute quando muted */
.sasha-container[data-muted="true"] .sasha-btn-volume .volume-icon {
  opacity: 0;
  transform: scale(0.5);
}

.sasha-container[data-muted="true"] .sasha-btn-volume .mute-icon {
  opacity: 1;
  transform: scale(1);
}

/* Bottone condivisione (ora in right-controls) */
.sasha-btn-share {
  background: rgba(255, 255, 255, 0.08);
  padding: 8px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sasha-btn-share:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--sasha-accent-color, #00d4ff);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.2);
}

/* Responsive per mobile - Layout overlay */
@media (max-width: 768px) {
  .sasha-container {
    flex-direction: column;
    min-height: 200px;
    height: 200px;
    position: relative;
  }
  
  .sasha-cover {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }
  
  .sasha-cover img {
    width: 100%;
    height: 100%;
  }
  
  .sasha-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, 
      rgba(0, 0, 0, 0.6) 0%, 
      rgba(0, 0, 0, 0.3) 30%,
      rgba(0, 0, 0, 0.3) 70%,
      rgba(0, 0, 0, 0.8) 100%);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 5;
  }
  
  /* Info in alto */
  .sasha-info {
    margin: 0;
  }
  
  .sasha-title {
    font-size: 16px;
    margin: 0 0 4px 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  }
  
  .sasha-subtitle {
    font-size: 12px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  }
  
  .sasha-sponsor {
    top: 10px;
    right: 10px;
  }
  
  .sasha-sponsor-claim {
    font-size: 9px;
  }
  
  .sasha-sponsor-logo {
    max-height: 28px;
    max-width: 100px;
    padding: 3px 6px;
  }
  
  .sasha-status {
    font-size: 12px;
  }
  
  /* Waveform e controlli destri compatti */
  .sasha-waveform-row {
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin: 0;
    padding-left: 84px; /* Spazio per play button a sinistra */
  }
  
  .sasha-waveform {
    height: 32px;
  }
  
  .sasha-right-controls {
    gap: 6px;
    flex-shrink: 0;
  }
  
  .sasha-right-controls .sasha-volume-slider {
    width: 60px;
  }
  
  .sasha-btn-volume,
  .sasha-btn-share {
    padding: 6px;
  }
  
  .sasha-btn-volume svg,
  .sasha-btn-share svg {
    width: 16px;
    height: 16px;
  }
  
  /* Controlli skip compatti */
  .sasha-controls-area {
    gap: 4px;
    margin: 0;
  }
  
  .sasha-skip-controls {
    gap: 10px;
  }
  
  .sasha-btn-skip {
    padding: 8px 14px;
    min-width: 70px;
    gap: 2px;
    border-radius: 10px;
  }
  
  .sasha-btn-skip svg {
    width: 20px;
    height: 20px;
  }
  
  .skip-seconds {
    font-size: 10px;
  }
  
  /* Progress bar compatta */
  .sasha-progress {
    gap: 8px;
  }
  
  .sasha-time {
    font-size: 11px;
  }
  
  /* Play button - a sinistra su mobile */
  .sasha-btn-play-overlay {
    width: 60px;
    height: 60px;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
  }
  
  .sasha-btn-play-overlay .play-icon,
  .sasha-btn-play-overlay .pause-icon {
    width: 32px;
    height: 32px;
  }
  
  .sasha-btn-play-overlay:hover {
    transform: translateY(-50%) scale(1.1);
  }
  
  .sasha-btn-play-overlay:active {
    transform: translateY(-50%) scale(0.95);
  }
}

@media (max-width: 480px) {
  .sasha-container {
    height: 180px;
    min-height: 180px;
  }
  
  .sasha-content {
    padding: 10px;
  }
  
  .sasha-title {
    font-size: 14px;
  }
  
  .sasha-subtitle {
    font-size: 11px;
  }
  
  .sasha-sponsor {
    top: 8px;
    right: 8px;
  }
  
  .sasha-sponsor-claim {
    font-size: 8px;
  }
  
  .sasha-sponsor-logo {
    max-height: 24px;
    max-width: 80px;
    padding: 2px 4px;
  }
  
  .sasha-waveform {
    height: 28px;
  }
  
  .sasha-right-controls .sasha-volume-slider {
    width: 50px;
  }
  
  .sasha-btn-skip {
    padding: 7px 12px;
    min-width: 65px;
  }
  
  .sasha-btn-skip svg {
    width: 18px;
    height: 18px;
  }
  
  .skip-seconds {
    font-size: 9px;
  }
  
  .sasha-time {
    font-size: 10px;
  }
  
  .sasha-btn-play-overlay {
    width: 56px;
    height: 56px;
  }
  
  .sasha-btn-play-overlay .play-icon,
  .sasha-btn-play-overlay .pause-icon {
    width: 28px;
    height: 28px;
  }
}

/* Animazioni */
@keyframes sasha-fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sasha-container {
  animation: sasha-fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stati del player */
.sasha-container.loading .sasha-btn-play-overlay {
  opacity: 0.6;
  cursor: not-allowed;
  animation: none;
}

.sasha-container.loading .sasha-btn-skip {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Accessibilità */
.sasha-progress-bar:focus-visible {
  outline: 2px solid var(--sasha-accent-color, #00d4ff);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Performance ottimizzazioni */
.sasha-container * {
  will-change: auto;
}

.sasha-waveform {
  contain: layout style paint;
}

.sasha-progress-fill {
  will-change: width;
}

.sasha-btn-play-overlay {
  will-change: transform;
}

/* Transizioni smooth */
* {
  -webkit-tap-highlight-color: transparent;
}

button {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
