/* -------------------- GLOBAL RESET -------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0c10;
  color: #eaeaea;
  overflow: hidden;
}

/* -------------------- APP LAYOUT -------------------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px;
  gap: 10px;
}

/* -------------------- HEADER -------------------- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  position: relative;
}

.header h1 {
  margin: 0;
  font-size: 24px;
  color: #45a29e;
}

/* -------------------- VIEWER FISHEYE -------------------- */
.viewer-fisheye {
  width: 46px;
  height: 46px;
  background: #111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.08);
  position: relative;
}

.viewer-fisheye-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.viewer-count {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.viewer-label {
  font-size: 9px;
  color: #aaa;
  margin-top: 2px;
}

/* -------------------- MAIN CONTENT -------------------- */
.main-content {
  display: flex;
  flex: 1;
  gap: 12px;
  overflow: hidden;
  min-height: 0;
}

/* -------------------- PLAYER -------------------- */
.main-player {
  flex: 2;
  position: relative;
  min-width: 0;
}

.player-container {
  width: 100%;
  height: 70vh;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #333;
  position: relative;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* -------------------- SIDEBAR -------------------- */
.sidebar {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

/* -------------------- CATEGORY TABS -------------------- */
.category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  flex: 0 0 auto;
}

.category-tab {
  flex: 0 0 auto;
  padding: 7px 12px;
  font-size: 12px;
  background: #1c1f26;
  border: 1px solid #2f333b;
  border-radius: 8px;
  color: #ddd;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.category-tab:hover { background: #2a2e36; }

.category-tab.active {
  background: #45a29e;
  color: #111;
  border-color: #45a29e;
}

/* -------------------- UPDATES -------------------- */
.updates-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  overflow: hidden;
  background: #1c1f26;
  border: 1px solid #2f333b;
  border-radius: 10px;
  padding: 8px 10px;
  flex: 0 0 auto;
  min-height: 40px;
}

.updates-label {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: #ffd54a;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.updates-track-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.updates-track {
  display: flex; /* horizontal scrolling for updates */
  gap: 20px;
  white-space: nowrap;
  will-change: transform;
}

.update-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 12px;
}

.update-chip::before {
  content: "•";
  color: #ffd54a;
  font-size: 14px;
  line-height: 1;
}

/* -------------------- TOP 10 VIEWED CHANNELS -------------------- */
.top-10 {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}

.top-10 h2 {
  margin: 0;
  font-size: 13px;
}

.top-10-channels {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  gap: 4px;
  padding-bottom: 4px;
}

.top-10-channels::-webkit-scrollbar {
  height: 6px;
}

.top-10-channels::-webkit-scrollbar-thumb {
  background: #45a29e;
  border-radius: 4px;
}

.top-10-card {
  flex: 0 0 60px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  background: #1a1d23;
  border: 1px solid #2f333b;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  text-align: center;
}

.top-10-card:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.18); }

.top-10-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  background: #111;
  padding: 2px;
}

.top-10-name {
  font-size: 8px;
  font-weight: 600;
  color: #fff;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.top-10-viewers {
  font-size: 7px;
  color: rgba(255,255,255,.7);
}

/* -------------------- SEARCH -------------------- */
.search-row {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.search-btn,
.fav-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: #1c1f26;
  border: 1px solid #2f333b;
  color: #fff;
  cursor: pointer;
  transition: .2s;
  font-size: 12px;
}

.search-btn:hover,
.fav-btn:hover { background: #45a29e; color: #111; }

/* -------------------- CHANNEL LIST -------------------- */
.channel-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  background: #1a1d23;
  border-radius: 8px;
  cursor: pointer;
  transition: .2s;
  border: 1px solid transparent;
  flex: 0 0 auto;
  max-height: 60px;
  min-height: 60px;
  overflow: hidden;
}

.channel-item:hover { background: #2a2e36; }
.channel-item.active { border-color: #45a29e; background: #20262d; }

.channel-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }

.channel-logo {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: contain;
  background: #111;
}

.channel-meta { display: flex; flex-direction: column; min-width: 0; }

.channel-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-online { font-size: 10px; color: #9aa3ad; }

.fav-toggle { border: none; background: transparent; color: #ffd54a; font-size: 16px; cursor: pointer; padding: 0 4px; flex-shrink: 0; }

/* -------------------- RADIO OVERLAY -------------------- */
#radioOverlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  overflow: hidden;
}

#radioOverlay.show { display: flex; }

#radioBg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(12px);
  transform: scale(1.08);
  opacity: .85;
}

#radioOverlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}

#radioOverlay > *:not(#radioBg) { position: relative; z-index: 2; }

#radioLogo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(255,255,255,.06);
  padding: 8px;
}

#radioTitle {
  margin-top: 12px;
  text-align: center;
  font-weight: 700;
  font-size: 18px;
}

/* -------------------- SCROLLBAR -------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #45a29e; border-radius: 4px; }

/* -------------------- CHAT ICON & BOX -------------------- */
#chatIcon {
  position: fixed; /* always visible */
  bottom: 20px;
  right: 80px; /* left of fisheye */
  width: 42px;
  height: 42px;
  background: #45a29e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: #111;
  z-index: 10000;
  user-select: none;
}

#chatIcon:hover { background: #66cfc8; }

#chatBox {
  display: none;
  position: fixed;
  bottom: 70px;
  right: 80px; /* aligned with chat icon */
  width: 280px;
  max-height: 400px;
  background: #1c1f26;
  border: 1px solid #333;
  border-radius: 12px;
  flex-direction: column;
  z-index: 9999;
}

#chatHeader { background: #45a29e; padding: 8px; text-align: center; font-weight: bold; color: #111; }
#chatMessages { flex: 1; padding: 8px; overflow-y: auto; font-size: 12px; padding-bottom: 50px; }
#chatInputWrap { display: flex; }
#chatInput { flex: 1; border: none; padding: 6px; outline: none; }
#sendMsg { background: #45a29e; border: none; color: #111; padding: 6px 10px; cursor: pointer; }

/* Close button */
.close-chat { float: right; background: transparent; border: none; color: #111; font-weight: bold; cursor: pointer; font-size: 14px; padding: 0 4px; }

/* -------------------- MOBILE RESPONSIVE -------------------- */
@media (max-width: 900px) {
  .main-content { flex-direction: column; gap: 0; height: 100%; }
  .main-player { flex: none; height: 27vh; width: 100%; }
  .player-container { height: 100%; border-radius: 0; border-left: none; border-right: none; }
  .sidebar { flex: 1; height: 73vh; overflow: hidden; padding: 8px; }
}

@media (max-width: 480px) {
  #chatIcon { right: 10px; bottom: 20px; }
  #chatBox { right: 10px; width: 90%; max-height: 250px; bottom: 70px; }
}

/* -------------------- BLINK -------------------- */
@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.2; } 100% { opacity: 1; } }
.blink { animation: blink 1s infinite; }
/* -------------------- XTREME ALERT -------------------- */
.xtreme-alert {
  background: linear-gradient(135deg, #1a0000, #330000);
  border: 1px solid #ff3c3c;
  color: #ffb3b3;
  animation: pulseGlow 1.2s infinite;
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 5px #ff0000;
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 20px #ff3c3c, 0 0 40px #ff0000;
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 5px #ff0000;
    transform: scale(1);
  }
}
