/* ==========================================================================
   DỰ ÁN: AI VIDEO HUB - FILE CSS CHUẨN ĐỒNG BỘ THEO CẤU TRÚC TEMPLATE CŨ
   ========================================================================== */

:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #7c5cff;
  --accent-2: #5b8cff;
  --danger: #ff6b6b;
  --radius: 10px;
  --border-color: #262b35;
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: #7da2ff; }

/* ==========================================================================
   1. ĐỊNH DẠNG HEADER & MENU CHUẨN (FIXED/STICKY LÊN TRÊN CÙNG)
   Căn cứ theo thứ tự render của base.html gốc: Form tìm kiếm -> Khối điều hướng
   ========================================================================== */
.site-header {
  background: rgba(24, 27, 34, 0.95);
  border-bottom: 1px solid var(--border-color);
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 9999 !important;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Thẻ định dạng chữ thương hiệu "▶ {{ SITE_NAME }}" */
.brand {
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff !important;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}
.brand span { color: var(--danger); }

/* Khung form tìm kiếm bọc Input + Button nằm ở trung tâm */
.search {
  flex: 1 1 300px;
  max-width: 500px;
  display: flex;
  gap: 8px;
}
.search input {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  transition: all 0.2s;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}
.search button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.search button:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.3);
}

/* Khối điều hướng thành viên (Đăng nhập, Đăng ký, Đăng xuất, Admin) */
.user-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
}
.user-nav a {
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}
.user-nav a:hover {
  background: rgba(255,255,255,0.05);
}
/* Làm nổi bật nút Đăng xuất / Tên người dùng */
.user-nav button.link {
  background: none;
  border: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 12px;
}
.user-nav button.link:hover { color: var(--danger); }

/* Thanh danh mục phụ cuộn ngang nằm ngay dưới Navbar chính */
.cat-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
  border-top: 1px solid rgba(255,255,255,0.03);
}
.cat-bar::-webkit-scrollbar { height: 4px; }
.cat-bar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
.cat-bar a {
  color: var(--muted);
  padding: 4px 12px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid transparent;
}
.cat-bar a:hover, .cat-bar a.btn-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ==========================================================================
   2. KHUNG CHỨA NỘI DUNG CHÍNH (CONTAINER & MAIN)
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}
/* Đệm lùi padding-top để tránh phần header fixed che mất video */
main.container {
  padding-top: 110px !important; 
  padding-bottom: 48px;
  flex-grow: 1;
}

/* ==========================================================================
   3. HỆ THỐNG HIỂN THỊ VIDEO (CARDS & RESPONSIVE GRID)
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  margin-block: 16px 32px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: #383f4f;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #020617;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}
.card:hover .thumb img {
  transform: scale(1.05);
}
.thumb-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  background: #11141a;
}

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

.badge {
  position: absolute;
  left: 8px;
  top: 8px;
  background: rgba(24, 27, 34, 0.85);
  backdrop-filter: blur(4px);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-youtube { border: 1px solid rgba(255, 78, 69, 0.4); color: #ff6b6b; }
.badge-vimeo { border: 1px solid rgba(26, 183, 234, 0.4); color: #5bc0ff; }

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.card-title {
  margin: 0 0 8px;
  font-size: 0.98rem;
  line-height: 1.4;
  font-weight: 600;
}
.card-title a {
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s ease;
}
.card:hover .card-title a {
  color: var(--accent-2);
}
.meta {
  margin-top: auto;
  color: var(--muted);
  font-size: .85rem;
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   4. TIÊU ĐỀ TRANG VÀ THÀNH PHẦN KHÁC (TITLES & MESSAGES)
   ========================================================================== */
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 12px 0 20px;
  color: #fff;
}
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 32px 0 16px;
  color: #fff;
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.messages { list-style: none; padding: 0; margin: 0 0 24px; }
.msg { padding: 12px 16px; border-radius: 8px; background: var(--surface-2); margin-bottom: 10px; font-size: 0.95rem; border-left: 4px solid var(--muted); }
.msg.success { border-left-color: #3ecf8e; background: rgba(62, 207, 142, 0.05); }
.msg.error { border-left-color: var(--danger); background: rgba(255, 107, 107, 0.05); }

/* ==========================================================================
   5. NÂNG CẤP BIỂU MẪU ĐĂNG NHẬP / ĐĂNG KÝ (.FORM-CARD)
   ========================================================================== */
.form-card {
  max-width: 420px;
  margin: 40px auto;
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
.form-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 24px;
  text-align: center;
}
.form-card p { margin-block: 16px; }
.form-card p label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}
.form-card input[type=text], .form-card input[type=password], .form-card input[type=email] {
  width: 100%;
}
.form-card button, .form-card .btn {
  width: 100%;
  padding-block: 10px;
  margin-top: 12px;
}

/* ==========================================================================
   6. TRANG CHI TIẾT VIDEO (.DETAIL) & KHUNG PHÁT PHÁT VIDEO
   ========================================================================== */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.5); }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-title { font-size: 1.6rem; margin: 18px 0 8px; font-weight: 700; }
.description { background: var(--surface); padding: 18px; border-radius: var(--radius); margin: 16px 0; color: #cfd4de; border: 1px solid var(--border-color); }

/* ==========================================================================
   7. THANH PHÂN TRANG CHUẨN CẤU TRÚC LỚP (.PAGINATION)
   ========================================================================== */
.pagination {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 8px !important;
  margin: 36px 0 12px !important;
}
.pagination a {
  padding: 8px 16px;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}
.pagination a:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.2);
}
.pagination text, .pagination span {
  padding: 8px 14px;
  background: #0b0d10;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   8. CHÂN TRANG TRỰC QUAN (FOOTER)
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border-color);
  padding-block: 28px;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
  margin-top: auto;
}

@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  main.container { padding-top: 150px !important; } /* Đệm thêm cho di động khi navbar bẻ dòng */
}
