/**
 * geometry-short-video.css
 * Hệ thống giao diện đáp ứng đa thiết bị (320px/360px Mobile -> Foldable -> Tablet -> Desktop)
 * cho Hộp thoại Biên Tập Video Bài Giảng Hình Học (AUTOGRADING AI).
 */

.gsv-modal-backdrop {
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(9, 15, 29, 0.72);
  backdrop-filter: blur(6px);
}

#modal-geometry-short-video.modal-backdrop .gsv-modal-dialog,
.gsv-modal-dialog {
  width: min(1140px, 96vw) !important;
  max-width: min(1140px, 96vw) !important;
  height: min(92dvh, 880px);
  max-height: 94dvh !important;
  display: flex;
  flex-direction: column;
  padding: 1.15rem 1.4rem !important;
  border-radius: 20px;
  background: var(--surface-card, #ffffff);
  color: var(--text-color, #0f172a);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 25px 60px -12px rgba(2, 6, 23, 0.45);
  overflow: hidden;
  box-sizing: border-box;
}

.gsv-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding-bottom: 0.7rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  flex-shrink: 0;
}

.gsv-header-brand {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}

.gsv-header-icon {
  font-size: 1.45rem;
  line-height: 1.1;
  flex-shrink: 0;
}

.gsv-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.gsv-modal-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text-color, #0f172a);
}

.gsv-brand-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
}

.gsv-modal-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted, #64748b);
  line-height: 1.4;
}

.gsv-close-btn {
  min-height: 38px;
  flex-shrink: 0;
  font-weight: 700;
}

.gsv-status-banner {
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.55rem;
  flex-shrink: 0;
}

.gsv-export-progress-wrap {
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.6rem;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  flex-shrink: 0;
}

.gsv-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #1e40af;
  margin-bottom: 0.35rem;
}

.gsv-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #dbeafe;
  overflow: hidden;
}

.gsv-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  transition: width 0.16s ease;
}

.gsv-studio-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(380px, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.85rem 1.4rem;
  overflow: hidden;
}

.gsv-preview-column {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  min-height: 0;
}

.gsv-chapter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 76px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
  flex-shrink: 0;
}

.gsv-chap-pill {
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--surface-subtle, #f8fafc);
  color: var(--text-color, #334155);
  border-radius: 999px;
  padding: 0.28rem 0.68rem;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  min-height: 32px;
}

.gsv-chap-pill.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.gsv-stage-shell {
  flex: 1;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #090f1d;
  border-radius: 14px;
  padding: 0.55rem;
  border: 1px solid #1e293b;
  overflow: hidden;
}

.gsv-canvas-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

#gsv-preview-canvas {
  max-width: 100%;
  max-height: 46dvh;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  display: block;
}

.gsv-transport-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: var(--surface-subtle, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  flex-shrink: 0;
}

.gsv-play-btn {
  min-height: 38px;
  font-weight: 700;
  white-space: nowrap;
}

.gsv-time-readout {
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted, #475569);
  white-space: nowrap;
}

.gsv-timeline-scrubber {
  flex: 1;
  min-width: 90px;
  cursor: pointer;
}

.gsv-safe-btn[aria-pressed="true"] {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 700;
}

