/* CSS Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Base Typography - Large text for elderly users */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 20px;
  line-height: 1.6;
  color: #000000;
  background-color: #ffffff;
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

h1 {
  font-size: 32px;
  margin-bottom: 20px;
  color: #1a1a1a;
}

/* Large touch targets for elderly users - 60x60px minimum */
.song-item {
  min-height: 60px;
  min-width: 100%;
  padding: 20px;
  margin-bottom: 12px;
  font-size: 22px;
  border: 2px solid #333;
  background: #f5f5f5;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.1s ease;
  text-align: left;
  display: block;
  width: 100%;
}

/* Visual feedback within 100ms */
.song-item:active {
  background-color: #e0e0e0;
  transform: scale(0.98);
}

.song-item:hover {
  background-color: #eaeaea;
}

/* Active song highlighting */
.song-item.active {
  background-color: #ffeb3b;
  border-color: #f57c00;
  font-weight: bold;
}

/* Cache indicators for offline availability */
.cache-indicator {
  display: inline-block;
  margin-left: 12px;
  font-size: 20px;
  font-weight: bold;
  vertical-align: middle;
  min-width: 24px;
  text-align: center;
}

.cache-indicator.cached {
  color: #4caf50; /* Green for cached */
  opacity: 0.8;
}

.cache-indicator.not-cached {
  color: #9e9e9e; /* Gray for needs download */
  opacity: 0.6;
}

/* Make cache indicators more visible on active songs */
.song-item.active .cache-indicator.cached {
  color: #2e7d32; /* Darker green on yellow background */
  opacity: 1;
}

.song-item.active .cache-indicator.not-cached {
  color: #616161; /* Darker gray on yellow background */
  opacity: 0.8;
}

/* Control buttons - 60x60px touch targets */
.controls {
  display: none;
  margin: 24px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.controls.visible {
  display: flex;
}

.control-btn {
  min-width: 60px;
  min-height: 60px;
  font-size: 18px;
  padding: 12px 20px;
  border: 2px solid #000;
  background: #fff;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.1s ease;
}

.control-btn:active {
  background: #e0e0e0;
  transform: scale(0.95);
}

.control-btn:focus {
  outline: 3px solid #007bff;
  outline-offset: 2px;
}

.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error messages - large, high contrast */
.error {
  font-size: 20px;
  color: #d32f2f;
  background: #ffebee;
  padding: 20px;
  border: 2px solid #d32f2f;
  border-radius: 8px;
  margin: 20px 0;
}

/* Loading indicator */
.loading {
  font-size: 20px;
  color: #1976d2;
  padding: 20px;
  text-align: center;
}

/* Progress bar */
#progress-container {
  display: none;
  margin: 24px 0;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 8px;
}

#progress-container.visible {
  display: block;
}

#current-song-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 12px;
}

progress {
  width: 100%;
  height: 20px;
  border-radius: 4px;
}

#time-display {
  font-size: 18px;
  margin-top: 8px;
  color: #666;
}

/* Status indicator */
.status-indicator {
  font-size: 20px;
  margin: 12px 0;
  padding: 12px;
  background: #e3f2fd;
  border-radius: 8px;
}

/* Navigation Button */
.nav-btn {
  font-size: 20px;
  padding: 15px 24px;
  margin-bottom: 20px;
  background-color: #e0e0e0;
  border: 2px solid #333;
  border-radius: 8px;
  cursor: pointer;
  display: inline-block;
  min-height: 60px; /* Touch target */
}

.nav-btn:active {
  background-color: #d0d0d0;
  transform: scale(0.98);
}

/* Voice List Header */
#selected-song-title {
  font-size: 26px;
  margin-bottom: 16px;
  color: #333;
  padding: 0 4px;
}

/* Voice Items Container */
#voice-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Responsive design - portrait */
@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .song-item {
    font-size: 20px;
    padding: 18px;
  }
}

/* Responsive design - landscape */
@media (min-width: 601px) and (max-width: 1024px) {
  .controls {
    justify-content: center;
  }
}

/* Touch-action to prevent unwanted zoom */
button, .song-item {
  touch-action: manipulation;
}

/* High visibility focus indicators */
*:focus {
  outline: 3px solid #007bff;
  outline-offset: 2px;
}

/* Download spinner for first-time R2 downloads */
.download-spinner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #1976d2;
  color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  font-size: 20px;
}

.spinner-icon {
  width: 28px;
  height: 28px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner-text {
  font-weight: 500;
  white-space: nowrap;
}

/* Visible state for download spinner */
.download-spinner.visible {
  display: flex;
}

/* Responsive adjustments for spinner */
@media (max-width: 600px) {
  .download-spinner {
    bottom: 16px;
    left: 16px;
    right: 16px;
    transform: none;
    justify-content: center;
  }
}