/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
  --bg-primary: #0f0f23;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --accent-primary: #6366f1;
  --accent-secondary: #a855f7;
  --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #6b6b80;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================
   Listener Page
   ============================================ */
.listener-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.radio-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 40px 30px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.visualizer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.4;
}

.content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* Station Info */
.station-info {
  text-align: center;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.station-name {
  font-size: 24px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Album Art */
.album-container {
  position: relative;
  width: 220px;
  height: 220px;
}

.album-art {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.album-placeholder {
  width: 80px;
  height: 80px;
  color: var(--text-muted);
}

.album-placeholder svg {
  width: 100%;
  height: 100%;
}

.album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vinyl-record {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  background: 
    radial-gradient(circle at center, #1a1a1a 15%, transparent 16%),
    radial-gradient(circle at center,
      #1a1a1a 20%,
      #2d2d2d 21%,
      #2d2d2d 28%,
      #1a1a1a 29%,
      #1a1a1a 36%,
      #2d2d2d 37%,
      #2d2d2d 44%,
      #1a1a1a 45%
    );
  border-radius: 50%;
  transform: translate(-50%, -50%) translateX(30%);
  z-index: 1;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.vinyl-record::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  background: var(--accent-gradient);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.vinyl-record::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  background: #111;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.vinyl-record.spinning {
  animation: spin 3s linear infinite;
}

@keyframes spin {
  from { transform: translate(-50%, -50%) translateX(30%) rotate(0deg); }
  to { transform: translate(-50%, -50%) translateX(30%) rotate(360deg); }
}

/* Song Info */
.song-info {
  text-align: center;
  max-width: 100%;
  padding: 0 10px;
}

.song-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.song-artist {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Progress Bar */
.progress-container {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.time {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

.time.duration {
  text-align: right;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.1s linear;
}

/* Listeners */
.listeners-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Volume Control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding-top: 10px;
}

.volume-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.volume-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.volume-btn svg {
  width: 24px;
  height: 24px;
}

.volume-slider,
.seek-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  cursor: pointer;
  outline: none;
}

.volume-slider::-webkit-slider-thumb,
.seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.volume-slider::-webkit-slider-thumb:hover,
.seek-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px var(--accent-primary);
}

/* Click to Start */
.click-to-start {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 15, 35, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: var(--radius-lg);
}

.click-to-start.hidden {
  display: none;
}

.start-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 30px 50px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
}

/* Connection Status */
.connection-status {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  z-index: 1000;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.connection-status.connected .status-dot { background: var(--success); }
.connection-status.disconnected .status-dot,
.connection-status.error .status-dot { background: var(--danger); }
.connection-status.connecting .status-dot,
.connection-status.reconnecting .status-dot { 
  background: var(--warning);
  animation: pulse 1s infinite; 
}

/* ============================================
   Admin Page
   ============================================ */
.admin-page {
  background: var(--bg-primary);
  min-height: 100vh;
}

/* Login Modal */
.login-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.login-card {
  background: var(--bg-secondary);
  padding: 40px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-card h2 {
  margin-bottom: 30px;
  font-size: 24px;
}

.login-card input {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 16px;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.login-card button {
  width: 100%;
  padding: 16px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.login-card button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.error-message {
  color: var(--danger);
  font-size: 14px;
  margin-top: 16px;
  min-height: 20px;
}

/* Admin Container */
.admin-container {
  min-height: 100vh;
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-header h1 {
  font-size: 24px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.connection-badge {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
}

.connection-badge.connected { color: var(--success); }
.connection-badge.disconnected,
.connection-badge.error { color: var(--danger); }
.connection-badge.connecting { color: var(--warning); }

.logout-btn {
  padding: 10px 24px;
  background: transparent;
  border: 2px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--danger);
  color: white;
}

/* Admin Grid */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
}

.panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 24px;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

/* Now Playing Panel */
.now-playing-content {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.current-album-art {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.current-album-art .album-placeholder {
  width: 50px;
  height: 50px;
}

.current-album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.current-song-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.current-song-details h3 {
  font-size: 18px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-song-details p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Seek Container */
.seek-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.seek-slider {
  height: 6px;
}

/* Playback Controls */
.playback-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.control-btn {
  width: 52px;
  height: 52px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  background: var(--accent-primary);
  transform: scale(1.05);
}

.control-btn svg {
  width: 24px;
  height: 24px;
}

.control-btn.play-btn {
  width: 68px;
  height: 68px;
  background: var(--accent-gradient);
}

.control-btn.play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
}

.control-btn.play-btn svg {
  width: 32px;
  height: 32px;
}

/* Admin Volume */
.admin-volume {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-volume label {
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
}

.admin-volume input {
  flex: 1;
}

.admin-volume span {
  min-width: 45px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Form Styles */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.duration-input-group {
  display: flex;
  gap: 10px;
}

.duration-input-group input {
  flex: 1;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 12px 20px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger {
  padding: 8px 16px;
  background: transparent;
  border: 2px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

/* Playlist */
.playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.playlist-header h2 {
  margin: 0;
  padding: 0;
  border: none;
}

.playlist-container {
  max-height: 450px;
  overflow-y: auto;
  padding-right: 8px;
}

.empty-playlist {
  text-align: center;
  color: var(--text-muted);
  padding: 50px 20px;
  font-size: 14px;
}

.playlist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.playlist-item:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

.playlist-item.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

.playlist-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.playlist-index {
  color: var(--text-muted);
  font-size: 12px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.playlist-cover {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.playlist-cover-placeholder {
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border-radius: 6px;
  flex-shrink: 0;
}

.playlist-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.playlist-title {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-artist {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.playlist-duration {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.playlist-play-btn,
.playlist-remove-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-secondary);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.playlist-play-btn:hover {
  background: var(--accent-primary);
  color: white;
  transform: scale(1.1);
}

.playlist-remove-btn:hover {
  background: var(--danger);
  color: white;
  transform: scale(1.1);
}

/* Stats Panel */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-tertiary);
  padding: 24px 20px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
  
  .admin-header {
    flex-direction: column;
    text-align: center;
  }
  
  .now-playing-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .current-album-art {
    width: 120px;
    height: 120px;
  }

  .radio-container {
    padding: 30px 20px;
  }

  .album-container {
    width: 180px;
    height: 180px;
  }

  .vinyl-record {
    width: 160px;
    height: 160px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}