.gsv-mobile-inspector-tabs {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.25rem;
  background: var(--surface-subtle, #f1f5f9);
  border-radius: 10px;
}

.gsv-mob-tab {
  border: none;
  border-radius: 8px;
  padding: 0.48rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  background: transparent;
  color: var(--text-muted, #475569);
  cursor: pointer;
  min-height: 38px;
}

.gsv-mob-tab.active {
  background: var(--surface-card, #ffffff);
  color: #1d4ed8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.gsv-inspector-column {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.gsv-inspector-panel {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

.gsv-inspector-panel.is-active {
  display: flex;
}

.gsv-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gsv-field-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-color, #1e293b);
}

.gsv-segmented-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.gsv-choice-chip {
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--surface-card, #ffffff);
  color: var(--text-color, #334155);
  border-radius: 10px;
  padding: 0.48rem 0.4rem;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  text-align: center;
}

.gsv-choice-chip.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.gsv-voice-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.gsv-voice-presets-grid .gsv-preset-btn {
  text-align: left;
  padding: 0.5rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

.gsv-voice-preview-btn {
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  transition: all 0.15s ease;
}

.gsv-voice-preview-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.gsv-field-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.gsv-select,
.gsv-text-input {
  min-height: 40px;
  font-size: 0.82rem;
}

.gsv-toggle-stack {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--surface-subtle, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
}

.gsv-check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 30px;
}

.gsv-script-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.gsv-script-title { font-size: 0.84rem; }
.gsv-scene-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  margin-left: 0.35rem;
}

.gsv-scene-script-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.gsv-scene-item {
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--surface-subtle, #f8fafc);
}

.gsv-scene-item.active {
  border-color: #3b82f6;
  background: #eff6ff;
}

.gsv-scene-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  color: #1e40af;
}

.gsv-scene-textarea {
  width: 100%;
  min-height: 54px;
  resize: vertical;
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
  font-family: inherit;
  box-sizing: border-box;
}

.gsv-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding-top: 0.7rem;
  margin-top: 0.65rem;
  border-top: 1px solid var(--border-color, #e2e8f0);
  flex-shrink: 0;
}

.gsv-footer-meta { font-size: 0.76rem; color: var(--text-muted, #64748b); }
.gsv-footer-actions { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.gsv-export-cta { font-weight: 800; min-height: 40px; padding: 0.45rem 1rem; }

[data-theme="dark"] .gsv-modal-dialog { background: #0f172a; color: #f8fafc; border-color: #1e293b; }
[data-theme="dark"] .gsv-choice-chip,
[data-theme="dark"] .gsv-mob-tab.active { background: #1e293b; color: #f8fafc; border-color: #334155; }
[data-theme="dark"] .gsv-choice-chip.active { background: #1e3a8a; border-color: #60a5fa; color: #eff6ff; }
[data-theme="dark"] .gsv-transport-bar,
[data-theme="dark"] .gsv-toggle-stack,
[data-theme="dark"] .gsv-scene-item,
[data-theme="dark"] .gsv-mobile-inspector-tabs { background: #111827; border-color: #1f2937; }

.gsv-no-voice-banner {
  animation: gsvFadeIn 0.2s ease-in-out;
}

.gsv-sub-export-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gsv-sub-export-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .gsv-no-voice-banner {
  background: rgba(30, 58, 138, 0.25) !important;
  border-color: rgba(96, 165, 250, 0.3) !important;
}

[data-theme="dark"] .gsv-no-voice-banner p {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .gsv-sub-export-card {
  background: #111827 !important;
  border-color: #1f2937 !important;
}

[data-theme="dark"] .gsv-sub-export-card div {
  color: #f8fafc !important;
}

@media (max-width: 820px) {
  .gsv-modal-backdrop { padding: 0 !important; align-items: flex-end !important; }
  #modal-geometry-short-video.modal-backdrop .gsv-modal-dialog,
  .gsv-modal-dialog {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 96dvh !important;
    max-height: 96dvh !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 0.75rem 0.85rem !important;
  }
  .gsv-studio-body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.65rem;
  }
  .gsv-preview-column {
    flex-shrink: 0;
  }
  .gsv-stage-shell {
    min-height: 140px;
    max-height: 23dvh;
    padding: 0.35rem;
  }
  #gsv-preview-canvas {
    max-height: 21dvh;
  }
  .gsv-mobile-inspector-tabs {
    flex-shrink: 0;
  }
  .gsv-inspector-column {
    overflow-y: visible;
  }
  .gsv-field-row-2col { grid-template-columns: 1fr; }
  .gsv-choice-chip, .gsv-mob-tab, .gsv-play-btn, .gsv-export-cta, .gsv-close-btn { min-height: 44px; }
  .gsv-footer-meta { display: none; }
  .gsv-footer-actions { width: 100%; justify-content: flex-end; }
  .gsv-export-cta { flex: 1; justify-content: center; }
}
