/* ==========================================================================
   MONAI VISUAL LIVE EDITOR (Direct Edit & 1-Click Auto-Publish to Web)
   Adapted from GOSU Cinema Visual Editor for MONAI — Hybrid AI VFX Studio
   ========================================================================== */

:root {
  --ve-accent: #f6821f;
  --ve-accent-hover: #ff9910;
  --ve-accent-glow: rgba(246, 130, 31, 0.4);
  --ve-bg: rgba(10, 14, 20, 0.95);
  --ve-border: rgba(246, 130, 31, 0.45);
  --ve-text: #f3f4f6;
  --ve-muted: #9ca3af;
}

/* Floating Launcher Button at Bottom-Right (Hidden until authenticated) */
#ve-Launcher {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9998;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--ve-bg);
  border: 1px solid var(--ve-border);
  color: var(--ve-accent);
  font-family: 'Geist Mono', monospace, sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), 0 0 15px var(--ve-accent-glow);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  transition: all 0.25s ease;
}

#ve-Launcher:hover {
  background: var(--ve-accent);
  color: #000;
  border-color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(246, 130, 31, 0.6);
}

/* Bottom Main Editor Toolbar */
#ve-Toolbar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  z-index: 9999;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px;
  background: var(--ve-bg);
  border: 1px solid var(--ve-border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.95), 0 0 25px var(--ve-accent-glow);
  backdrop-filter: blur(16px);
  border-radius: 14px;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  max-width: 96vw;
}

body.ve-editing #ve-Toolbar {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

body.ve-editing #ve-Launcher {
  display: none !important;
}

.ve-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(246, 130, 31, 0.15);
  border: 1px solid var(--ve-accent);
  color: var(--ve-accent);
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.ve-status-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: vePulse 1.6s infinite ease-in-out;
}

@keyframes vePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.ve-btn {
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e5e7eb;
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ve-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.ve-btn-primary {
  background: linear-gradient(135deg, #f6821f 0%, #d9530f 100%);
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 18px var(--ve-accent-glow);
  font-weight: 700;
}

.ve-btn-primary:hover {
  background: linear-gradient(135deg, #ff9910 0%, #f6821f 100%);
  box-shadow: 0 0 25px rgba(246, 130, 31, 0.7);
  transform: translateY(-2px);
}

.ve-btn-exit {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.ve-btn-exit:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fff;
}

/* Floating Rich-Text Formatting Bar */
#ve-FormatBar {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 12px;
  background: var(--ve-bg);
  border: 1px solid var(--ve-border);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.92), 0 0 20px var(--ve-accent-glow);
  backdrop-filter: blur(14px);
  border-radius: 10px;
  max-width: 96vw;
}

body.ve-editing #ve-FormatBar.is-visible {
  display: flex;
}

.ve-fmt-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-right: 6px;
  margin-right: 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.ve-fmt-group:last-child {
  border-right: 0;
  padding-right: 0;
  margin-right: 0;
}

.ve-fmt-btn {
  min-width: 28px;
  height: 27px;
  padding: 0 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e5e7eb;
  font-family: 'Geist Mono', monospace;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.ve-fmt-btn:hover,
.ve-fmt-btn.is-active {
  background: var(--ve-accent);
  color: #000;
  border-color: #fff;
}

.ve-fmt-color-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.ve-fmt-color-input {
  width: 28px;
  height: 27px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

/* Pinned Frame Action Buttons */
.ve-pinned-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 60;
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.hero > .ve-pinned-bar,
#top > .ve-pinned-bar {
  top: 90px;
  left: 24px;
}

body.ve-editing .ve-pinned-bar {
  display: flex;
}

.ve-pin-btn {
  padding: 7px 12px;
  background: rgba(10, 14, 20, 0.92);
  border: 1px solid var(--ve-accent);
  color: #fff;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 0 0 10px var(--ve-accent-glow);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ve-pin-btn:hover {
  background: var(--ve-accent);
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(246, 130, 31, 0.5);
}

/* Editable Text Highlights in Edit Mode */
body.ve-editing [data-ve-editable="true"] {
  outline: 1px dashed rgba(246, 130, 31, 0.35);
  outline-offset: 3px;
  border-radius: 4px;
  transition: outline-color 0.18s ease, background-color 0.18s ease;
  cursor: text !important;
}

body.ve-editing [data-ve-editable="true"]:hover {
  outline: 1px dashed var(--ve-accent);
  background-color: rgba(246, 130, 31, 0.08);
}

body.ve-editing [data-ve-editable="true"]:focus {
  outline: 2px solid var(--ve-accent);
  background-color: rgba(10, 14, 20, 0.9);
  box-shadow: 0 0 20px var(--ve-accent-glow);
}

/* Editable Image Highlights in Edit Mode */
body.ve-editing img[data-ve-img-id],
body.ve-editing [data-ve-bg-id] {
  outline: 2px dashed rgba(246, 130, 31, 0.45);
  outline-offset: -2px;
  cursor: pointer !important;
  transition: outline-color 0.2s ease, filter 0.2s ease;
}

body.ve-editing img[data-ve-img-id]:hover,
body.ve-editing [data-ve-bg-id]:hover {
  outline: 2px solid var(--ve-accent);
  filter: brightness(1.08);
}

/* Floating Image Edit Badge on Hover */
#ve-ImgHoverBadge {
  position: fixed;
  z-index: 9997;
  padding: 6px 12px;
  background: rgba(10, 14, 20, 0.95);
  border: 1px solid var(--ve-accent);
  color: #fff;
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.85);
  border-radius: 6px;
  display: none;
}

