:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #181818;
  --bg-card: #212121;
  --bg-card-hover: #2a2a2a;
  --bg-pill: #272727;
  --border-color: #383838;
  --text-main: #f1f1f1;
  --text-sub: #aaaaaa;
  --accent-red: #ff2a44;
  --accent-red-hover: #e01b34;
  --accent-blue: #3ea6ff;
  --nav-height: 60px;
  --sidebar-width: 240px;
  --card-radius: 12px;
}

body.light-theme {
  --bg-primary: #f9f9f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f0;
  --bg-pill: #eeeeee;
  --border-color: #e0e0e0;
  --text-main: #0f0f0f;
  --text-sub: #606060;
  --accent-red: #cc0000;
  --accent-red-hover: #aa0000;
  --accent-blue: #065fd4;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  overflow-x: hidden;
}

/* NAVBAR */
.navbar {
  position: sticky;
  top: 0;
  height: var(--nav-height);
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background-color: var(--bg-card);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.logo-icon {
  background: linear-gradient(135deg, var(--accent-red), #ff6b81);
  width: 34px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(255, 42, 68, 0.4);
}

.logo-text span {
  color: var(--accent-red);
}

/* SEARCH */
.nav-center {
  flex: 1;
  max-width: 620px;
  margin: 0 20px;
}

.search-container {
  display: flex;
  width: 100%;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 16px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px 0 0 20px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent-blue);
}

.clear-search {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 14px;
}

.search-submit-btn {
  width: 58px;
  height: 40px;
  background-color: var(--bg-pill);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 20px 20px 0;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-submit-btn:hover {
  background-color: var(--bg-card-hover);
}

/* NAV RIGHT */
.upload-btn {
  background-color: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.upload-btn:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--text-sub);
}

.notification-btn {
  position: relative;
}

.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background-color: var(--accent-red);
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

/* APP LAYOUT */
.app-layout {
  display: flex;
  min-height: calc(100vh - var(--nav-height));
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-primary);
  height: calc(100vh - var(--nav-height));
  position: sticky;
  top: var(--nav-height);
  padding: 12px 10px;
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: 74px;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .section-title,
.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 14px 0;
}

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

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
  padding: 12px 14px 6px;
  letter-spacing: 0.6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  color: var(--text-main);
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
}

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

.nav-item.active {
  background-color: var(--bg-card);
  font-weight: 700;
}

.nav-divider {
  border: none;
  height: 1px;
  background-color: var(--border-color);
  margin: 12px 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 6px;
  font-size: 0.75rem;
  color: var(--text-sub);
  line-height: 1.5;
}

.footer-links a {
  color: var(--text-sub);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  padding: 18px 28px;
  min-width: 0;
}

/* CATEGORIES BAR */
.categories-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 16px;
  scrollbar-width: none;
}
.categories-bar::-webkit-scrollbar { display: none; }

.pill {
  background-color: var(--bg-pill);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.pill:hover {
  background-color: var(--bg-card-hover);
}

.pill.active {
  background-color: var(--text-main);
  color: var(--bg-primary);
  border-color: var(--text-main);
}

/* HERO BANNER */
.hero-banner {
  background: linear-gradient(135deg, #1e272e, #0984e3);
  border-radius: var(--card-radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.live-pill {
  background-color: var(--accent-red);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #ffffff;
  border-radius: 50%;
  animation: pulseAnim 1.4s infinite;
}

@keyframes pulseAnim {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.hero-banner h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  max-width: 780px;
}

.hero-banner p {
  color: #dfe6e9;
  font-size: 0.95rem;
  max-width: 650px;
  margin-bottom: 18px;
}

.watch-live-btn {
  background-color: #ffffff;
  color: #0f0f0f;
  border: none;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.watch-live-btn:hover {
  background-color: #f1f2f6;
  transform: translateY(-2px);
}

/* VIDEO GRID */
.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.grid-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.video-counter {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px 18px;
}

.video-card {
  background-color: var(--bg-card);
  border-radius: var(--card-radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.video-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.3);
  border-color: var(--text-sub);
}

.thumb-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000;
}

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

.duration-tag {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-body {
  padding: 12px;
  display: flex;
  gap: 12px;
}

.creator-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.card-text {
  flex: 1;
  min-width: 0;
}

.video-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-main);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-creator {
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-bottom: 2px;
}

.video-stats {
  font-size: 0.78rem;
  color: var(--text-sub);
}

/* MODAL VIDEO PLAYER */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  background-color: var(--bg-secondary);
  width: 92%;
  max-width: 1040px;
  max-height: 92vh;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background-color: rgba(0,0,0,0.65);
  border: none;
  color: #ffffff;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 30;
}

.modal-close:hover {
  background-color: var(--accent-red);
}

.video-stage {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000;
}

.video-stage video {
  width: 100%;
  height: 100%;
  display: block;
}

.video-details-pane {
  padding: 20px 24px;
}

.modal-video-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-views-date {
  font-size: 0.88rem;
  color: var(--text-sub);
}

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

.action-btn {
  background-color: var(--bg-pill);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn:hover {
  background-color: var(--bg-card-hover);
}

.channel-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-primary);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.channel-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0984e3, #74b9ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.channel-name {
  font-weight: 700;
  font-size: 1rem;
}

.channel-subs {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.subscribe-btn {
  background-color: var(--text-main);
  color: var(--bg-primary);
  border: none;
  padding: 9px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.subscribe-btn.active {
  background-color: var(--bg-pill);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.video-description-box {
  background-color: var(--bg-primary);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

/* COMMENTS */
.comments-section h3 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.comment-count {
  font-size: 0.9rem;
  color: var(--text-sub);
  font-weight: normal;
}

.comment-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.comment-input-box {
  flex: 1;
  display: flex;
  gap: 10px;
}

.comment-input-box input {
  flex: 1;
  background-color: transparent;
  border: none;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 4px;
  font-size: 0.9rem;
  outline: none;
}

.comment-input-box input:focus {
  border-bottom-color: var(--accent-blue);
}

.comment-submit-btn {
  background-color: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comment-item {
  display: flex;
  gap: 12px;
}

.comment-author {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.comment-time {
  font-weight: normal;
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-left: 6px;
}

.comment-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.35;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 1500;
    transition: left 0.25s ease;
    box-shadow: 4px 0 16px rgba(0,0,0,0.5);
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .search-container {
    max-width: 100%;
  }
  .main-content {
    padding: 14px 16px;
  }
}
