:root {
  --spotify-green: #1ed760;
  --spotify-dark: #121212;
  --spotify-darker: #000000;
  --spotify-light: #222222;
  --spotify-lighter: #333333;
  --spotify-gray: #a7a7a7;
  --spotify-white: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #a7a7a7;
  --app-font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

[data-theme="netflix"] {
  --spotify-green: #e50914;
  --spotify-dark: #141414;
  --spotify-darker: #000000;
  --spotify-light: #2a2a2a;
  --spotify-lighter: #3a3a3a;
  --spotify-gray: #808080;
  --spotify-white: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #808080;
  --netflix-font: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

[data-theme="netflix"] #globeViz {
  filter: grayscale(0.5) brightness(0.7);
}

[data-theme="netflix"] body {
  font-family: var(--netflix-font, "Helvetica Neue", Helvetica, Arial, sans-serif);
}

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

body { 
  margin: 0; 
  background: var(--spotify-darker); 
  overflow: hidden; 
  font-family: var(--app-font, "Helvetica Neue", Helvetica, Arial, sans-serif);
  color: var(--text-primary);
}

#globeViz { width: 100vw; height: 100vh; position: absolute; top: 0; left: 0; }

#tooltip {
  position: absolute;
  color: var(--spotify-white);
  background: var(--spotify-light);
  padding: 8px 16px;
  border-radius: 500px;
  pointer-events: none;
  display: none;
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
}

#controls {
  position: absolute;
  bottom: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  transition: right 0.3s ease;
}

#controls.panel-open { right: 370px; }

.btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--spotify-green);
  color: var(--spotify-darker);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--spotify-green);
  transform: scale(1.05);
}

#authBtn {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 50;
  padding: 10px 20px;
  background: transparent;
  border: 2px solid var(--spotify-green);
  border-radius: 500px;
  color: var(--spotify-green);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

#authBtn:hover { background: var(--spotify-green); color: var(--spotify-darker); }

#rightPanel {
  position: absolute;
  top: 0;
  right: -370px;
  width: 350px;
  height: 100vh;
  background: rgba(16, 16, 16, 0.98);
  border-left: 1px solid rgba(255,255,255,0.1);
  transition: right 0.4s cubic-bezier(0.3, 0, 0, 1);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

#rightPanel.open { right: 0; }

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(29, 185, 84, 0.08), transparent);
}

.panel-header h3 {
  color: var(--spotify-white);
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.close-panel {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s;
  padding: 4px 8px;
  border-radius: 50%;
}

.close-panel:hover { color: var(--spotify-white); background: rgba(255,255,255,0.1); }

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  position: relative;
}

#loadingSpinner {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border: 3px solid rgba(29, 185, 84, 0.2);
  border-top-color: var(--spotify-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: none;
  z-index: 10;
}

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.channel-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  gap: 14px;
  margin-bottom: 8px;
  background: transparent;
  border: 1px solid transparent;
}

.channel-item:hover { 
  background: linear-gradient(135deg, rgba(29, 185, 84, 0.15), rgba(29, 185, 84, 0.05));
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  border-color: rgba(29, 185, 84, 0.3);
}

.channel-item:active { 
  transform: translateY(0);
  background: rgba(29, 185, 84, 0.1);
}

.channel-logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: transform 0.2s;
}

.channel-item:hover .channel-logo {
  transform: scale(1.08);
}

.channel-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.channel-name {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
}

.channel-item:hover .channel-name {
  color: var(--spotify-green);
}

.channel-group {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fav-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  opacity: 0;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.fav-btn::before {
  content: '☆';
  color: var(--text-secondary);
  font-size: 20px;
  transition: all 0.2s ease;
}

.fav-btn:hover::before {
  color: #ffd700;
  transform: scale(1.2);
}

.channel-item:hover .fav-btn { opacity: 1; }

.fav-btn.active::before {
  content: '★';
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.fav-btn.active {
  opacity: 1;
}

#playerModal {
  display: none;
  position: fixed;
  width: 76%;
  max-width: 860px;
  background: var(--spotify-dark);
  border-radius: 8px;
  z-index: 80;
  box-shadow: 0 16px 24px rgba(0,0,0,0.4);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
}

#playerModal.dragging { cursor: move; user-select: none; }
#playerModal.dragging * { pointer-events: none; }
#playerModal.open { display: block; }

.player-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-header h3 {
  color: var(--text-primary);
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.close-player {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-player:hover { color: var(--spotify-white); background: rgba(255,255,255,0.1); }

.video-wrapper {
  aspect-ratio: 16/9;
  background: #000;
  position: relative;
  overflow: visible;
  z-index: 100;
}

.video-wrapper video { width: 100%; height: 100%; }

#customControls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.8);
  opacity: 1;
  z-index: 200;
}

#pauseOverlay {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 28px;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  z-index: 100;
}

#loginModal, #registerModal, #forgotModal, #verifyModal, #resetPasswordModal, #profileModal, #changePasswordModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.modal-box {
  background: var(--spotify-dark);
  padding: 32px;
  border-radius: 8px;
  width: 320px;
  box-shadow: 0 16px 24px rgba(0,0,0,0.4);
}