#ve-ImgHoverBadge:hover {
  background: var(--ve-accent);
  color: #000;
}

/* Modal Backdrop & Dialog */
.ve-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(3, 5, 8, 0.86);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ve-modal-backdrop.is-open {
  display: flex;
}

.ve-modal {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: #0d1117;
  border: 1px solid var(--ve-border);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), 0 0 30px var(--ve-accent-glow);
  border-radius: 16px;
  padding: 26px 28px;
  color: var(--ve-text);
  font-family: 'Geist', system-ui, sans-serif;
}

.ve-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ve-modal-head h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ve-accent);
  letter-spacing: -0.3px;
}

.ve-close-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #9ca3af;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.ve-close-btn:hover {
  color: #fff;
  border-color: #fff;
}

.ve-field {
  margin-bottom: 18px;
}

.ve-field label {
  display: block;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--ve-accent);
  margin-bottom: 7px;
  text-transform: uppercase;
}

.ve-input,
.ve-select,
.ve-textarea {
  width: 100%;
  padding: 10px 12px;
  background: #06090e;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #f3f4f6;
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 14px;
  box-sizing: border-box;
}

.ve-input:focus,
.ve-select:focus,
.ve-textarea:focus {
  outline: none;
  border-color: var(--ve-accent);
  box-shadow: 0 0 10px var(--ve-accent-glow);
}

.ve-file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--ve-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.ve-file-drop:hover {
  background: rgba(246, 130, 31, 0.08);
  border-color: var(--ve-accent);
}

.ve-img-preview-box {
  margin-top: 12px;
  padding: 12px;
  background: #06090e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  text-align: center;
}

.ve-img-preview-box img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 4px;
}

.ve-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.ve-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Toast Notifications */
.ve-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10001;
  padding: 12px 20px;
  background: rgba(10, 14, 20, 0.98);
  border: 1px solid var(--ve-accent);
  border-left: 5px solid var(--ve-accent);
  color: #fff;
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.9), 0 0 20px var(--ve-accent-glow);
  border-radius: 8px;
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  max-width: 420px;
  line-height: 1.45;
}

.ve-toast.is-shown {
  transform: translateY(0);
  opacity: 1;
}

/* Video Card Edit Overlay */
.reel-card {
  position: relative;
}

body.ve-editing .reel-card {
  outline: 1px dashed rgba(246, 130, 31, 0.4);
  outline-offset: 4px;
  border-radius: 12px;
}

body.ve-editing .reel-card:hover {
  outline: 2px solid var(--ve-accent);
}

.ve-card-edit-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 50;
  padding: 5px 10px;
  background: var(--ve-bg);
  border: 1px solid var(--ve-accent);
  color: var(--ve-accent);
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

body.ve-editing .ve-card-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ve-card-edit-btn:hover {
  background: var(--ve-accent);
  color: #000;
}

/* Backgrounds Manager Modal Grid */
.ve-bg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 6px;
}

.ve-bg-card {
  background: #06090e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease;
}

.ve-bg-card:hover {
  border-color: var(--ve-accent);
}

.ve-bg-thumb {
  width: 100%;
  height: 110px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.ve-bg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ve-bg-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.ve-bg-card-desc {
  font-size: 11.5px;
  color: #9ca3af;
  line-height: 1.4;
}

/* Revert Modal Choice Cards */
.ve-revert-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.ve-revert-card {
  background: #06090e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  transition: all 0.2s ease;
}

.ve-revert-card:hover {
  border-color: var(--ve-accent);
  background: rgba(246, 130, 31, 0.04);
}

.ve-revert-info h5 {
  margin: 0 0 6px 0;
  font-size: 14px;
  color: #fff;
}

.ve-revert-info p {
  margin: 0;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.45;
}

.ve-revert-danger {
  border-color: rgba(239, 68, 68, 0.3);
}

.ve-revert-danger:hover {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.06);
}

.ve-bg-active-tag {
  outline: 2px dashed rgba(246, 130, 31, 0.6) !important;
  outline-offset: -2px !important;
}
