:root {
  --bg: #0c0c0e;
  --bg-sidebar: #111114;
  --bg-card: #1a1a1f;
  --bg-hover: #25252b;
  --bg-input: #1e1e24;
  --text: #f0f0f0;
  --text-muted: #8a8a96;
  --accent: #3dd68c;
  --accent-dim: rgba(61, 214, 140, 0.15);
  --border: #2a2a32;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 14px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 28px;
  padding: 0 8px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--bg-hover);
  color: var(--text);
}

.subs-section {
  margin-top: 28px;
}

.subs-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 10px;
}

.subs-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.subs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.15s;
}

.subs-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.subs-item .thumb {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-card);
  flex-shrink: 0;
}

.subs-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.premium-card {
  background: linear-gradient(145deg, #1a1a22, #15151a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.premium-card h4 {
  font-size: 14px;
  margin-bottom: 6px;
}

.premium-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.premium-card button {
  width: 100%;
  padding: 8px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.premium-card button:hover {
  background: var(--accent-dim);
}

/* ========== MAIN ========== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  gap: 20px;
  flex-shrink: 0;
}

.search-box {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
}

.search-box i {
  color: var(--text-muted);
  font-size: 14px;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

/* ========== CONTENT ========== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 40px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* Featured */
.featured {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 32px;
}

.featured-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  aspect-ratio: 16/9;
  transition: transform 0.2s;
}

.featured-card:hover {
  transform: scale(1.015);
}

.featured-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.featured-card .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 55%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
}

.featured-card .tags {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
}

.featured-card .duration {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 12px;
  background: rgba(0,0,0,0.7);
  padding: 3px 8px;
  border-radius: 4px;
}

.featured-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}

.featured-card .channel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.featured-card .channel img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

/* Categories */
.categories-section {
  margin-bottom: 28px;
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.video-card {
  cursor: pointer;
  transition: transform 0.18s;
}

.video-card:hover {
  transform: translateY(-3px);
}

.video-card .thumb-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--bg-card);
  margin-bottom: 10px;
}

.video-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-card .duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 11px;
  background: rgba(0,0,0,0.8);
  padding: 2px 6px;
  border-radius: 3px;
}

.video-card h4 {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card .meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
}

.video-card .meta img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.empty-msg {
  color: var(--text-muted);
  font-size: 14px;
  grid-column: 1 / -1;
  padding: 30px 0;
}

/* ========== PLAYER VIEW ========== */
.hidden {
  display: none !important;
}

.player-view {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-btn:hover {
  color: var(--text);
}

.player-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

.player-wrapper {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

#player {
  width: 100%;
  height: 100%;
}

.player-info {
  margin-top: 16px;
}

.player-info h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.3;
}

.player-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.player-meta > span {
  color: var(--text-muted);
  font-size: 14px;
}

.player-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.controls button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}

.controls button:hover {
  background: var(--bg-hover);
}

#playPauseBtn {
  font-size: 16px;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.progress-wrap span {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}

#progress, #volume {
  accent-color: var(--accent);
  cursor: pointer;
}

#progress {
  flex: 1;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

#volume {
  width: 80px;
}

/* Up Next */
.side-queue {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.side-queue h3 {
  font-size: 14px;
  margin-bottom: 14px;
  color: var(--text-muted);
}

.up-next-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.up-next-item {
  display: flex;
  gap: 10px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s;
}

.up-next-item:hover {
  background: var(--bg-hover);
}

.up-next-item img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.up-next-item .info h5 {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.up-next-item .info p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1100px) {
  .player-layout {
    grid-template-columns: 1fr;
  }
  .side-queue {
    max-height: 300px;
  }
}

@media (max-width: 800px) {
  .sidebar {
    display: none;
  }
  .featured {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 16px;
  }
  .topbar {
    padding: 12px 16px;
  }
}

/* Quality Selector */
.quality-wrap {
  position: relative;
}

.quality-btn {
  background: var(--bg-hover) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  padding: 6px 10px !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  display: flex !important;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.quality-btn:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.quality-menu {
  position: absolute;
  bottom: 110%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 110px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.quality-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.quality-menu button:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.quality-menu button.active {
  color: var(--accent);
  font-weight: 600;
}

/* Fullscreen & Mini Player */
.player-wrapper:-webkit-full-screen,
.player-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  background: #000;
}

.player-wrapper:-webkit-full-screen #player,
.player-wrapper:fullscreen #player {
  width: 100%;
  height: 100%;
}

/* Mini Player Mode */
body.mini-mode .sidebar,
body.mini-mode .topbar,
body.mini-mode .side-queue,
body.mini-mode .player-info,
body.mini-mode .back-btn,
body.mini-mode #browseView {
  display: none !important;
}

body.mini-mode .main {
  background: transparent;
}

body.mini-mode .content {
  padding: 0;
  overflow: visible;
}

body.mini-mode .player-view {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 360px;
  z-index: 9999;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  padding: 0;
  overflow: hidden;
}

body.mini-mode .player-layout {
  display: block;
}

body.mini-mode .player-wrapper {
  aspect-ratio: 16/9;
  border-radius: 12px 12px 0 0;
}

body.mini-mode .controls {
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  gap: 6px;
}

body.mini-mode .progress-wrap span,
body.mini-mode .quality-wrap,
body.mini-mode #prevBtn,
body.mini-mode #nextBtn {
  display: none;
}

body.mini-mode #volume {
  width: 50px;
}

body.mini-mode .player-main {
  width: 100%;
}
