:root {
  --bg-color: #020205;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --glass-bg: rgba(15, 15, 20, 0.4);
  --glass-border: rgba(255, 255, 255, 0.1);
  --accent: #4deeea;
  --accent-hover: #3bcac6;
  --shadow-color: rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  overflow: hidden; /* Prevent scrolling, full screen app */
  width: 100vw;
  height: 100vh;
}

h1, h2, h3 {
  font-family: 'Outfit', sans-serif;
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px var(--shadow-color);
}

/* Header */
.main-header {
  position: absolute;
  top: 24px;
  left: 24px;
  padding: 20px 28px;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to globe */
  animation: fadeInDown 1s ease-out;
}

.main-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  background: linear-gradient(90deg, #ffffff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-header p {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 300;
}

/* Globe Container */
#globeViz {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Tooltip */
.tooltip {
  position: absolute;
  padding: 8px 12px;
  font-size: 13px;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.2s;
}

.tooltip.hidden {
  opacity: 0;
}

/* Modal (Video Player) */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; /* Let clicks pass through background */
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  opacity: 0;
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  min-width: 300px;
  height: 450px;
  min-height: 250px;
  resize: both;
  overflow: auto;
  pointer-events: auto; /* Re-enable clicks on the window */
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.modal.hidden .modal-content {
  display: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  cursor: grab;
  user-select: none;
}

.modal-header:active {
  cursor: grabbing;
}

.location-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.location-info i {
  color: var(--accent);
  width: 24px;
  height: 24px;
}

.location-info h2 {
  font-size: 24px;
  font-weight: 600;
}

.close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.video-container {
  position: relative;
  width: 100%;
  flex-grow: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Category Switcher */
.category-switcher {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px;
  z-index: 10;
}

.cat-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.cat-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.cat-btn.active {
  color: var(--bg-color);
  background: var(--text-primary);
}

.cat-btn i {
  width: 18px;
  height: 18px;
}

/* Category Specific Active Colors */
.cat-btn[data-category="news"].active {
  background: #4deeea;
}
.cat-btn[data-category="walking"].active {
  background: #39ff14;
}
.cat-btn[data-category="historic"].active {
  background: #ffb300;
}


/* Modal Layout for Sidebar */
.modal-layout {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 20px;
}
.video-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.related-sidebar {
  width: 300px;
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  padding: 16px;
  border: 1px solid var(--glass-border);
  overflow-y: auto;
}
.related-sidebar h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--accent);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 8px;
}
.related-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex-grow: 1;
}
.related-item {
  padding: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}
.related-item:hover {
  background: rgba(255,255,255,0.15);
  border-left: 3px solid var(--accent);
}


/* Cluster Marker Icons */
@keyframes pulseMarker {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
  70% { box-shadow: 0 0 0 15px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.cluster-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
  border: 2px solid rgba(255, 255, 255, 0.8);
  text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: auto;
}

.cluster-marker:hover {
  transform: scale(1.4);
  z-index: 100;
}

.cluster-marker.multiple {
  width: 26px;
  height: 26px;
}

.cluster-marker.living {
  animation: pulseMarker 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

.cluster-marker.visited {
  opacity: 0.5;
  filter: grayscale(80%);
  border-color: rgba(255,255,255,0.3);
}


/* Channel Directory Sidebar */
#channelDirectory {
  position: absolute;
  top: 24px;
  right: -350px; /* Hidden offscreen by default */
  width: 320px;
  height: calc(100vh - 48px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 20px;
  transition: right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

#channelDirectory.active {
  right: 24px;
}

#channelDirectory.hidden {
  display: none;
}

.directory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--glass-border);
}

.directory-header h2 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ff00ff; /* Livetv accent color */
}

.country-list {
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 5px;
}

/* Custom Scrollbar for directory */
.country-list::-webkit-scrollbar {
  width: 6px;
}
.country-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}
.country-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.country-group {
  margin-bottom: 20px;
}

.country-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 12px;
  border-radius: 6px;
}

.country-title img {
  width: 24px;
  height: auto;
  border-radius: 2px;
}

.channel-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  text-align: left;
  padding: 8px 12px 8px 46px; /* Offset to align with text */
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  transform: translateX(4px);
}

.channel-btn::before {
  content: "•";
  color: #ff00ff;
  font-size: 20px;
  line-height: 0;
  margin-right: 4px;
}

/* Accordion Styles */
.country-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}
.country-title:hover {
  background: rgba(255,255,255,0.1);
}
.channels-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 10px;
  margin-bottom: 12px;
}

/* Country Context Card */
.country-context-card {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.ctx-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.7);
}
.ctx-row strong {
  color: #fff;
}
.ctx-row:last-child {
  margin-bottom: 0;
}
.freedom-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .category-switcher {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
    width: 95%;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 8px;
    padding-bottom: env(safe-area-inset-bottom, 8px);
    gap: 8px;
    scrollbar-width: none;
    bottom: max(15px, env(safe-area-inset-bottom));
  }
  .category-switcher::-webkit-scrollbar {
    display: none;
  }
  .cat-btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 11px;
  }
  .modal-layout {
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
  }
  .modal-content {
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }
  .video-main {
    flex: none;
    height: auto;
    aspect-ratio: 16 / 9;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #000;
  }
  .modal-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    padding: 10px;
    margin-bottom: 0;
  }
  .location-info h2 {
    font-size: 16px;
  }
  .related-sidebar {
    padding: 16px;
    padding-bottom: env(safe-area-inset-bottom, 60px);
  }
  #surpriseMeBtn {
    bottom: max(85px, env(safe-area-inset-bottom, 85px)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
  }
  #explorationTracker {
    top: max(10px, env(safe-area-inset-top, 10px)) !important;
    font-size: 11px;
    padding: 6px 12px;
  }
  .related-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    height: auto;
  }
  .main-header h1 {
    font-size: 18px;
  }
  .main-header p {
    display: none;
  }
  .main-header {
    padding: 10px;
    border-radius: 8px;
  }
  .watermark {
    bottom: max(60px, env(safe-area-inset-bottom, 60px)) !important;
  }
  #channelDirectory {
    width: 100%;
    right: 0;
  }
}

/* Portrait Short Mode */
.video-container.short-video {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  padding: 10px;
}
.video-container.short-video #youtubePlayer {
  position: relative;
  width: auto;
  height: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 25px rgba(255, 0, 0, 0.25);
  background: #111;
}
.video-container.short-video iframe {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

