/* src/frontend/static/css/video-modal.css */

#video-modal-overlay.show {
  display: flex;
  z-index: 99999;
}

/* grid inside modal */
/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* grid inside modal */
#video-modal .modal-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: start;
  height: 100%;
}

#video-modal .modal-side {
  color: #ddd;
  display: flex;
  flex-direction: column;
  gap: 15px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ... existing styles ... */

#video-modal {
  width: min(1400px, 95%);
  height: 90vh;
  /* Reduced height slightly if needed, but 90vh is good */
  max-height: 90vh;
  background: #111;
  /* Slightly lighter than pure black */
  border: 1px solid #222;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
  color: var(--text);
  padding: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
}

#video-modal-overlay {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

/* видео - занимает всё доступное место в колонке */
#video-modal .modal-main {
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  margin-top: 0;
  height: 100%;
  min-height: 60vh;
  width: 100%;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* === WIZARD MODE RESET === */
#video-modal .modal-main.modal-main-wizard {
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  align-items: flex-start !important;
  /* Start content from top */
  justify-content: normal !important;
  /* Reset center */
  display: block !important;
  /* Allow block flow */
  overflow: visible !important;
}

#video-modal .modal-main video,
#video-modal .modal-main img,
#video-modal .modal-main .modal-image-element,
#video-modal .modal-main .modal-gallery,
#video-modal .modal-main .modal-gallery-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

#video-modal .modal-title {
  font-weight: 700;
  font-size: 22px;
  line-height: 1.3;
  color: #fff;
  letter-spacing: -0.02em;
}

#video-modal .modal-desc {
  color: #aaa;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 8px;
}

#video-modal .modal-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#video-modal .modal-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

#video-modal .modal-close {
  position: absolute;
  right: 12px;
  top: 12px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  z-index: 999;
}

/* основная кнопка в модалке - яркая основная */
#video-modal .btn-primary {
  background: linear-gradient(135deg, #D6FF3F 0%, #c1e639 100%);
  color: #000;
  padding: 14px 32px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(214, 255, 63, 0.2);
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

#video-modal .btn-primary:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

#video-modal .btn-primary:active {
  transform: scale(0.98);
}

#video-modal .btn-primary:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
  box-shadow: none;
}

/* сохранём ghost-стиль для вторичных кнопок */
#video-modal .btn-ghost {
  background: #171717;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
}

/* кнопка prompt внутри модалки видео */
#video-modal .btn-ghost {
  font-weight: 600;
  padding: 8px 10px;
}

/* prompt modal */
#prompt-modal-overlay {
  display: none;
  align-items: center;
  justify-content: center;
}

#prompt-modal pre {
  margin: 0;
}

/* делаем кнопку генерации шире на мобильных */
@media (max-width:700px) {
  #video-modal .btn-primary {
    width: 100%;
  }

  #video-modal .btn-ghost {
    width: 100%;
  }
}

@media (max-width:700px) {
  #video-modal {
    padding: 10px;
  }

  #video-modal .modal-grid {
    grid-template-columns: 1fr;
  }

  #video-modal .modal-main {
    min-height: 40vh;
  }
}



.modal-gallery {
  position: relative;
  overflow: hidden;
  display: none;
}

.modal-gallery .gallery-prev,
.modal-gallery .gallery-next {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20000;
  background: none;
  border: none;
  color: #fff;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  user-select: none;
  pointer-events: auto;
}

.modal-gallery .gallery-prev {
  left: 8px;
}

.modal-gallery .gallery-next {
  right: 8px;
}



.modal-copy-link-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.modal-copy-link-btn img {
  width: 22px;
  height: 22px;
  display: block;
  cursor: pointer;
}

.modal-tags-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 30px;
}

.modal-tags-row .modal-label {
  flex: 0 0 auto;
  white-space: nowrap;
  color: #9aa0a6;
  font-size: 13px;
  margin-top: 0px;
}

.modal-tags-row .modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ================== Generate Modal с раскадровкой ================== */

#generate-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 20px;
  overflow-y: auto;
}

#generate-modal {
  width: min(700px, 95%);
  max-height: 90vh;
  overflow-y: auto;
  background: #0b0b0b;
  border-radius: 12px;
  padding: 20px;
  color: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

