/* YouTube-Style Theme for Video Blog */
:root {
  --yt-bg: #0F0F0F;
  --yt-surface: #1A1A1A;
  --yt-surface-hover: #2A2A2A;
  --yt-border: #303030;
  --yt-text: #FFFFFF;
  --yt-text-secondary: #AAAAAA;
  --yt-accent: #FF0000;
  --yt-accent-hover: #CC0000;
  --yt-blue: #3B82F6;
  --yt-blue-hover: #60A5FA;
  --yt-success: #22C55E;
  --yt-warning: #F59E0B;
  --yt-error: #FF4444;
  --yt-radius: 12px;
  --yt-radius-sm: 8px;
  --yt-header-height: 56px;
  --yt-sidebar-width: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Roboto", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--yt-bg);
  color: var(--yt-text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.yt-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--yt-header-height);
  background: var(--yt-bg);
  border-bottom: 1px solid var(--yt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  gap: 16px;
}
.yt-header-left, .yt-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.yt-menu-btn {
  width: 40px; height: 40px;
  border: none; background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--yt-text);
}
.yt-menu-btn:hover { background: var(--yt-surface-hover); }
.yt-menu-btn span {
  display: block; width: 18px; height: 2px;
  background: currentColor; border-radius: 2px;
}
.yt-logo {
  display: flex; align-items: center; gap: 6px;
  font-size: 1.25rem; font-weight: 700;
  color: var(--yt-text); letter-spacing: -0.5px;
}
.yt-logo svg { width: 28px; height: 20px; }
.yt-logo-tv { color: var(--yt-accent); }

