/* --- PREMIUM YOUTUBE MOBILE THEME DESIGN --- */

:root {
  /* YouTube Light Theme Palette */
  --yt-bg-primary: #ffffff;
  --yt-bg-secondary: #f9f9f9;
  --yt-text-primary: #0f0f0f;
  --yt-text-secondary: #606060;
  --yt-border: #f2f2f2;
  
  --yt-red: #ff0000;
  --yt-red-dark: #cc0000;
  --yt-chip-bg: #f2f2f2;
  --yt-chip-hover: #e5e5e5;
  --yt-chip-active-bg: #0f0f0f;
  --yt-chip-active-text: #ffffff;
  
  --yt-player-bg: rgba(255, 255, 255, 0.95);
  --yt-nav-bg: #ffffff;
  --yt-nav-border: #e5e5e5;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* YouTube OLED Black Theme Palette */
    --yt-bg-primary: #0f0f0f;
    --yt-bg-secondary: #212121;
    --yt-text-primary: #f1f1f1;
    --yt-text-secondary: #aaaaaa;
    --yt-border: #272727;
    
    --yt-red: #ff0000;
    --yt-red-dark: #cc0000;
    --yt-chip-bg: #272727;
    --yt-chip-hover: #3f3f3f;
    --yt-chip-active-bg: #ffffff;
    --yt-chip-active-text: #0f0f0f;
    
    --yt-player-bg: rgba(15, 15, 15, 0.95);
    --yt-nav-bg: #0f0f0f;
    --yt-nav-border: #272727;
  }
}

/* Base resets prioritizing premium typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--yt-bg-primary);
  color: var(--yt-text-primary);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-top: 50px; /* Space for Mobile Header */
  padding-bottom: 140px; /* Space for Bottom Nav + MinimPlayer */
}

/* Scrollbar customizations */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--yt-chip-hover);
  border-radius: 3px;
}

/* Material Symbols Icon config alignment */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  display: inline-block;
  vertical-align: middle;
}

.icon-fill {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Premium Header Bar */
#yt-mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background-color: var(--yt-bg-primary);
  border-bottom: 1px solid var(--yt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-left .yt-logo-icon {
  font-family: 'Material Symbols Outlined';
  color: var(--yt-red);
  font-size: 26px;
  font-variation-settings: 'FILL' 1;
}

.header-left .yt-logo-text {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.7px;
  color: var(--yt-text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-action-btn {
  background: none;
  border: none;
  color: var(--yt-text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-btn {
  position: relative;
}

.badge-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 8px;
  height: 8px;
  background-color: var(--yt-red);
  border-radius: 50%;
  border: 1px solid var(--yt-bg-primary);
}

.profile-avatar-circle {
  width: 28px;
  height: 28px;
  background-color: #ea580c;
  color: #ffffff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Layout Wrappers */
#pcwrap {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

#wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* Horizontally sliding Subscriptions Panel styling */
#filter {
  background-color: var(--yt-bg-primary);
  border-bottom: 1.5px solid var(--yt-border);
  padding: 10px 0 10px 0;
  position: sticky;
  top: 50px;
  z-index: 990;
}

.pclogo {
  font-size: 15px;
  font-weight: 700;
  padding: 0 16px 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-red-dot {
  width: 6px;
  height: 6px;
  background-color: var(--yt-red);
  border-radius: 50%;
}

/* Channel bubbles container */
.yt-channel-row {
  display: flex;
  overflow-x: auto;
  gap: 16px;
  padding: 4px 16px 8px 16px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Hide scrollbars */
}

.yt-channel-row::-webkit-scrollbar {
  display: none;
}

.yt-channel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  width: 64px;
}

.yt-channel-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: var(--yt-chip-bg);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: transform 0.15s ease;
  border: 1.5px solid transparent;
}

.yt-channel-circle img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.yt-all-icon {
  font-size: 26px;
  color: var(--yt-text-primary);
}

.yt-avatar-fallback {
  font-size: 18px;
  font-weight: bold;
  color: var(--yt-text-secondary);
}

/* Mini Blue Notification dot */
.yt-channel-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background-color: #3b82f6; /* Classic blue alert dot */
  border-radius: 50%;
  border: 2px solid var(--yt-bg-primary);
}

.yt-channel-label {
  font-size: 11px;
  color: var(--yt-text-secondary);
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}

/* Active State for Channel selections */
.yt-channel-item.active .yt-channel-circle {
  border-color: var(--yt-red);
  transform: scale(1.05);
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.2);
}

.yt-channel-item.active .yt-channel-label {
  color: var(--yt-text-primary);
  font-weight: 700;
}

/* Horizontal SubCategory chip items row */
#category-chips-row {
  display: flex;
  gap: 8px;
  padding: 8px 16px 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

#category-chips-row::-webkit-scrollbar {
  display: none;
}

.tab {
  background-color: var(--yt-chip-bg);
  color: var(--yt-text-primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab:hover {
  background-color: var(--yt-chip-hover);
}

.tab.active {
  background-color: var(--yt-chip-active-bg);
  color: var(--yt-chip-active-text);
  font-weight: 600;
}

/* --- PREMIUM YOUTUBE CARD DESIGN --- */
.post {
  display: flex;
  flex-direction: column;
  background-color: var(--yt-bg-primary);
  border-bottom: 6px solid var(--yt-border); /* Subtle section dividers instead of desktop borders */
  padding-bottom: 12px;
}

.yt-thumbnail-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #1a1a1a;
  overflow: hidden;
}

.yt-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.post:hover .yt-thumbnail {
  transform: scale(1.02);
}

.yt-thumbnail-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, #2a2a2a 0%, #121212 100%);
}

.yt-favicon-fallback {
  width: 48px;
  height: 48px;
  padding: 8px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  object-fit: contain;
}

.yt-domain-text {
  font-size: 13px;
  font-weight: 500;
  color: #aaaaaa;
}

.yt-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* Details Section directly below video image */
.yt-details {
  display: flex;
  gap: 12px;
  padding: 12px 14px 4px 14px;
}

.yt-avatar-container {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background-color: var(--yt-chip-bg);
}

.yt-channel-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.yt-info {
  flex: 1;
  min-width: 0;
}

.yt-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--yt-text-primary);
  line-height: 1.35;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-title a {
  text-decoration: none;
  color: inherit;
}

