/* Elegant, refined design for Spotify OAuth Demo */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  padding-top: 10vh;
}

.container {
  background: white;
  border-radius: 20px;
  box-shadow: 
    0 2.8px 2.2px rgba(0, 0, 0, 0.02),
    0 6.7px 5.3px rgba(0, 0, 0, 0.028),
    0 12.5px 10px rgba(0, 0, 0, 0.035),
    0 22.3px 17.9px rgba(0, 0, 0, 0.042),
    0 41.8px 33.4px rgba(0, 0, 0, 0.05),
    0 100px 80px rgba(0, 0, 0, 0.07);
  max-width: 600px;
  width: 100%;
  overflow: hidden;
}

header {
  background: #1a1a2e;
  color: white;
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(138, 43, 226, 0.1) 0%, rgba(30, 144, 255, 0.1) 100%);
  pointer-events: none;
}

h1 {
  font-size: 1.875rem;
  font-weight: 300;
  margin: 0;
  letter-spacing: -0.5px;
  position: relative;
}

h1::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, #8a2be2 0%, #1e90ff 100%);
  margin: 1rem auto 0;
}

main {
  padding: 2.5rem;
}

#actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

button {
  flex: 1;
  min-width: 150px;
  padding: 0.875rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  text-transform: none;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(100%);
}

#btnAuthorize {
  background: #7c3aed;
  color: white;
  box-shadow: 0 4px 14px 0 rgba(124, 58, 237, 0.3);
}

#btnAuthorize:not(:disabled):hover {
  background: #6d28d9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

#btnAuthorize:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

#btnGetToken {
  background: #0ea5e9;
  color: white;
  box-shadow: 0 4px 14px 0 rgba(14, 165, 233, 0.3);
}

#btnGetToken:not(:disabled):hover {
  background: #0284c7;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}

#btnGetToken:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

#btnGetToken.success {
  background: #10b981;
  box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.3);
  cursor: default;
}

#btnGetToken.success:hover {
  transform: none;
  box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.3);
}

#error {
  margin-bottom: 1rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  color: #991b1b;
  font-size: 0.9rem;
  display: none;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.08);
}

#error:not(:empty) {
  display: block;
}

.tokens {
  margin-bottom: 1rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 10px;
  word-break: break-all;
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
  font-size: 0.825rem;
  line-height: 1.6;
  color: #166534;
  display: none;
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.08);
  position: relative;
}

.tokens:not(:empty) {
  display: block;
}

.tokens strong {
  display: block;
  margin-bottom: 0.6rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.875rem;
  color: #14532d;
  font-weight: 600;
}

.tokens .token-value {
  display: block;
  word-break: break-all;
  margin-top: 0.5rem;
}

.clickable-token {
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.clickable-token:hover {
  background: linear-gradient(135deg, #e6faf0 0%, #d1f2e7 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(34, 197, 94, 0.15);
}

.clickable-token:active {
  transform: translateY(0);
}

.tokens .copy-hint {
  display: block;
  font-size: 0.7rem;
  color: #059669;
  margin-top: 0.5rem;
  font-style: italic;
  opacity: 0.7;
}

.token-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.copy-icon {
  width: 16px;
  height: 16px;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  fill: currentColor;
}

.clickable-token:hover .copy-icon {
  opacity: 1;
}

/* Collapsible instructions */
details {
  margin-bottom: 1.5rem;
}

details summary {
  cursor: pointer;
  font-weight: 500;
  color: #64748b;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #fafbfc 0%, #f3f4f7 100%);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  user-select: none;
}

details summary:hover {
  background: linear-gradient(135deg, #f3f4f7 0%, #e8ebf3 100%);
  color: #475569;
}

details[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

details .intro {
  padding: 1rem;
  background: #fafbfc;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-top: none;
  margin-bottom: 0;
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.6;
}

details .intro strong {
  color: #334155;
  background: linear-gradient(135deg, #f6f8fb 0%, #e8ebf3 100%);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid rgba(203, 213, 225, 0.4);
}

#steps {
  background: #fafbfc;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-top: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  padding: 1rem 1.5rem 1.5rem;
}

#steps h2 {
  color: #1e293b;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
  letter-spacing: -0.25px;
}

#steps ol {
  padding-left: 1.25rem;
}

#steps li {
  margin-bottom: 0.6rem;
  color: #475569;
  line-height: 1.5;
  font-size: 0.9rem;
}

#steps li strong {
  color: #1e293b;
  font-weight: 600;
}

