/**
 * Video generator — narrow centered layout + equal panels
 */

/* Page — tight top/bottom, narrow sides */
.vg-section {
  padding: 1.25rem 1rem 1.5rem;
}

.vg-narrow {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 576px) {
  .vg-section {
    padding: 1.5rem 1.25rem 1.75rem;
  }

  .vg-narrow {
    max-width: 1120px;
  }
}

@media (min-width: 992px) {
  .vg-section {
    padding: 1.5rem 1.5rem 2rem;
  }

  .vg-narrow {
    max-width: 1140px;
  }
}

/* Three-column layout — equal height panels */
.vg-layout-row {
  align-items: stretch;
}

.vg-layout-row > [class*='col-'] {
  display: flex;
  flex-direction: column;
}

.vg-templates-col,
.vg-equal-col {
  min-height: 0;
}

.vg-templates-panel,
.vg-equal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1 1 auto;
  min-height: 100%;
  height: 100%;
}

.vg-templates-panel {
  padding: 1rem 0.95rem 1.05rem !important;
  overflow: hidden;
}

.vg-templates-panel__icon {
  flex-shrink: 0;
  font-size: 1.35rem;
  color: var(--cb-accent, #f97316);
  margin-top: 0.1rem;
}

.vg-templates-panel__meta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cb-heading, #1f2937);
}

.vg-templates-panel__head {
  flex-shrink: 0;
  margin-bottom: 0.85rem;
}

.vg-templates-panel__hint {
  margin-top: 0.45rem;
  line-height: 1.4;
}

.vg-tpl-grid {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.15rem 0.25rem 0.15rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(249, 115, 22, 0.45) transparent;
}

.vg-tpl-grid::-webkit-scrollbar {
  width: 5px;
}

.vg-tpl-grid::-webkit-scrollbar-thumb {
  background: rgba(249, 115, 22, 0.45);
  border-radius: 4px;
}

.vg-tpl-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: 0.5rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  background: #fafafa;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.vg-tpl-card:hover {
  border-color: rgba(249, 115, 22, 0.45);
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.vg-tpl-card.is-selected {
  border-color: var(--cb-accent, #f97316);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15), 0 8px 20px rgba(249, 115, 22, 0.12);
}

.vg-tpl-card__frame {
  position: relative;
  display: block;
  width: 150px;
  height: 150px;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 0.55rem;
  overflow: hidden;
  background: linear-gradient(145deg, #1f2937 0%, #0f172a 100%);
}

.vg-tpl-card__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.vg-tpl-card__video.is-thumb-loading {
  opacity: 0.4;
}

.vg-tpl-card__video.is-thumb-ready {
  opacity: 1;
}

.vg-tpl-card__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.18s ease;
}

.vg-tpl-card__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.vg-tpl-card:hover .vg-tpl-card__play {
  opacity: 1;
  transform: scale(1.05);
}

.vg-tpl-card.is-selected .vg-tpl-card__shade {
  opacity: 0.55;
}

.vg-tpl-card__badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: var(--cb-accent, #f97316);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.vg-tpl-card.is-selected .vg-tpl-card__badge {
  opacity: 1;
  transform: scale(1);
}

.vg-tpl-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.45rem;
  min-width: 0;
}

.vg-tpl-card__name {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--cb-heading, #1f2937);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vg-tpl-card__action {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--cb-muted, #6b7280);
  transition: color 0.18s ease;
}

.vg-tpl-card:hover .vg-tpl-card__action {
  color: var(--cb-accent, #f97316);
}

.vg-tpl-card.is-selected .vg-tpl-card__action {
  font-size: 0;
  color: var(--cb-accent, #f97316);
}

.vg-tpl-card.is-selected .vg-tpl-card__action::after {
  content: 'Currently active';
  font-size: 0.65rem;
}

.vg-tpl-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 0.5rem;
  text-align: center;
}

.vg-tpl-loader__text {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--cb-muted, #6b7280);
}

.vg-templates-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  padding: 1.25rem 0.75rem;
  border: 1px dashed #d1d5db;
  border-radius: 0.65rem;
  background: #f9fafb;
}

.vg-templates-empty i {
  font-size: 1.75rem;
  color: #9ca3af;
}