.modal-box h2 {
  color: var(--text-primary);
  margin: 0 0 24px 0;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

.modal-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border-radius: 4px;
  border: none;
  background: var(--spotify-light);
  color: var(--text-primary);
  font-size: 14px;
}

.modal-box input::placeholder { color: var(--text-secondary); }
.modal-box input:focus { outline: 2px solid var(--spotify-white); outline-offset: -2px; }

.modal-box .btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--spotify-green);
  border: none;
  border-radius: 500px;
  color: var(--spotify-darker);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  margin-top: 8px;
}

.modal-box .btn-primary:hover { transform: scale(1.02); }

.modal-box p { color: var(--text-secondary); font-size: 12px; text-align: center; margin: 16px 0; }
.modal-box a { color: var(--spotify-white); text-decoration: none; }
.modal-box a:hover { text-decoration: underline; }

#countryInfo {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--spotify-green);
  padding: 8px 16px;
  border-radius: 500px;
  color: var(--spotify-darker);
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
  display: none;
}

.tab-buttons {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  background: rgba(255,255,255,0.05);
  border: none;
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.25s ease;
}

.tab-btn:hover { 
  background: rgba(255,255,255,0.1); 
  color: var(--spotify-white);
}

.tab-btn.active {
  background: var(--spotify-green);
  color: var(--spotify-darker);
  box-shadow: 0 4px 15px rgba(29, 185, 84, 0.3);
}

#channelSearch {
  margin: 0 16px 16px;
  padding: 12px 38px 12px 16px;
  border-radius: 24px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  font-size: 14px;
  width: calc(100% - 32px);
  box-sizing: border-box;
  transition: all 0.2s ease;
}

#channelSearch:focus { 
  outline: none; 
  border-color: var(--spotify-green);
  background: rgba(29, 185, 84, 0.1);
}

#channelSearch::placeholder { color: var(--text-secondary); }

#channelSearch:focus { outline: none; }
#channelSearch::placeholder { color: var(--text-secondary); }

#searchClear {
  position: absolute;
  right: 30px;
  top: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: none;
  z-index: 10;
  text-align: center;
  line-height: 15px;
}

#searchClear:hover { color: var(--spotify-white); background: rgba(255,255,255,0.4); }

.no-channels {
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }

#customControls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.9));
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 1;
  transition: opacity 0.3s;
}

#customControls button {
  background: none;
  border: none;
  color: var(--spotify-white);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  transition: transform 0.2s;
}

#customControls button:hover { transform: scale(1.1); }

#customControls button#playPauseBtn {
  width: 32px;
  height: 32px;
  background: var(--spotify-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--spotify-darker);
  font-size: 14px;
}

#customControls button#playPauseBtn:hover { transform: scale(1.1); }

#progressBar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

#progressBar:hover { height: 5px; }
#progressBar:hover #progressBarFill { height: 5px; }

#progressBar span {
  position: absolute;
  top: -4px;
  left: 0;
  width: 100%;
  height: 12px;
}

#progressBarFill {
  height: 100%;
  background: var(--spotify-green);
  border-radius: 2px;
  transition: height 0.1s;
  width: 0%;
}

#timeDisplay { color: var(--spotify-white); font-size: 11px; min-width: 35px; }

#volumeSlider {
  width: 72px;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  cursor: pointer;
}

#volumeSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  background: var(--spotify-white);
  border-radius: 50%;
  cursor: pointer;
}

#qualityBtn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
}

#qualityBtn:hover { color: var(--spotify-white); }

#qualityMenu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--spotify-light);
  border-radius: 4px;
  padding: 4px;
  min-width: 90px;
  z-index: 100;
  margin-bottom: 8px;
}

#qualityOptions div {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 2px;
  color: var(--text-secondary);
  font-size: 12px;
}

#qualityOptions div:hover { background: rgba(255,255,255,0.1); color: var(--spotify-white); }

#ccBtn { background: transparent; border: none; color: var(--text-secondary); padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: 500; }
#ccBtn:hover { color: var(--spotify-white); }
#ccBtn.active { color: var(--spotify-green); }

#ccMenu { display: none; position: absolute; bottom: 100%; right: 0; transform: translateX(0); background: var(--spotify-light); border-radius: 4px; padding: 4px; min-width: 120px; z-index: 100; margin-bottom: 8px; }
#ccOptions div { padding: 8px 12px; cursor: pointer; border-radius: 2px; color: var(--text-secondary); font-size: 12px; }
#ccOptions div:hover { background: rgba(255,255,255,0.1); color: var(--spotify-white); }
#ccOptions div.selected { color: var(--spotify-green); }

@media (max-width: 768px) {
  #rightPanel { width: 100%; right: -100%; }
  #playerModal { width: 95%; max-width: none; }
  #controls { bottom: 12px; right: 12px; }
  #controls.panel-open { right: 12px; }
  .video-wrapper { aspect-ratio: 16/9; }
  #customControls { flex-wrap: wrap; padding: 12px 8px; gap: 8px; }
  #volumeSlider { width: 50px; }
  #authBtn { padding: 8px 14px; font-size: 12px; }
  #countryInfo { font-size: 12px; padding: 6px 12px; }
  .channel-logo { width: 36px; height: 36px; }
  .channel-name { font-size: 13px; }
  .modal-box { width: 90%; padding: 24px; }
}