#notes {
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

#notes h3 {
  color: #92400e;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  letter-spacing: -0.25px;
}

#notes ul {
  list-style: none;
  padding: 0;
}

#notes li {
  color: #92400e;
  margin-bottom: 0.4rem;
  padding-left: 1.5rem;
  position: relative;
  line-height: 1.5;
  font-size: 0.875rem;
}

#notes li:before {
  content: "→";
  position: absolute;
  left: 0.5rem;
  font-weight: 600;
}

#notes a {
  color: #7c3aed;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border-bottom: 1px solid transparent;
}

#notes a:hover {
  color: #6d28d9;
  border-bottom-color: #6d28d9;
}

#action-tests {
  border-top: 1px solid #e2e8f0;
  padding-top: 2rem;
  margin-top: 2rem;
}

#action-tests h3 {
  color: #64748b;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  font-weight: 500;
  letter-spacing: -0.25px;
}

#btnGetDevices {
  background: #10b981;
  color: white;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.3);
}

#btnGetDevices:not(:disabled):hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

#btnGetDevices:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

#action-results {
  margin-top: 1rem;
}

.test-buttons {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.test-buttons button {
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
}

/* Formatted results styles */
#formatted-results {
  margin-bottom: 1rem;
}

.formatted-response {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem;
}

.formatted-response h4 {
  margin: 0 0 1rem 0;
  color: #1e293b;
  font-size: 1.1rem;
}

.no-data {
  color: #64748b;
  font-style: italic;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  text-align: center;
}

/* Device list styles */
.device-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.device-item {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.device-item.active {
  border-color: #10b981;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.device-header strong {
  color: #1e293b;
  font-size: 0.95rem;
}

.active-badge {
  background: #10b981;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.device-details {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: #64748b;
}

.private-session {
  color: #f59e0b;
  font-weight: 500;
}

/* Playlist styles */
.playlist-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.playlist-item {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.playlist-header strong {
  color: #1e293b;
  font-size: 0.95rem;
}

.playlist-visibility {
  background: #e2e8f0;
  color: #64748b;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
}

.playlist-details {
  display: flex;
  gap: 0.2rem;
  font-size: 0.85rem;
  color: #64748b;
}

.collaborative {
  color: #8b5cf6;
  font-weight: 500;
}

.playlist-description {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #94a3b8;
  font-style: italic;
}

/* Player state styles */
.player-state {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.now-playing {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.track-info {
  margin-bottom: 1rem;
}

.track-status {
  color: #10b981;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.track-name {
  display: block;
  font-size: 1.1rem;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.track-artist {
  color: #475569;
  font-size: 0.95rem;
}

.track-album {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.playback-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #64748b;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #10b981;
  transition: width 0.3s ease;
}

.playback-device {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.85rem;
  color: #64748b;
}

.device-volume {
  margin-left: 1rem;
}

.playback-settings {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: #64748b;
}

/* Raw JSON styles */
#raw-results summary {
  cursor: pointer;
  font-weight: 500;
  color: #64748b;
  padding: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

#raw-results summary:hover {
  background: #f1f5f9;
  color: #475569;
}

#raw-results[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

#raw-json {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

/* Custom scrollbar for results */
#action-results::-webkit-scrollbar {
  width: 8px;
}

#action-results::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

#action-results::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

#action-results::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Copy feedback */
.copy-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #10b981;
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  font-weight: 500;
  animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  20% { opacity: 1; transform: translate(-50%, -50%); }
  80% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* Responsive design */
@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }
  
  .container {
    border-radius: 0;
    box-shadow: none;
  }
  
  body {
    padding: 0;
    align-items: stretch;
    background: white;
  }
  
  main {
    padding: 1.5rem;
  }
  
  header {
    padding: 2rem 1.5rem;
  }
  
  #actions {
    flex-direction: column;
  }
  
  button {
    width: 100%;
  }
}