/**
 * Stylesheet chuyên biệt chuẩn 100% cho giao diện Canva Video Editor
 * Phong cách: Sáng thanh lịch (Light Workspace), Mặt bàn vẽ xám (#ebedf0), Tím Gradient Canva (#7d2ae8 -> #00c4cc)
 * Timeline: Dạng băng chuyền Slide Trang (Canva Page Cards)
 */

#view-canva {
  display: none;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #ebedf0;
  color: #111827;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
}

#view-canva.active {
  display: flex;
  flex-direction: column;
}

/* ========================================================================== */
/* 1. HEADER CANVA                                                           */
/* ========================================================================== */
.cv-header {
  height: 52px;
  background-color: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
  z-index: 20;
}

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

.cv-logo {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, cursive, sans-serif;
  font-weight: 900;
  font-size: 26px;
  background: linear-gradient(135deg, #7d2ae8 0%, #00c4cc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  cursor: pointer;
}

.cv-menu-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cv-menu-nav span {
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.cv-menu-nav span:hover {
  background: #f3f4f6;
  color: #111827;
}

.cv-doc-title-input {
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  max-width: 320px;
  outline: none;
}

.cv-doc-title-input:hover,
.cv-doc-title-input:focus {
  border-color: #d1d5db;
  background: #ffffff;
}

.cv-cloud-status {
  font-size: 11px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.cv-switch-theme-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #374151;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.cv-switch-theme-btn:hover {
  background: #e5e7eb;
}

.cv-btn-share {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #8b3dff 0%, #6b21a8 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  padding: 7px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(139, 61, 255, 0.3);
  transition: opacity 0.15s ease;
}

.cv-btn-share:hover {
  opacity: 0.92;
}

.cv-btn-panic {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #dc2626;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

/* ========================================================================== */
/* 2. KHÔNG GIAN LÀM VIỆC CANVA (SIDEBAR TỐI + NGĂN KÉO + MẶT BÀN VẼ)         */
/* ========================================================================== */
.cv-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cv-workspace-top {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* CỘT CÔNG CỤ DỌC MÀU TỐI ĐẶC TRƯNG CANVA (72px) */
.cv-left-sidebar {
  width: 72px;
  background-color: #0e1318;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  flex-shrink: 0;
  z-index: 10;
}

.cv-nav-item {
  width: 64px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #9ca3af;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cv-nav-item span {
  font-size: 10px;
  font-weight: 500;
}

.cv-nav-item:hover {
  color: #ffffff;
  background: #1f2937;
}

.cv-nav-item.active {
  color: #ffffff;
  background: #252627;
  font-weight: 700;
}

/* NGĂN KÉO TÀI NGUYÊN CANVA (DRAWER PANEL 320px) */
.cv-drawer-panel {
  width: 320px;
  background-color: #ffffff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
}

.cv-drawer-header {
  padding: 14px 14px 10px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.cv-search-wrap {
  padding: 0 14px 10px 14px;
  display: flex;
  gap: 6px;
}

.cv-search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.cv-search-input-wrap input {
  width: 100%;
  height: 36px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 0 12px 0 34px;
  font-size: 12px;
  color: #111827;
  outline: none;
}

.cv-search-input-wrap input:focus {
  border-color: #7d2ae8;
  background: #ffffff;
}

.cv-search-icon {
  position: absolute;
  left: 12px;
  pointer-events: none;
  fill: #8b3dff;
}

.cv-search-btn {
  height: 36px;
  padding: 0 14px;
  background: #7d2ae8;
  color: #ffffff;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cv-asset-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.cv-asset-card {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cv-asset-card:hover {
  background: #ffffff;
  border-color: #7d2ae8;
  box-shadow: 0 2px 8px rgba(125, 42, 232, 0.15);
}

.cv-asset-thumb-box {
  width: 96px;
  height: 54px;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #111827;
  flex-shrink: 0;
}

.cv-asset-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cv-asset-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.cv-asset-meta .cv-title {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.cv-asset-meta .cv-author {
  font-size: 11px;
  color: #6b7280;
}

/* ========================================================================== */
/* 3. MẶT BÀN VẼ CANVA (CANVAS WORKSPACE & TỜ GIẤY THIẾT KẾ NỔI BẬT)          */
/* ========================================================================== */
.cv-canvas-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #ebedf0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* THANH CÔNG CỤ NỔI CANVA FLOATING BAR */
.cv-floating-bar {
  height: 40px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.cv-tool-pill {
  padding: 4px 12px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cv-tool-pill:hover {
  background: #e5e7eb;
  color: #111827;
}

.cv-tool-pill.active {
  background: #fdf4ff;
  border-color: #7d2ae8;
  color: #7d2ae8;
  font-weight: 600;
}

/* Nút phóng to / thu nhỏ toàn màn hình Canva */
.cv-tool-pill-fs {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fdfaff;
  border-color: #d8b4fe;
  color: #7d2ae8;
  font-weight: 600;
  margin-left: auto;
}

.cv-tool-pill-fs:hover {
  background: #7d2ae8;
  color: #ffffff;
  border-color: #7d2ae8;
  box-shadow: 0 2px 6px rgba(125, 42, 232, 0.3);
}

/* MẶT BÀN LÀM VIỆC VÀ TRANG GIẤY VIDEO */
.cv-desk-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  min-height: 0;
  min-width: 0;
  position: relative;
}

/* TRANG THIẾT KẾ VIDEO 16:9 NỔI TRÊN MẶT BÀN */
.cv-page-frame {
  height: 100%;
  max-height: 100%;
  width: auto;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  background-color: #ffffff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 0 0 1px #d1d5db;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

/* TRẠNG THÁI PHÓNG TO TOÀN MÀN HÌNH CANVA (FULLSCREEN ACTIVE) */
.cv-page-frame.fullscreen-active {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  z-index: 999999 !important;
  background: #000000 !important;
  box-shadow: none !important;
}

/* Nút nổi thu nhỏ lại khi đang toàn màn hình Canva */
.cv-fs-exit-overlay-btn {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.cv-fs-exit-overlay-btn:hover {
  background: rgba(220, 38, 38, 0.85);
  border-color: #ef4444;
}

.cv-page-frame.fullscreen-active .cv-fs-exit-overlay-btn {
  display: inline-flex;
}

.cv-player-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000000;
}

.cv-player-iframe iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
}

.cv-stealth-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  background: transparent;
  cursor: pointer;
}

/* ========================================================================== */
/* LỚP PHỦ TẢI (LOADING) VÀ THÔNG BÁO LỖI (ERROR) CANVA                    */
/* ========================================================================== */
.cv-player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  box-sizing: border-box;
}

.cv-loading-overlay {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.cv-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(125, 42, 232, 0.2);
  border-top-color: #7d2ae8;
  border-right-color: #00c4cc;
  border-radius: 50%;
  animation: cvSpin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes cvSpin {
  to { transform: rotate(360deg); }
}

.cv-loading-text {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  letter-spacing: 0.3px;
}

.cv-error-overlay {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.cv-error-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.cv-error-title {
  font-size: 15px;
  font-weight: 700;
  color: #dc2626;
  margin-bottom: 6px;
}

.cv-error-desc {
  font-size: 12px;
  color: #4b5563;
  max-width: 320px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.cv-error-btn {
  padding: 6px 18px;
  background: #7d2ae8;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(125, 42, 232, 0.3);
}

.cv-error-btn:hover {
  background: #6b21a8;
  box-shadow: 0 4px 10px rgba(125, 42, 232, 0.4);
}

/* ========================================================================== */
/* 4. TIMELINE CANVA (BĂNG CHUYỀN SLIDE TRANG VIDEO)                         */
/* ========================================================================== */
.cv-timeline-footer {
  height: 185px;
  min-height: 185px;
  max-height: 185px;
  background-color: #ffffff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

/* THANH ĐIỀU KHIỂN PLAY VÀ THỜI LƯỢNG CANVA */
.cv-timeline-bar {
  height: 38px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.cv-transport-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cv-play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #7d2ae8;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(125, 42, 232, 0.3);
}

.cv-timecode {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  font-family: monospace;
}

/* THANH TIẾN TRÌNH KÉO TUA CHUYÊN NGHIỆP CANVA (SCRUBBER BAR) */
.cv-progress-container {
  flex: 1;
  margin: 0 18px;
  height: 28px;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  user-select: none;
}

.cv-progress-track {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  position: relative;
  transition: height 0.15s ease;
}

.cv-progress-container:hover .cv-progress-track {
  height: 8px;
}

.cv-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7d2ae8 0%, #00c4cc 100%);
  pointer-events: none;
  transition: width 0.05s linear;
}

.cv-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #ffffff;
  border: 2.5px solid #7d2ae8;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  opacity: 0.95;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.cv-progress-container:hover .cv-progress-thumb {
  transform: translate(-50%, -50%) scale(1.25);
  opacity: 1;
  box-shadow: 0 2px 8px rgba(125, 42, 232, 0.4);
}

.cv-transport-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cv-badge-status {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: 4px;
}

/* THANH MINI PROGRESS BAR DƯỚI ĐÁY SLIDE THUMBNAIL */
.cv-slide-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.cv-slide-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7d2ae8, #10b981);
  transition: width 0.05s linear;
}

/* BĂNG CHUYỀN SLIDES TRANG CANVA */
.cv-slides-track {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  overflow-x: auto;
}

.cv-page-card {
  width: 140px;
  height: 86px;
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.cv-page-card.active {
  border-color: #7d2ae8;
  box-shadow: 0 0 0 2px rgba(125, 42, 232, 0.25);
}

.cv-page-card-header {
  height: 22px;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 600;
  color: #4b5563;
}

.cv-page-card-thumb {
  flex: 1;
  background: #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.cv-badge-playing {
  font-size: 9px;
  font-weight: 700;
  color: #10b981;
  background: rgba(0, 0, 0, 0.75);
  padding: 1px 6px;
  border-radius: 3px;
}

.cv-add-page-btn {
  width: 110px;
  height: 86px;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.cv-add-page-btn:hover {
  border-color: #7d2ae8;
  color: #7d2ae8;
  background: #fdfaff;
}

/* BẢNG THÔNG BÁO NHANH PHÍM TẮT VIDEO CANVA (HUD TOAST: SPACE, <, >) */
.video-action-hud {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  letter-spacing: 0.5px;
}

.video-action-hud.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

