/* ==========================================================
   XamVoz Video Streamer - Ultra Smooth 60fps Architecture
   Tối ưu triệt để: GPU-Accelerated, Zero-Lag, No Heavy Blurs
   ========================================================== */

:root {
  --bg-deep: #06080d;
  --bg-surface: #0a0e17;
  --bg-card: #0f1624;
  --bg-card-hover: #182338;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.18);

  --primary: #06b6d4;
  --primary-glow: rgba(6, 182, 212, 0.3);
  --emerald: #10b981;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;

  --header-height: 56px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-main);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar nhẹ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: var(--radius-pill); }

/* ================= HEADER BAR ================= */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.logo-icon {
  font-size: 20px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
}

.brand-name .highlight {
  color: var(--primary);
}

.brand-sub {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--emerald);
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-pill);
  font-size: 11px;
  color: #6ee7b7;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--emerald);
  border-radius: 50%;
}

.header-center {
  display: flex;
  align-items: center;
}

.view-switch-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  border-radius: var(--radius-pill);
}

.view-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.view-tab-btn.active {
  background: #0e7490;
  color: #fff;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  outline: none;
}

.btn-primary {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11.5px;
  border-radius: var(--radius-sm);
}

.grid-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-progress-bar-wrap {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-progress-bar-wrap.hidden {
  display: none !important;
}

.preview-progress-text {
  font-size: 12px;
  color: #38bdf8;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.preview-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.v-card-thumb-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.video-grid-card:hover .v-card-thumb-video.is-active-preview {
  opacity: 1;
}

.v-card-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.02) 75%);
  background-size: 200% 100%;
  animation: shimmerAnim 1.6s infinite;
}

@keyframes shimmerAnim {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
  border-radius: var(--radius-md);
}

/* ================= MAIN CONTAINER ================= */
.app-main {
  position: absolute;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* ================= GRID VIEW ================= */
.grid-section {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 18px 24px 60px;
  -webkit-overflow-scrolling: touch;
}

.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.search-input {
  width: 300px;
  max-width: 100%;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: #fff;
  font-family: var(--font-main);
  font-size: 12.5px;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

.grid-count-info {
  font-size: 12.5px;
  color: var(--text-muted);
}

.grid-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.video-grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
}

.video-grid-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-bright);
  background: var(--bg-card-hover);
}

.v-card-thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #020408;
  position: relative;
  overflow: hidden;
}

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

.v-card-duration-tag {
  position: absolute;
  bottom: 6px;
  right: 6px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  border-radius: 4px;
}

.v-card-play-hover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 28px;
  opacity: 0;
  transition: opacity 0.15s;
}

.video-grid-card:hover .v-card-play-hover {
  opacity: 1;
}

.v-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.v-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.v-card-host {
  font-size: 11px;
  color: var(--primary);
  font-family: var(--font-mono);
}

/* ========================================================
   CINEMA VIEWER OVERLAY (XEM VÀ LƯỚT TẠI THƯ VIỆN LƯỚI)
   ======================================================== */
.cinema-overlay {
  position: fixed;
  inset: 0;
  background: #020305;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.cinema-close-btn {
  position: absolute;
  top: 16px;
  left: 20px;
  z-index: 160;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-bright);
  color: #fff;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

.cinema-close-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
}

.cinema-counter-badge {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 160;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
}

.cinema-stage-box {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cinema-media-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.cinema-video-el {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.cinema-iframe-el {
  width: 100%;
  height: 100%;
  border: none;
}

/* Play indicator */
.cinema-play-ripple {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 20;
}

.cinema-stage-box.is-paused .cinema-play-ripple {
  opacity: 1;
}

/* Navigation arrows */
.cinema-nav-arrow {
  position: absolute;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-bright);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  transition: transform 0.15s, background 0.15s;
}

.cinema-nav-arrow:hover {
  background: var(--primary);
  transform: scale(1.1);
}

.arrow-up { top: 40%; }
.arrow-down { top: 52%; }

/* Bottom Bar */
.cinema-bottom-bar,
.reel-overlay-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 20px 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-slider-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeline-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  cursor: pointer;
  position: relative;
  transition: height 0.15s;
}

.timeline-track:hover { height: 7px; }

.timeline-fill {
  height: 100%;
  width: 0%;
  background: #38bdf8;
  border-radius: var(--radius-pill);
}

.time-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.cinema-info-row,
.reel-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cinema-text-col,
.meta-text-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.cinema-title,
.reel-v-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cinema-link,
.reel-v-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cinema-btns-col,
.meta-actions-col {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: #fff;
}

/* ================= REEL SECTION (TAB RIÊNG NẾU DÙNG) ================= */
.reel-section {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-cinema-card {
  width: 100%;
  max-width: 900px;
  height: 100%;
  background: #000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-media-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel-center-play-indicator {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}

.reel-cinema-card.is-paused .reel-center-play-indicator {
  opacity: 1;
}

.reel-side-rail {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 30;
}

.rail-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-bright);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.rail-btn:hover {
  background: var(--primary);
  transform: scale(1.1);
}

.rail-counter {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--primary);
}

/* ================= EMPTY STATE ================= */
.empty-state-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.empty-card-box {
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-emoji { font-size: 44px; }
.empty-card-box h2 { font-size: 17px; font-weight: 800; color: #fff; }
.empty-card-box p { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.empty-btns { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; }

/* ================= MODAL DIALOGS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 8, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 540px;
  background: #0c121e;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-top {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-heading { display: flex; align-items: center; gap: 8px; }
.modal-heading h3 { font-size: 14.5px; font-weight: 800; color: #fff; }
.dialog-close-btn { background: transparent; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; }

.modal-content {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-sub { font-size: 12px; color: var(--text-muted); }
.textbox-area { display: flex; flex-direction: column; gap: 6px; }

textarea#pasteTextarea {
  width: 100%;
  height: 150px;
  background: #04070d;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px;
  resize: vertical;
  outline: none;
}

textarea#pasteTextarea:focus { border-color: var(--primary); }
.textbox-meta { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; }
.link-btn { background: transparent; border: none; color: #38bdf8; cursor: pointer; font-size: 11.5px; font-weight: 700; }

.modal-bottom {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.keys-table { display: flex; flex-direction: column; gap: 6px; }
.key-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.k-key kbd { background: #1e293b; border: 1px solid #475569; border-radius: 4px; padding: 2px 6px; font-family: var(--font-mono); font-size: 11px; color: #38bdf8; }

/* TOAST */
.toast-hub {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 999;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  background: #0f172a;
  border: 1px solid var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hidden { display: none !important; }

/* ================= MOBILE ================= */
@media (max-width: 768px) {
  .app-header { height: 50px; padding: 0 12px; }
  .brand-sub, .header-badge { display: none; }
  .grid-feed { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-section { padding: 12px 10px 40px; }
  .cinema-nav-arrow { display: none; }
  .cinema-close-btn { top: 12px; left: 12px; padding: 5px 12px; font-size: 12px; }
  .cinema-counter-badge { top: 14px; right: 12px; font-size: 11px; }
  .cinema-bottom-bar { padding: 16px 12px 10px; }
  .cinema-title { font-size: 12.5px; }
  .cinema-video-el { object-fit: contain; }
}