.yt-title a:hover {
  color: var(--yt-red);
}

.yt-metadata {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
  color: var(--yt-text-secondary);
}

.yt-channel-name {
  font-weight: 400;
}

.yt-dot {
  font-size: 10px;
}

.yt-date {
  font-weight: 400;
}

.yt-more-btn {
  background: none;
  border: none;
  color: var(--yt-text-primary);
  cursor: pointer;
  height: 36px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
}

/* Play Podcast Pills */
.yt-audio-trigger {
  margin-top: 8px;
}

.yt-play-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--yt-red);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.yt-play-pill span {
  font-size: 16px;
}

.yt-play-pill:hover {
  background-color: var(--yt-red-dark);
}

.yt-play-pill.playing {
  background-color: var(--yt-text-primary);
  color: var(--yt-bg-primary);
}

/* High-fidelity Playing highlight */
.post.nowplaying {
  background-color: var(--yt-border);
}

/* Hidden elements */
audio {
  display: none;
}

/* --- PREMIUM MINI FLOATING PLAYER (PIP style) --- */
#floating_player {
  position: fixed;
  left: 0;
  bottom: 49px; /* Sit cleanly above bottom nav bar */
  width: 100%;
  background-color: var(--yt-player-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--yt-border);
  z-index: 999;
  display: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#floating_player.show {
  display: block;
}

/* Top Progress Red Line Indicator */
#mini-progress-track {
  width: 100%;
  height: 2px;
  background-color: var(--yt-border);
  position: absolute;
  top: 0;
  left: 0;
}

#mini-progress-fill {
  height: 100%;
  background-color: var(--yt-red);
  width: 0%;
  transition: width 0.1s linear;
}

.player_meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 12px;
}

.player-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

#player-thumb-container {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background-color: #272727;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#player-current-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.music-note-icon {
  position: absolute;
  color: #ffffff;
  font-size: 18px;
  opacity: 0.5;
}

.player-text-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

span#title {
  font-size: 13px;
  font-weight: 500;
  color: var(--yt-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-subtitle {
  font-size: 11px;
  color: var(--yt-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

#speed, #plus30 {
  background: none;
  border: none;
  color: var(--yt-text-primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

#playpausebutton {
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  color: var(--yt-text-primary);
  cursor: pointer;
  font-size: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px;
}

@media (prefers-color-scheme: dark) {
  #playpausebutton {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  }
}

#playpausebutton.playing {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E") !important;
}

@media (prefers-color-scheme: dark) {
  #playpausebutton.playing {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E") !important;
  }
}

/* --- MOBILE BOTTOM NAVIGATION BAR --- */
#yt-bottom-navigation {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 49px;
  background-color: var(--yt-nav-bg);
  border-top: 1px solid var(--yt-nav-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom); /* iOS Swipe Bar compensation */
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--yt-text-secondary);
  font-size: 10px;
  flex: 1;
  height: 100%;
  gap: 2px;
}

.nav-item span.material-symbols-outlined {
  font-size: 22px;
}

.nav-label {
  font-weight: 500;
}

/* Center Highlighted Create Button */
.create-btn span {
  font-size: 34px !important;
  color: var(--yt-text-primary);
  margin-top: -4px;
}

.nav-item.active {
  color: var(--yt-text-primary);
}

.nav-item.active span.material-symbols-outlined {
  color: var(--yt-red); /* Active red indicator */
}

/* Desktop layout optimizations mimicking Premium layouts */
@media (min-width: 768px) {
  body {
    padding-top: 50px;
    padding-bottom: 0;
  }

  #pcwrap {
    display: flex;
    flex-direction: row;
    gap: 24px;
    padding: 24px;
    max-width: 1000px;
  }

  #filter {
    position: sticky;
    top: 74px;
    width: 240px;
    height: calc(100vh - 100px);
    background-color: var(--yt-bg-primary);
    border: 1px solid var(--yt-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    padding: 16px 10px;
    flex-shrink: 0;
  }

  .pclogo {
    display: block;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    padding-left: 6px;
  }

  .yt-channel-row {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 4px;
    padding: 0;
    margin-bottom: 16px;
  }

  .yt-channel-item {
    flex-direction: row;
    width: 100%;
    gap: 12px;
    padding: 8px;
    border-radius: 10px;
  }

  .yt-channel-item:hover {
    background-color: var(--yt-chip-hover);
  }

  .yt-channel-circle {
    width: 30px;
    height: 30px;
  }

  .yt-all-icon {
    font-size: 18px;
  }

  .yt-channel-label {
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--yt-text-primary);
  }

  .yt-channel-item.active {
    background-color: var(--yt-chip-bg);
  }

  .yt-channel-item.active .yt-channel-circle {
    transform: none;
    border: none;
  }

  #category-chips-row {
    padding: 0;
    gap: 6px;
    margin-top: auto;
  }

  #wrap {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
  }

  .post {
    border: 1px solid var(--yt-border);
    border-radius: 16px;
    overflow: hidden;
  }

  #yt-bottom-navigation {
    display: none;
  }

  #floating_player {
    bottom: 24px;
    right: 24px;
    left: auto;
    width: 360px;
    border: 1px solid var(--yt-border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
  }
}