.yt-header-center {
  flex: 1;
  max-width: 640px;
  display: flex;
  justify-content: center;
}
.yt-search-form {
  display: flex;
  width: 100%;
  max-width: 640px;
  height: 40px;
}
.yt-search-input {
  flex: 1;
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-right: none;
  border-radius: 20px 0 0 20px;
  padding: 0 16px;
  color: var(--yt-text);
  font-size: 0.95rem;
  outline: none;
}
.yt-search-input::placeholder { color: #888; }
.yt-search-input:focus { border-color: #1c62b9; }
.yt-search-btn {
  width: 64px;
  background: var(--yt-surface-hover);
  border: 1px solid var(--yt-border);
  border-radius: 0 20px 20px 0;
  color: var(--yt-text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.yt-search-btn:hover { background: #3a3a3a; }

.yt-icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%; border: none;
  background: transparent; color: var(--yt-text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.yt-icon-btn:hover { background: var(--yt-surface-hover); }

.yt-avatar-btn {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  background: var(--yt-blue);
  color: #fff; font-weight: 700; font-size: 0.9rem;
  cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.yt-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Dropdown ---------- */
.yt-dropdown { position: relative; }
.yt-dropdown-menu {
  position: absolute;
  top: 48px; right: 0;
  min-width: 220px;
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-radius: var(--yt-radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 8px 0;
  display: none;
  z-index: 110;
}
.yt-dropdown.open .yt-dropdown-menu { display: block; }
.yt-dropdown-menu a, .yt-dropdown-menu button {
  display: block; width: 100%; text-align: left;
  padding: 10px 16px; background: none; border: none;
  color: var(--yt-text); font-size: 0.95rem; cursor: pointer;
}
.yt-dropdown-menu a:hover, .yt-dropdown-menu button:hover { background: var(--yt-surface-hover); }
.yt-dropdown-menu .sep { height: 1px; background: var(--yt-border); margin: 6px 0; }
.yt-dropdown-menu .role-tag { color: var(--yt-text-secondary); font-size: 0.8rem; padding: 4px 16px 8px; }

/* ---------- Sidebar ---------- */
.yt-sidebar {
  position: fixed;
  top: var(--yt-header-height); left: 0; bottom: 0;
  width: var(--yt-sidebar-width);
  background: var(--yt-bg);
  border-right: 1px solid var(--yt-border);
  padding: 12px 0;
  overflow-y: auto;
  z-index: 90;
  transform: translateX(0);
  transition: transform .25s ease;
}
.yt-sidebar.closed { transform: translateX(-100%); }
.yt-sidebar.closed ~ .yt-main { margin-left: 0; }
.yt-sidebar-section { padding: 8px 0; border-bottom: 1px solid var(--yt-border); }
.yt-sidebar-section:last-child { border-bottom: none; }
.yt-sidebar a {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 24px;
  color: var(--yt-text); font-size: 0.95rem;
  border-radius: 10px;
  margin: 0 12px 2px;
}
.yt-sidebar a:hover { background: var(--yt-surface-hover); }
.yt-sidebar a.active { background: var(--yt-surface-hover); font-weight: 500; }
.yt-sidebar a svg { width: 24px; height: 24px; flex-shrink: 0; fill: currentColor; opacity: .85; }
.yt-sidebar-title {
  padding: 8px 24px 6px;
  color: var(--yt-text-secondary); font-size: 0.8rem;
  font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
  margin: 0 12px;
}
.yt-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 85;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.yt-backdrop.open { opacity: 1; pointer-events: auto; }

/* ---------- Main Layout ---------- */
.yt-main {
  margin-left: var(--yt-sidebar-width);
  margin-top: var(--yt-header-height);
  min-height: calc(100vh - var(--yt-header-height));
  padding: 24px 32px 48px;
  transition: margin-left .25s ease;
}
.yt-main.full { margin-left: 0; }

@media (max-width: 1312px) {
  .yt-sidebar { transform: translateX(-100%); }
  .yt-sidebar.open { transform: translateX(0); }
  .yt-sidebar.closed { transform: translateX(-100%); }
  .yt-main { margin-left: 0; }
}

/* ---------- Alerts / Messages ---------- */
.alert {
  padding: 12px 16px; border-radius: var(--yt-radius-sm);
  margin-bottom: 16px; font-size: 0.95rem; border: 1px solid transparent;
}
.alert.success { background: rgba(34,197,94,.12); color: var(--yt-success); border-color: rgba(34,197,94,.3); }
.alert.error, .alert.danger { background: rgba(255,68,68,.12); color: var(--yt-error); border-color: rgba(255,68,68,.3); }
.alert.warning { background: rgba(245,158,11,.12); color: var(--yt-warning); border-color: rgba(245,158,11,.3); }
.alert.info { background: rgba(59,130,246,.12); color: var(--yt-blue); border-color: rgba(59,130,246,.3); }

/* ---------- Generic Content Helpers ---------- */
.yt-page-title {
  font-size: 1.5rem; font-weight: 700; margin: 0 0 8px;
}
.yt-page-subtitle { color: var(--yt-text-secondary); margin: 0 0 20px; }
.muted { color: var(--yt-text-secondary); }
.empty { color: var(--yt-text-secondary); text-align: center; padding: 40px 0; }
.topbar-title { font-size: 1.4rem; font-weight: 700; margin: 6px 0 16px; }
.pitch { color: var(--yt-text-secondary); margin-bottom: 18px; }

/* ---------- Buttons ---------- */
button, .btn {
  background: var(--yt-blue); color: #fff;
  border: none; border-radius: 18px;
  padding: 10px 18px; cursor: pointer;
  font-size: 0.95rem; font-weight: 600;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--yt-blue-hover); }
.btn.ghost {
  background: transparent; color: var(--yt-text);
  border: 1px solid var(--yt-border);
}
.btn.ghost:hover { background: var(--yt-surface-hover); }
.btn.red { background: var(--yt-accent); }
.btn.red:hover { background: var(--yt-accent-hover); }
.btn.grey { background: var(--yt-surface-hover); color: var(--yt-text); }
.btn.grey:hover { background: #3a3a3a; }

/* YouTube subscribe button */
.yt-sub-btn {
  border: none; border-radius: 18px;
  padding: 10px 18px; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  background: var(--yt-text); color: var(--yt-bg);
}
.yt-sub-btn:hover { background: #e6e6e6; }
.yt-sub-btn.subscribed { background: var(--yt-surface-hover); color: var(--yt-text); }
.yt-sub-btn.subscribed:hover { background: var(--yt-surface-hover); }

/* ---------- Cards (legacy) ---------- */
.card {
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-radius: var(--yt-radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card a { color: var(--yt-text); }
.card a:hover { color: var(--yt-blue-hover); }
.form-card { max-width: 460px; margin: 0 auto; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; color: var(--yt-text-secondary); font-size: 0.85rem; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--yt-surface);
  border: 1px solid var(--yt-border);
  border-radius: var(--yt-radius-sm);
  padding: 10px 12px;
  color: var(--yt-text); font-size: 0.95rem;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--yt-blue); }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: auto; }

/* ---------- Video Grid ---------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px 16px;
}
@media (max-width: 640px) {
  .video-grid { grid-template-columns: 1fr; gap: 18px 0; }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1600px) {
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
}

.video-card {
  display: block; text-decoration: none; color: inherit;
  cursor: pointer;
}
.video-card .thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--yt-radius);
  overflow: hidden;
  background: #000;
}
.video-card .thumb-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .2s ease;
}
.video-card:hover .thumb-wrap img { transform: scale(1.04); }
.video-card .play-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease;
}
.video-card:hover .play-overlay { opacity: 1; }
.video-card .play-overlay svg {
  width: 48px; height: 48px;
  fill: #fff; opacity: .95;
}
.video-card .duration-badge {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.8); color: #fff;
  font-size: 0.78rem; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
}
.video-card .rank-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--yt-accent); color: #fff;
  font-size: 0.75rem; font-weight: 700;
  padding: 3px 8px; border-radius: 4px;
}
.video-card .info {
  display: flex; gap: 12px; padding: 12px 0 0;
}
.video-card .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--yt-blue); color: #fff; font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  overflow: hidden;
}
.video-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.video-card .meta { flex: 1; min-width: 0; }
.video-card .meta h3 {
  font-size: 0.98rem; font-weight: 600;
  line-height: 1.35; margin: 0 0 6px;
  color: var(--yt-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.video-card .meta p {
  margin: 0; color: var(--yt-text-secondary); font-size: 0.86rem; line-height: 1.4;
}
.video-card .meta .author:hover { color: var(--yt-text); }

/* ---------- Watch Page ---------- */
.watch-layout { max-width: 1280px; margin: 0 auto; }
.watch-player {
  width: 100%; aspect-ratio: 16/9;
  background: #000; border-radius: var(--yt-radius);
  overflow: hidden;
}
.watch-player video, .watch-player iframe {
  width: 100%; height: 100%; object-fit: contain;
}
.watch-info { padding: 18px 0 28px; }
.watch-info h1 { font-size: 1.35rem; font-weight: 700; margin: 0 0 10px; }
.watch-meta {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  flex-wrap: wrap;
}
.watch-channel {
  display: flex; align-items: center; gap: 12px;
}
.watch-channel .avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--yt-blue); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.watch-channel .avatar img { width: 100%; height: 100%; object-fit: cover; }
.watch-channel .name { font-weight: 600; color: var(--yt-text); }
.watch-channel .subs { color: var(--yt-text-secondary); font-size: 0.82rem; }
.watch-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.watch-stats { color: var(--yt-text-secondary); font-size: 0.9rem; }
.watch-desc {
  background: var(--yt-surface); border-radius: var(--yt-radius);
  padding: 14px 16px; margin-top: 14px; line-height: 1.5;
  color: var(--yt-text);
}
.watch-desc .date { color: var(--yt-text-secondary); font-size: 0.85rem; margin-bottom: 6px; }

/* ---------- Related grid ---------- */
.related-title { font-size: 1.15rem; font-weight: 700; margin: 24px 0 14px; }

/* ---------- Tables (admin) ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--yt-text-secondary); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--yt-border); }
td { padding: 12px; border-bottom: 1px solid var(--yt-border); }
tr:hover td { background: var(--yt-surface-hover); }
.role-pill {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 600; border: 1px solid var(--yt-border); color: var(--yt-text-secondary);
}
.role-pill.administrator { color: var(--yt-error); background: rgba(255,68,68,.12); border-color: rgba(255,68,68,.35); }
.role-pill.dev { color: var(--yt-warning); background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); }
.role-pill.supporter { color: var(--yt-success); background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); }

/* ---------- Search box utility ---------- */
.search-box { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box input { flex: 1; min-width: 220px; }

/* ---------- Avatar ---------- */
.avatar-lg {
  width: 88px; height: 88px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--yt-border);
  background: var(--yt-surface); display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
}

/* ---------- Mobile Header tweaks ---------- */
@media (max-width: 640px) {
  .yt-header { padding: 0 10px; gap: 8px; }
  .yt-header-center { justify-content: flex-end; }
  .yt-search-form { max-width: none; }
  .yt-search-input { padding: 0 12px; font-size: 0.9rem; }
  .yt-search-btn { width: 44px; }
  .yt-main { padding: 16px 12px 40px; }
  .yt-logo-text { display: none; }
  .yt-logo svg { width: 26px; height: 18px; }
}
@media (max-width: 400px) {
  .yt-header-right .yt-icon-btn.notifications { display: none; }
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
