:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-hover: #f1f3f5;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #ef4444;
  --primary-hover: #dc2626;
  --accent: #2563eb;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  --radius: 12px;
}

body.dark {
  --bg: #0f0f0f;
  --surface: #181818;
  --surface-hover: #272727;
  --border: #2e2e2e;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.2s, color 0.2s;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.announcement-banner {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 18px;
  text-align: center;
}

/* Login Gate */
.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-brand h1 {
  font-size: 1.4rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 11px;
}

.error-text {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
}

.login-hint {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.login-hint code {
  background: var(--surface-hover);
  padding: 2px 6px;
  border-radius: 4px;
}

.back-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-icon {
  background: var(--primary);
  color: #fff;
  width: 32px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.nav-center {
  flex: 1;
  max-width: 560px;
}

.search-box {
  display: flex;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 16px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.search-box button {
  border: none;
  background: var(--surface-hover);
  color: var(--text);
  padding: 0 18px;
  cursor: pointer;
  border-left: 1px solid var(--border);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-danger-outline:hover {
  background: var(--primary);
  color: #fff;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

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

/* Layout */
.app-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.sidebar {
  width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  flex-shrink: 0;
  transition: width 0.2s, transform 0.2s;
}

.sidebar.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}

.sidebar-nav, .sidebar-categories {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover, .nav-item.active {
  background: var(--surface-hover);
  font-weight: 600;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Category Chips */
.category-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.chip {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

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

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.badge {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: var(--shadow);
}

.video-card:hover {
  transform: translateY(-3px);
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #1e293b;
  overflow: hidden;
}

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

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

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

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #f97316);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.video-info h3 {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-meta {
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* Watch View */
.watch-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}

.player-wrapper {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.player-wrapper iframe,
.player-wrapper video {
  width: 100%;
  height: 100%;
  border: none;
}

.watch-title {
  font-size: 1.35rem;
  margin-bottom: 14px;
}

.watch-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.channel-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-name {
  font-weight: 600;
}

.sub-count {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-subscribe {
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 8px 16px;
}

.btn-subscribe.subscribed {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.watch-actions {
  display: flex;
  gap: 10px;
}

.action-pill {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.action-pill.liked {
  border-color: var(--accent);
  color: var(--accent);
}

.description-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 16px 0 24px;
}

.desc-stats {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.tag {
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.status-published {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.status-private {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* Comments */
.comments-section h3 {
  margin-bottom: 14px;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.comment-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.comment-input-row {
  display: flex;
  gap: 8px;
}

.comment-input-row input {
  flex: 1;
}

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

.comment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

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

.comment-date {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-left: 6px;
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.related-card {
  display: flex;
  gap: 10px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}

.related-card img {
  width: 130px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
}

.related-info h4 {
  font-size: 0.88rem;
  margin-bottom: 4px;
}

/* Admin Dashboard */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.admin-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.admin-card h2 {
  font-size: 1.15rem;
  margin-bottom: 16px;
}

.admin-two-col {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea,
.admin-search {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.table-responsive {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table-video-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-video-cell img {
  width: 68px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
}

.table-actions {
  display: flex;
  gap: 6px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 999;
}

@media (max-width: 960px) {
  .watch-layout,
  .admin-two-col {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 90;
  }
}
