/* ========================================
   DESIGN TOKENS — CSS variables for theming
   ======================================== */

:root {
  --bg: #ffffff;
  --bg-secondary: #f9f9f9;
  --text: #0f0f0f;
  --text-muted: #606060;
  --border: #e5e5e5;
  --hover: #f2f2f2;
  --chip-bg: #f2f2f2;
  --chip-bg-active: #0f0f0f;
  --chip-text-active: #ffffff;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  --header-height: 56px;
  --sidebar-width: 72px;
  --sidebar-width-expanded: 240px;
}

body.dark {
  --bg: #0f0f0f;
  --bg-secondary: #181818;
  --text: #f1f1f1;
  --text-muted: #aaaaaa;
  --border: #272727;
  --hover: #272727;
  --chip-bg: #272727;
  --chip-bg-active: #f1f1f1;
  --chip-text-active: #0f0f0f;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* ========================================
   RESET & BASE
   ======================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

button {
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

/* ========================================
   HEADER / NAVBAR
   ======================================== */

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  gap: 16px;
}

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

.nav-center {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: center;
  max-width: 720px;
  gap: 8px;
}

.logo-img {
  height: 22px;
  cursor: pointer;
  padding: 0 8px;
}

.profile-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text);
  transition: background-color 0.15s ease;
}

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

/* ========================================
   SEARCH BAR
   ======================================== */

.search-wrapper {
  display: flex;
  flex: 1;
  max-width: 540px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background-color: var(--bg);
  transition: border-color 0.15s ease;
}

.search-wrapper:focus-within {
  border-color: #1c62b9;
  box-shadow: 0 0 0 1px rgba(28, 98, 185, 0.2) inset;
}

.search-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 0 16px;
}

.search-wrapper input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  width: 64px;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

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

.mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text);
  transition: background-color 0.15s ease;
}

.mic-btn:hover {
  background-color: var(--hover);
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--bg);
  overflow-y: auto;
  padding: 12px 0;
  z-index: 50;
  transition: width 0.2s ease;
}

.sidebar.expanded {
  width: var(--sidebar-width-expanded);
}

.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
  margin: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  color: var(--text);
}

.sidebar-item:hover {
  background-color: var(--hover);
}

.sidebar-item.active {
  background-color: var(--hover);
}

.sidebar-icon {
  font-size: 20px;
  margin-bottom: 6px;
}

.sidebar-label {
  font-size: 10px;
  text-align: center;
}

/* When sidebar is expanded, switch to horizontal layout */
.sidebar.expanded .sidebar-item {
  flex-direction: row;
  justify-content: flex-start;
  padding: 10px 12px;
  margin: 2px 8px;
}

.sidebar.expanded .sidebar-icon {
  font-size: 22px;
  margin-bottom: 0;
  margin-right: 18px;
  width: 22px;
}

.sidebar.expanded .sidebar-label {
  font-size: 14px;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 0 24px 24px;
}

/* ========================================
   CATEGORY CHIPS
   ======================================== */

.chips {
  position: sticky;
  top: var(--header-height);
  background-color: var(--bg);
  display: flex;
  gap: 12px;
  padding: 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 10;
  border-bottom: 1px solid transparent;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 8px;
  background-color: var(--chip-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.chip.active {
  background-color: var(--chip-bg-active);
  color: var(--chip-text-active);
}

/* ========================================
   VIDEO GRID
   ======================================== */

.videos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px 16px;
  padding-top: 20px;
}

.video-link {
  text-decoration: none;
  color: inherit;
}

.video-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.thumbnail {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  transition: border-radius 0.2s ease, transform 0.2s ease;
}

.video-link:hover .thumbnail {
  border-radius: 0;
}

.video-info {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 12px 0;
}

.channel-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.video-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.video-title {
  font-weight: 500;
  font-size: 14px;
  margin: 0;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 900px) {
  .nav-center {
    max-width: none;
  }

  .search-wrapper {
    max-width: none;
  }

  .mic-btn {
    display: none;
  }
}

@media (max-width: 680px) {
  .navbar {
    padding: 0 8px;
    gap: 8px;
  }

  .nav-center {
    display: none;
  }

  .logo-img {
    height: 18px;
    padding: 0 4px;
  }

  .sidebar {
    width: 0;
    padding: 0;
  }

  .sidebar.expanded {
    width: var(--sidebar-width-expanded);
  }

  .main-content {
    margin-left: 0;
    padding: 0 12px 12px;
  }

  .videos {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}