/* Global Styles */
:root {
  font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light dark;
  color: rgba(255, 255, 255, 0.87);
  background-color: #242424;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}

a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.25s;
}

button:hover {
  border-color: #646cff;
}

button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

/* App-specific Styles */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
}

h1 {
  color: #1db954;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
  line-height: 1.1;
}

.subtitle {
  text-align: center;
  color: #888;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.input-form {
  margin-bottom: 2rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.link-input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #fff;
  font-size: 1rem;
}

.link-input:focus {
  outline: none;
  border-color: #1db954;
}

.link-input::placeholder {
  color: #666;
}

.fetch-button, .spotify-button {
  padding: 0.75rem 1.5rem;
  background: #1db954;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.fetch-button:hover:not(:disabled), .spotify-button:hover:not(:disabled) {
  background: #1ed760;
}

.fetch-button:disabled, .spotify-button:disabled {
  background: #666;
  cursor: not-allowed;
}

.spotify-button {
  width: 100%;
  margin-top: 1rem;
}

.message {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.error-message {
  background: #ff4444;
  color: white;
}

.success-message {
  background: #1db954;
  color: white;
}

.info-message {
  background: #2962ff;
  color: white;
}

.songs-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #1a1a1a;
  border-radius: 8px;
  border: 2px solid #333;
}

.songs-section h2 {
  color: #1db954;
  margin-bottom: 1rem;
}

.songs-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
  text-align: left;
}

.song-item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: #252525;
  border-radius: 6px;
  border-left: 3px solid #1db954;
}

.song-item.more {
  background: #1a1a1a;
  border-left: none;
  text-align: center;
  color: #888;
}

.instructions {
  margin-top: 3rem;
  padding: 1.5rem;
  background: #1a1a1a;
  border-radius: 8px;
  text-align: left;
}

.instructions h3 {
  color: #1db954;
  margin-bottom: 1rem;
}

.instructions ol {
  margin-left: 1.5rem;
  line-height: 1.8;
}

.instructions li {
  margin-bottom: 0.5rem;
}

.note {
  margin-top: 1rem;
  padding: 1rem;
  background: #252525;
  border-radius: 6px;
  border-left: 3px solid #ff9800;
}

.note a {
  color: #1db954;
  text-decoration: none;
}

.note a:hover {
  text-decoration: underline;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.loading-content {
  text-align: center;
  padding: 2rem;
  background: #1a1a1a;
  border-radius: 12px;
  border: 2px solid #1db954;
  min-width: 300px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #333;
  border-top: 4px solid #1db954;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.2rem;
  color: #1db954;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.loading-progress {
  font-size: 0.95rem;
  color: #888;
  min-height: 1.5rem;
}

@media (max-width: 768px) {
  .input-group {
    flex-direction: column;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .loading-content {
    min-width: 250px;
    padding: 1.5rem;
  }
}

/* Step sections */
.step-section {
  margin-bottom: 2rem;
}

/* Logout section - always visible when connected */
.logout-section {
  text-align: right;
  margin-bottom: 1rem;
}

/* Logout button */
.logout-button {
  padding: 0.5rem 1rem;
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.logout-button:hover {
  background: #ff6666;
}

/* Secondary button - for changing playlist selection */
.secondary-button {
  padding: 0.5rem 1rem;
  background: #252525;
  color: #fff;
  border: 2px solid #333;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-button:hover {
  border-color: #1db954;
  background: #2a2a2a;
}

/* Playlist selection */
.playlist-selection {
  padding: 1.5rem;
  background: #1a1a1a;
  border-radius: 8px;
  border: 2px solid #333;
}

.playlist-selection h3 {
  color: #1db954;
  margin-bottom: 1rem;
  margin-top: 0;
}

.playlist-options {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.option-button {
  flex: 1;
  padding: 1rem;
  background: #252525;
  color: #fff;
  border: 2px solid #333;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.option-button:hover {
  border-color: #1db954;
}

.option-button.selected {
  background: #1db954;
  border-color: #1db954;
  font-weight: 600;
}

.playlist-dropdown {
  width: 100%;
  padding: 0.75rem;
  background: #252525;
  color: #fff;
  border: 2px solid #333;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.playlist-dropdown:focus {
  outline: none;
  border-color: #1db954;
}

.continue-button {
  width: 100%;
  padding: 0.75rem;
  background: #1db954;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.continue-button:hover:not(:disabled) {
  background: #1ed760;
}

.continue-button:disabled {
  background: #666;
  cursor: not-allowed;
}

/* URL input section */
.url-input-section {
  padding: 1.5rem;
  background: #1a1a1a;
  border-radius: 8px;
  border: 2px solid #333;
}

.url-input-section h3 {
  color: #1db954;
  margin-top: 0;
  margin-bottom: 1rem;
}

/* Songs actions */
.songs-actions {
  margin-bottom: 1.5rem;
}

.action-button {
  padding: 0.75rem 1.5rem;
  background: #252525;
  color: white;
  border: 2px solid #333;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.action-button:hover:not(:disabled) {
  border-color: #1db954;
  background: #2a2a2a;
}

.action-button.primary {
  background: #1db954;
  border-color: #1db954;
}

.action-button.primary:hover:not(:disabled) {
  background: #1ed760;
}

.action-button:disabled {
  background: #666;
  border-color: #666;
  cursor: not-allowed;
  opacity: 0.5;
}

.song-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.song-info {
  flex: 1;
}

.song-add-button {
  padding: 0.5rem 1rem;
  background: #1db954;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  margin-left: 1rem;
}

.song-add-button:hover:not(:disabled) {
  background: #1ed760;
}

.song-add-button:disabled {
  background: #666;
  cursor: not-allowed;
}

.song-add-button.added {
  background: #666;
  cursor: default;
}

@media (max-width: 768px) {
  .input-group {
    flex-direction: column;
  }
  
  .playlist-options {
    flex-direction: column;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .loading-content {
    min-width: 250px;
    padding: 1.5rem;
  }
  
  .logout-section {
    text-align: center;
  }
  
  .logout-button {
    display: inline-block;
    width: auto;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    color: #213547;
    background-color: #ffffff;
  }
  
  a:hover {
    color: #747bff;
  }
  
  button {
    background-color: #f9f9f9;
  }
}
