/* =========================================
   GLOBAL + THEME VARIABLES
========================================= */
:root{
  --bg: #ffffff;
  --surface: #ffffff;
  --muted: #606060;
  --text: #000000;
  --border: #ddd;
  --card-shadow: rgba(0,0,0,0.06);
  --accent: #e0e0e0;
}

/* Dark mode variables (true black background) */
body.dark-mode {
  --bg: #000000;            /* main page background (true black) */
  --surface: #0f0f0f;       /* surfaces (slightly lighter than pure black) */
  --muted: #b3b3b3;
  --text: #ffffff;
  --border: #202020;
  --card-shadow: rgba(0,0,0,0.8);
  --accent: #242424;
}

/* =========================================
   GLOBAL RESET
========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Roboto", sans-serif;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* link default color */
a { color: inherit; }

/* =========================================
   HEADER
========================================= */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1002;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}

.logo {
  height: 25px;
  cursor: pointer;
}

.search-bar {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 600px;
}

.search-bar input {
  width: 80%;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 20px 0 0 20px;
  padding: 0 15px;
  font-size: 14px;
}

.search-bar button {
  height: 36px;
  width: 50px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 20px 20px 0;
  background: var(--accent);
  cursor: pointer;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  position: relative;
  color: var(--text);
}

.create-btn {
  position: relative;
}

.create-dropdown {
  position: absolute;
  top: 40px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  width: 180px;
  overflow: hidden;
  z-index: 1003;
}

.create-dropdown a {
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}

.create-dropdown a:hover {
  background: var(--accent);
}

.create-btn.active .create-dropdown {
  display: flex;
}

.user-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* =========================================
   SIDEBAR
========================================= */
.sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  width: 80px; /* collapsed width by default on large screens */
  height: calc(100vh - 60px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 0.25s ease, left 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 1001;
  overflow: hidden;
}

.sidebar.expanded {
  width: 240px;
}

/* Mobile overlay-state class */
.sidebar.active {
  /* used on small screens to slide in overlay */
  left: 0;
  width: 240px;
  box-shadow: 2px 0 8px rgba(0,0,0,0.4);
}

/* Sidebar content scroll area */
.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 10px;
}

.menu-section {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
}

.menu-section a {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}

.menu-section a:hover {
  background-color: var(--accent);
}

.menu-section i {
  font-size: 18px;
  width: 30px;
  text-align: center;
  color: var(--text);
}

.menu-section span {
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.2s, transform 0.2s;
  color: var(--text);
}

.sidebar.expanded .menu-section span,
@media (max-width: 768px) {
  /* on small screens, when sidebar slides in, show labels */
  .sidebar.active .menu-section span { opacity: 1; transform: translateX(0); }
}

.sidebar.expanded .menu-section span {
  opacity: 1;
  transform: translateX(0);
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.menu-heading {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 16px;
  display: none;
}

.sidebar.expanded .menu-heading {
  display: block;
}

/* =========================================
   SIDEBAR FOOTER
========================================= */
.sidebar-footer {
  padding: 10px 16px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  flex-shrink: 0;
}

.sidebar-footer p {
  margin-top: 6px;
}

.footer-links {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.footer-links span {
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s;
}

.footer-links span:hover {
  color: var(--text);
}

/* =========================================
   OVERLAY (for mobile sidebar)
========================================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* =========================================
   CATEGORY BAR
========================================= */
.category-bar {
  margin-top: 60px;
  margin-left: 80px;
  padding: 8px 20px;
  overflow-x: auto;
  white-space: nowrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: margin-left 0.25s ease;
}

.sidebar.expanded ~ .category-bar {
  margin-left: 240px;
}

.category-bar button {
  display: inline-block;
  margin-right: 10px;
  padding: 6px 15px;
  border: none;
  border-radius: 20px;
  background: var(--accent);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
  color: var(--text);
}

.category-bar button.active,
.category-bar button:hover {
  background: var(--border);
}

/* =========================================
   MAIN CONTENT
========================================= */
.main-content {
  margin-top: 10px;
  margin-left: 80px;
  padding: 10px 20px;
  transition: margin-left 0.25s ease;
  min-height: calc(100vh - 120px);
}

.sidebar.expanded ~ .main-content {
  margin-left: 240px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.video-card {
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px var(--card-shadow);
}

.video-card:hover {
  transform: translateY(-4px);
}

.video-thumb {
  width: 100%;
  height: 180px;
  background: #333;
  background-size: cover;
  background-position: center;
}

.video-info {
  padding: 10px;
  display: flex;
  gap: 10px;
}

.video-info img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.video-info div h4 {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text);
}

.video-info div p {
  font-size: 12px;
  color: var(--muted);
}

/* =========================================
   FOOTER
========================================= */
footer {
  margin-left: 80px;
  padding: 15px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--border);
  transition: margin-left 0.25s ease;
}

.sidebar.expanded ~ footer {
  margin-left: 240px;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 1024px) {
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (max-width: 768px) {
  /* On small screens we make the sidebar hidden by default and overlayed when active */
  header { padding: 0 12px; }
  .menu-btn { display: inline-block; }

  .sidebar {
    left: -260px; /* hide off-canvas */
    width: 240px;
  }

  /* make labels visible only when sidebar is active */
  .sidebar .menu-section span { display: inline-block; opacity: 0; transform: translateX(-10px); }

  .sidebar.active .menu-section span { opacity: 1; transform: translateX(0); transition: opacity 0.2s, transform 0.2s; }

  .category-bar,
  .main-content,
  footer {
    margin-left: 0;
  }

  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .search-bar input { width: 70%; }
}