.vg-selected-template-name {
  font-weight: 700;
  color: var(--cb-accent, #f97316);
}

@media (min-width: 992px) {
  .vg-layout-row {
    min-height: 28rem;
  }

  .vg-templates-empty {
    flex: 1 1 auto;
    min-height: 0;
  }
}

@media (max-width: 991.98px) {
  .vg-tpl-grid {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.75rem;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.35rem;
  }

  .vg-tpl-grid__item {
    flex: 0 0 auto;
    width: min(170px, 48vw);
  }

  .vg-tpl-card__frame {
    width: 150px;
    height: 150px;
  }

  .vg-tpl-card {
    padding: 0.4rem;
  }

  .vg-tpl-card__body {
    margin-top: 0.35rem;
  }

  .vg-tpl-card__name {
    font-size: 0.75rem;
  }

  .vg-tpl-card__action {
    display: none;
  }
}

.vg-page-head {
  margin-bottom: 0.65rem !important;
  padding: 0.75rem 1rem !important;
}

.vg-page-desc {
  margin-bottom: 1rem !important;
  font-size: 0.9rem;
  line-height: 1.45;
}

.vg-section .cb-glance-icon {
  margin-bottom: 0.4rem !important;
  font-size: 1.25rem !important;
}

.vg-section .cb-glance-label {
  margin-bottom: 0.15rem !important;
}

.vg-section .cb-glance-value.small {
  line-height: 1.35;
}

.vg-page {
  width: 100%;
}

@media (min-width: 992px) {
  .vg-equal-card.cb-glance-card {
    min-height: 0;
    padding: 0.9rem 0.95rem 1rem;
  }
}

.vg-equal-card.cb-glance-card {
  padding: 1rem 0.95rem 1.05rem;
}

.vg-equal-card__head {
  flex-shrink: 0;
  margin-bottom: 0.65rem;
}

.vg-equal-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.vg-equal-card__body--preview {
  align-items: center;
  justify-content: center;
}

.vg-equal-card__body--form {
  justify-content: flex-start;
}

/* Form fills half column */
.vg-form-fill {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.vg-form-fill .form-control {
  width: 100%;
  max-width: 100%;
}

@media (min-width: 992px) {
  .vg-form-fill .form-control {
    font-size: 0.9rem;
    padding: 0.55rem 0.75rem;
  }

  .vg-form-fill .form-label {
    font-size: 0.8125rem;
    margin-bottom: 0.3rem;
  }

  .vg-form-fill .mb-2 {
    margin-bottom: 0.65rem !important;
  }

  .vg-form-fill .cb-btn-primary-lg,
  .vg-form-fill .cb-btn-outline-light-border {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    font-size: 0.875rem;
  }
}

.vg-actions-grid {
  margin-top: 0.15rem;
}

.vg-status-note {
  margin-top: 0.65rem !important;
  line-height: 1.4;
}

.vg-progress-wrap {
  margin-bottom: 0.65rem !important;
}

@media (max-width: 991.98px) {
  .vg-equal-card {
    min-height: 0;
  }

  .vg-equal-card__body--preview {
    padding-bottom: 0.5rem;
  }
}

@media (max-width: 575.98px) {
  .vg-form-fill .form-control {
    min-height: 2.85rem;
    font-size: 1rem;
  }

  .vg-form-fill .d-grid .btn {
    min-height: 2.85rem;
  }
}

/* Video frame — centered, fits narrow column */
.vg-preview-block {
  width: 100%;
  max-width: min(100%, 260px);
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 992px) {
  .vg-preview-block {
    max-width: min(100%, 100%);
  }

  .vg-equal-card__body--preview {
    padding-top: 0;
    padding-bottom: 0;
  }
}

.vg-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
}

.vg-template-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Bottom overlay (matches exported video) */
.vg-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 0 0.75rem 0.8rem;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.5) 20%, rgba(0, 0, 0, 0.9) 100%);
  pointer-events: none;
}

.vg-overlay-line {
  height: 3px;
  margin-bottom: 0.6rem;
  background: var(--cb-accent, #f97316);
  border-radius: 2px;
}

.vg-overlay-body {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.vg-avatar-wrap {
  flex-shrink: 0;
  width: 22%;
  max-width: 68px;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: #1f2937;
}

.vg-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vg-overlay-text {
  flex: 1;
  min-width: 0;
  color: #fff;
  font-size: clamp(0.6rem, 2.6vw, 0.75rem);
  line-height: 1.35;
}

.vg-outlet-name {
  margin: 0 0 0.12rem;
  font-weight: 700;
  font-size: clamp(0.75rem, 3.2vw, 0.9rem);
  color: #fff;
  line-height: 1.2;
}

.vg-outlet-name.vg-preview-placeholder {
  color: rgba(255, 255, 255, 0.45);
  font-weight: 600;
}

.vg-meta-line span.vg-preview-placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.vg-overlay-text .vg-tagline {
  margin: 0 0 0.3rem;
  font-size: clamp(0.55rem, 2.3vw, 0.65rem);
  font-weight: 600;
  color: var(--cb-accent, #f97316);
}

.vg-meta-line {
  display: flex;
  gap: 0.3rem;
  align-items: flex-start;
  margin: 0 0 0.15rem;
  font-size: clamp(0.55rem, 2.2vw, 0.65rem);
  color: rgba(255, 255, 255, 0.9);
}

.vg-meta-line i {
  flex-shrink: 0;
  margin-top: 0.1em;
  color: var(--cb-accent, #f97316);
}

.vg-meta-line span {
  word-break: break-word;
}

.vg-recording-badge {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: #dc2626;
  border-radius: 4px;
}

.vg-rec-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: vg-rec-pulse 1s ease infinite;
}

@keyframes vg-rec-pulse {
  50% {
    opacity: 0.35;
  }
}

/* Progress complete state */
.vg-progress-wrap.is-complete .progress-bar {
  background-color: #198754 !important;
}

.vg-progress-wrap.is-complete #vgProgressPercent {
  color: #198754 !important;
}

/* Status note (JS toggles is-busy / is-error on #vgStatusNote) */
#vgStatusNote.is-busy {
  color: var(--cb-heading, #1f2937);
  font-weight: 500;
}

#vgStatusNote.is-error {
  color: #b91c1c;
}

#vgBtnDownload.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.vg-record-canvas {
  position: fixed;
  left: -9999px;
  visibility: hidden;
  pointer-events: none;
}