/* Индикатор шагов - Premium Look */
.steps-indicator {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.steps-indicator .step-item {
  padding: 8px 20px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: #9aa0a6;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.steps-indicator .step-item.active {
  background: #1f1f1f;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.steps-indicator .step-item:not(.active):hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Clickable steps */
.steps-indicator .step-item.step-clickable {
  cursor: pointer;
}

.steps-indicator .step-item.step-clickable:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Soon badge for production mode */
.steps-indicator .step-item.step-soon {
  position: relative;
  opacity: 0.5;
  cursor: default;
}

.steps-indicator .step-item.step-soon::after {
  content: "soon";
  position: absolute;
  top: -6px;
  right: -6px;
  background: #8b5cf6;
  color: #fff;
  font-size: 8px;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Сетка раскадровки */
.storyboard-grid {
  display: flex;
  /* Используем flex для wrap */
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  justify-content: flex-start;
  /* Выравнивание по началу */
}

.storyboard-frame {
  position: relative;
  overflow: hidden;
  background: #1a1a1a;
  width: 100%;
  height: 80%;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

/* Drag-and-Drop стили */
.storyboard-frame.dragging {
  opacity: 0.5;
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(214, 255, 63, 0.3);
}

.storyboard-frame.drag-over {
  border: 2px dashed #D6FF3F;
  background: rgba(214, 255, 63, 0.1);
}

.storyboard-frame[draggable="true"] {
  cursor: grab;
}

.storyboard-frame[draggable="true"]:active {
  cursor: grabbing;
}

/* ================== Auth Requirement Modal ================== */
#auth-modal-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  z-index: 1000000;
  /* Самый верхний слой */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#auth-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#auth-modal {
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 30px;
  width: min(400px, 90%);
  text-align: center;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#auth-modal-overlay.visible #auth-modal {
  transform: scale(1);
}

#auth-modal h3 {
  margin: 0 0 12px 0;
  font-size: 20px;
  color: #fff;
}

#auth-modal p {
  color: #aaa;
  margin-bottom: 24px;
  font-size: 15px;
  line-height: 1.5;
}

.auth-modal-actions {
  display: flex;
  gap: 8px;
  flex-direction: column;
}

.auth-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
}

.auth-modal-close:hover {
  color: #fff;
}

.btn-auth-primary {
  display: inline-block;
  text-align: center;
  background: #D6FF3F;
  color: #000;
  padding: 12px 20px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.btn-auth-primary:hover {
  filter: brightness(1.1);
  transform: scale(1.02);
}

.btn-auth-secondary {
  display: inline-block;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s ease;
}

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

/* ================== Step 1: Prompt Edit Styles ================== */
#modal-step-prompt {
  width: 100%;
  height: 100%;
  padding: 20px;
  display: none;
  overflow-y: auto;
}

#modal-step-prompt h3 {
  margin: 0 0 20px 0;
  font-size: 20px;
  color: #fff;
}

.step-prompt-textarea {
  width: calc(100% - 7%);
  background: #0f0f0f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  color: #e0e0e0;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  min-height: 240px;
  margin-bottom: 0px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.step-prompt-textarea:focus {
  border-color: rgba(214, 255, 63, 0.5);
  background: rgba(255, 255, 255, 0.08);
}

.step-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 30px;
}

.step-actions .btn-step-nav {
  min-width: 100px;
  padding: 10px 24px !important;
  font-size: 14px !important;
}

/* Mobile adjustments for Content Modal */
@media (max-width: 900px) {
  #modal-step-prompt {
    padding: 0px !important;
  }

  #video-modal-overlay {
    padding: 0 !important;
  }

  #video-modal {
    width: 100vw !important;
    /* Force full viewport width */
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100vh !important;
    /* Fallback */
    height: 100dvh !important;
    /* Modern mobile viewport height */
    border-radius: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    border: none;
    box-sizing: border-box;
    /* Ensure padding doesn't add to width */
    overflow-x: hidden;
    /* Prevent horizontal scroll */
  }

  #video-modal .modal-grid {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    height: 100%;
    overflow-y: auto;
    /* Scroll container */
    gap: 0;
  }

  /* 1) Content height - reduced for mobile but flexible */
  #video-modal .modal-main {
    min-height: auto !important;
    height: 40vh !important;
    /* Fixed height for video/image on mobile */
    max-height: 45vh;
    flex: 0 0 auto;
    width: 100%;
    border-radius: 0;
    margin: 0;
  }

  /* FIX: Wizard mode must take full height/auto to show form */
  #video-modal .modal-main.modal-main-wizard {
    height: auto !important;
    max-height: none !important;
    flex: 1 1 auto;
    overflow: visible !important;
    display: block !important;
  }

  /* Wizard input stacking for mobile */
  .wizard-step-content {
    padding: 0 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .wizard-input-group {
    flex-direction: column !important;
    flex: auto !important;
    width: 100% !important;
    gap: 0 !important;
    max-height: 500px;
  }

  .wizard-ref-wrapper {
    width: 100% !important;
    margin-bottom: 20px;
    min-height: 120px;
  }

  .storyboard-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    padding: 0 20px !important;
  }

  .storyboard-card {
    width: 100% !important;
  }

  #video-modal .modal-side {
    padding: 20px;
    width: calc(100% - 10%);
    flex: 1 1 auto;
    overflow-y: visible;
    /* Scroll happens in modal-grid */
  }

  /* Hide side panel in wizard mode explicitly if needed, although JS does it */
  #video-modal .modal-main.modal-main-wizard+.modal-side {
    display: none !important;
  }

  /* 2) Tags margin */
  .modal-tags-row {
    margin-top: 10px !important;
    margin-bottom: 20px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* 3) Sticky actions */
  #video-modal .modal-actions {
    position: sticky;
    bottom: 0px;
    background: #111;
    z-index: 100;
    padding: 15px 0 20px 0;
    /* Extra padding for bottom safe area */
    margin-top: auto !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
  }

  #video-modal .btn-primary,
  #video-modal .btn-ghost {
    width: 100%;
    font-size: 11px !important;
    font-weight: 500 !important;
    gap: 2px !important;
  }
}