/* ==========================================================================
   BEEVIDEO STUDIO - PROJECT GALLERY & YOUTUBE-STYLE CARDS
   ========================================================================== */

#page-duan {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px 48px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

#page-duan[hidden] {
  display: none !important;
}

/* ── Gallery Header ── */
.pg-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.pg-title-group h2 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.pg-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pg-counter-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}

/* ── Toolbar: Search, Filters, View Modes ── */
.pg-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pg-search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--control-line);
  border-radius: 20px;
  padding: 0 12px;
  height: 38px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pg-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 140, 0, 0.15);
}

.pg-search-box .btn-icon {
  color: var(--text-faint);
  margin-right: 8px;
}

.pg-search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
}

.pg-search-box input::placeholder {
  color: var(--text-faint);
}

.pg-search-clear {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.pg-search-clear:hover {
  color: var(--text);
}

/* Filter pills */
.pg-filter-group {
  display: flex;
  align-items: center;
  background: var(--surface);
  padding: 3px;
  border-radius: 20px;
  border: 1px solid var(--control-line);
  gap: 2px;
}

.pg-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.pg-filter-btn:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.pg-filter-btn.active {
  background: var(--accent);
  color: #fff;
}

/* View Mode Buttons */
.pg-view-toggle {
  display: flex;
  align-items: center;
  background: var(--surface);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--control-line);
  gap: 2px;
}

.pg-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pg-view-btn:hover {
  color: var(--text);
}

.pg-view-btn.active {
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.pg-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  height: 38px;
  border-radius: 19px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 140, 0, 0.25);
  transition: all 0.15s ease;
}

.pg-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.35);
}

/* ==========================================================================
   YOUTUBE-STYLE CARDS (GRID VIEW)
   ========================================================================== */
.pg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px 20px;
  padding: 6px 0 20px;
}

.yt-card {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* ── 16:9 Video Box (YouTube Aspect Ratio) ── */
.yt-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #09090b;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--line);
}

/* Portrait blur background */
.yt-thumb-blur {
  position: absolute;
  inset: -10px;
  width: calc(100% + 20px);
  height: calc(100% + 20px);
  object-fit: cover;
  filter: blur(14px) brightness(0.4);
  transform: scale(1.1);
  z-index: 1;
}

.yt-thumb-main {
  position: relative;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  z-index: 2;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s ease;
}

.yt-thumb-full {
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  transition: transform 0.25s ease;
}

.yt-card:hover .yt-thumb-main,
.yt-card:hover .yt-thumb-full {
  transform: scale(1.02);
}

/* Fallback Thumb */
.yt-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1e24 0%, #111115 100%);
  color: var(--text-faint);
  padding: 16px;
  text-align: center;
}

.yt-thumb-fallback svg {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  color: var(--accent);
}

.yt-thumb-fallback span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Badges */
.yt-badge-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  z-index: 3;
}

.yt-badge-frame {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(15, 15, 18, 0.8);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 3;
  text-transform: uppercase;
}

.yt-badge-frame.doc {
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.yt-badge-frame.ngang {
  border-color: rgba(168, 85, 247, 0.4);
  color: #c084fc;
}

.yt-badge-status {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  z-index: 3;
}

.yt-badge-status.ready {
  background: rgba(16, 185, 129, 0.85);
  color: #fff;
}

.yt-badge-status.draft {
  background: rgba(0, 0, 0, 0.65);
  color: var(--text-faint);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hover Autoplay Video Overlay */
.yt-card-hover-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  z-index: 5;
  pointer-events: none;
}

.yt-hover-mute-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: fadeIn 0.15s ease;
}

/* ── YouTube Card Meta Info ── */
.yt-card-meta {
  display: flex;
  gap: 12px;
  padding: 12px 2px 4px;
}

.yt-card-avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #ea580c 100%);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.yt-card-details {
  flex: 1;
  min-width: 0;
}

.yt-card-title {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}

.yt-card:hover .yt-card-title {
  color: var(--accent);
}

.yt-card-channel {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.yt-dot {
  font-size: 10px;
  opacity: 0.6;
}

.yt-card-stats {
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 5px;
}

.yt-stat-video {
  color: #10b981;
  font-weight: 600;
}

.yt-stat-draft {
  color: var(--text-faint);
}

/* Card Action Hover Footer */
.yt-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.yt-card:hover .yt-card-actions {
  opacity: 1;
}

.yt-btn-edit {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--control-line);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.yt-btn-edit:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.yt-btn-icon-only {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--control-line);
  border-radius: 8px;
  color: var(--text-faint);
  cursor: pointer;
  transition: all 0.15s ease;
}

.yt-btn-icon-only:hover {
  color: var(--text);
  background: var(--surface-strong);
}

/* ==========================================================================
   LIST VIEW
   ========================================================================== */
.pg-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 0 20px;
}

.yt-list-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.yt-list-row:hover {
  background: var(--surface-strong);
  border-color: var(--control-line);
  transform: translateX(3px);
}

.yt-list-media {
  flex: none;
  position: relative;
  width: 140px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yt-list-details {
  flex: 1;
  min-width: 0;
}

.yt-list-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yt-list-row:hover .yt-list-title {
  color: var(--accent);
}

.yt-list-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-faint);
  flex-wrap: wrap;
}

.yt-list-badge-status {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

.yt-list-badge-status.ready {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.yt-list-badge-status.draft {
  background: var(--surface-strong);
  color: var(--text-faint);
  border: 1px solid var(--line);
}

.yt-list-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Empty State */
.pg-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-faint);
}

.pg-empty svg {
  width: 48px;
  height: 48px;
  color: var(--text-faint);
  margin-bottom: 12px;
  opacity: 0.5;
}

.pg-empty h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text);
}

.pg-empty p {
  margin: 0 0 20px;
  font-size: 14px;
}

/* Back button in editor topbar */
.tb-quay-lai {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--control-line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 12px;
  transition: all 0.15s ease;
}

.tb-quay-lai:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
