/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* ===========================================
   TikTok Text Overlay Styles
   =========================================== */

/* Base text container */
.text-overlay-container {
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 100%;
  margin: 0 auto;
}

/* Outline style - white text with black stroke */
.text-style-outline,
.text-style-classic {
  color: white !important;
  font-family: 'TikTok Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 700;
  background: transparent !important;
  padding: 0 !important;
  text-align: center;
  box-sizing: border-box;
  --outline-width: 1.2px;
  --outline-shadow:
    1.2px 0 0 #000,
    -1.2px 0 0 #000,
    0 1.2px 0 #000,
    0 -1.2px 0 #000,
    0.85px 0.85px 0 #000,
    -0.85px 0.85px 0 #000,
    0.85px -0.85px 0 #000,
    -0.85px -0.85px 0 #000;
  text-shadow: var(--outline-shadow) !important;
  -webkit-text-stroke: var(--outline-width) #000;
  --text-bg-color: #4A5FBDB8;
}

.text-style-outline.text-headline,
.text-style-classic.text-headline {
  font-size: 16px;
  line-height: 1.25;
  display:inline-block;
}

.text-style-outline.text-subtext,
.text-style-classic.text-subtext {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  display:inline-block;
}

@supports (-webkit-text-stroke: 1px black) {
  .text-style-outline,
  .text-style-classic {
    text-shadow: none !important;
  }
}

/* Safe Content Area Border - Removed as too restrictive */
.slide-preview-container {
  position: relative;
  /* Allow resize handles to extend beyond container on mobile */
  overflow: visible !important;
}

/* Keep the rounded corners and background clipping */
.slide-preview-container > div:first-child {
  overflow: hidden;
  border-radius: inherit;
}

/* Background styles */
.text-style-background-white,
.text-style-background-color,
.text-style-background-color-solid,
.text-style-highlight {
  font-family: 'TikTok Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 700;
  color: black !important;
  background: white !important;
  text-shadow: none !important;
  padding: 2px 10px !important;
  border-radius: 8px !important;
  box-decoration-break: clone !important;
  -webkit-box-decoration-break: clone !important;
  display: inline !important;
  max-width: 82%;
  line-height: 1.25;
}

.text-style-background-color {
  color: white !important;
  background: var(--text-bg-color, #4A5FBDB8) !important;
}

.text-style-background-color-solid {
  color: white !important;
  background: var(--text-bg-color, #4A5FBD) !important;
}

.text-style-background-white.text-headline,
.text-style-background-color.text-headline,
.text-style-background-color-solid.text-headline,
.text-style-highlight.text-headline {
  font-size: 16px;
  line-height: 1.25;
  margin-bottom: 12px;
  font-weight: 700;
}

.text-style-background-white.text-subtext,
.text-style-background-color.text-subtext,
.text-style-background-color-solid.text-subtext,
.text-style-highlight.text-subtext {
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
}

/* Editor preview: style inner text node so wrapper sizing doesn't become a giant rectangle */
[data-draggable="true"] .text-preview-content {
  display: inline;
  white-space: pre-wrap;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  line-height: inherit;
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
}

[data-draggable="true"].text-style-outline .text-preview-content,
[data-draggable="true"].text-style-classic .text-preview-content {
  color: white !important;
  -webkit-text-fill-color: white !important;
  background: transparent !important;
  text-shadow: var(--outline-shadow) !important;
  -webkit-text-stroke: 0 !important;
  text-rendering: geometricPrecision;
}

[data-draggable="true"].text-style-background-white,
[data-draggable="true"].text-style-background-color,
[data-draggable="true"].text-style-background-color-solid,
[data-draggable="true"].text-style-highlight {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  max-width: none !important;
}

[data-draggable="true"].text-style-background-white .text-preview-content,
[data-draggable="true"].text-style-background-color .text-preview-content,
[data-draggable="true"].text-style-background-color-solid .text-preview-content,
[data-draggable="true"].text-style-highlight .text-preview-content {
  padding: 2px 10px !important;
  border-radius: 8px !important;
  text-shadow: none !important;
}

[data-draggable="true"].text-style-background-white .text-preview-content,
[data-draggable="true"].text-style-highlight .text-preview-content {
  color: black !important;
  background: white !important;
}

[data-draggable="true"].text-style-background-color .text-preview-content {
  color: white !important;
  background: var(--text-bg-color, #4A5FBDB8) !important;
}

[data-draggable="true"].text-style-background-color-solid .text-preview-content {
  color: white !important;
  background: var(--text-bg-color, #4A5FBD) !important;
}

/* The magic span for line-by-line backgrounds */
.text-style-highlight .line-box {
  display: inline !important;
  background-color: white !important;
  color: black !important;
  padding: 4px 12px !important;
  border-radius: 8px !important;
  font-weight: 600 !important; /* SemiBold to match rendering */
  text-shadow: none !important;
  /* Critical properties for line wrapping */
  box-decoration-break: clone !important;
  -webkit-box-decoration-break: clone !important;
  -moz-box-decoration-break: clone !important;
  background-clip: padding-box !important;
  /* Ensure text stays visible */
  line-height: inherit !important;
}

.text-style-highlight.text-subtext .line-box {
  padding: 3px 10px !important;
  border-radius: 6px !important;
  font-weight: 600 !important; /* SemiBold to match headline */
}

.text-center-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-1px);
  background: rgba(59, 130, 246, 0.7);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 30;
}

.text-center-guide.visible {
  opacity: 1;
}

.text-vertical-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(59, 130, 246, 0.7);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 30;
}

.text-vertical-guide-20 {
  top: 20%;
  transform: translateY(-1px);
}

.text-vertical-guide-50 {
  top: 50%;
  transform: translateY(-1px);
}

.text-vertical-guide.visible {
  opacity: 1;
}

/* Small screen preview styles (for content ideas) */
/* Scale: 180px wide (vs 270px edit preview), so 0.67x */
.preview-small .text-style-outline.text-headline,
.preview-small .text-style-classic.text-headline {
  font-size: 11.5px;  /* 17.5 * 0.67 */
  --outline-width: 0.9px;
}

.preview-small .text-style-outline.text-subtext,
.preview-small .text-style-classic.text-subtext {
  font-size: 7.5px;  /* 11 * 0.67 */
  --outline-width: 0.6px;
}

.preview-small .text-style-background-white.text-headline,
.preview-small .text-style-background-color.text-headline,
.preview-small .text-style-background-color-solid.text-headline,
.preview-small .text-style-highlight.text-headline {
  font-size: 11.5px;
  line-height: 1.25;
}

.preview-small .text-style-background-white.text-subtext,
.preview-small .text-style-background-color.text-subtext,
.preview-small .text-style-background-color-solid.text-subtext,
.preview-small .text-style-highlight.text-subtext {
  font-size: 7.5px;
  line-height: 1.2;
}

.preview-small .text-style-highlight .line-box {
  padding: 2px 6px !important;
  border-radius: 4px !important;
}

/* Prevent image dragging */
.slide-preview-container img {
  user-select: none !important;
  -webkit-user-drag: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  pointer-events: none !important;
}

/* Draggable Text Styles */
[data-draggable="true"] {
  cursor: move;
  user-select: none;
  z-index: 20;
  position: absolute !important;
  overflow: visible;
  font-family: 'TikTok Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif !important;
  font-weight: 800 !important;
}

[data-draggable="true"]:hover {
  outline: 1.5px solid #FF006E;
  outline-offset: 2px;
}

[data-draggable="true"].selected {
  outline: 1.5px solid #FF006E;
  outline-offset: 2px;
  z-index: 100;
}

[data-draggable="true"].dragging {
  outline: 2px solid #FF006E;
  outline-offset: 2px;
  z-index: 100;
  opacity: 0.9;
}

.text-resize-handle,
.text-control-handle,
.text-size-indicator {
  display: none !important;
}

.text-editor-editing [data-draggable="true"],
.text-editor-editing [data-draggable="true"]:hover,
.text-editor-editing [data-draggable="true"].selected,
.text-editor-editing [data-draggable="true"].dragging {
  outline: none !important;
  opacity: 1;
}

.text-editor-editing .text-center-guide,
.text-editor-editing .text-vertical-guide {
  display: none !important;
}

.text-edit-overlay {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 160;
  overflow: visible;
}

.text-edit-overlay.active {
  display: block;
}

.text-edit-header {
  position: absolute;
  top: -44px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 3;
  padding: 0 10px;
}

.text-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.text-edit-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}

.text-edit-icon-btn svg {
  width: 16px;
  height: 16px;
}

.text-edit-style-btn[data-variant="outline"] {
  background: rgba(0, 0, 0, 0.72);
}

.text-edit-style-btn[data-variant="background_white"] {
  background: rgba(255, 255, 255, 0.95);
  color: #000;
}

.text-edit-style-btn[data-variant="background_color"] {
  background: rgba(74, 95, 189, 0.9);
}

.text-edit-style-btn[data-variant="background_color_solid"] {
  background: rgba(74, 95, 189, 1);
}

.text-edit-done-btn {
  position: absolute;
  right: 2px;
  top: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  pointer-events: auto;
}

.text-edit-size-slider {
  position: absolute;
  right: -30px;
  top: 50%;
  width: 28px;
  height: 210px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 3;
}

.text-edit-size-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 170px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  transform: rotate(-90deg);
  transform-origin: center;
}

.text-edit-size-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  background: #fff;
}

.text-edit-size-slider input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  background: #fff;
}

.text-edit-swatch-strip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -54px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 10px;
  pointer-events: auto;
  z-index: 3;
  background: rgba(0, 0, 0, 0.36);
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.text-edit-swatch {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: var(--swatch-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.text-edit-swatch.active {
  transform: scale(1.12);
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 0, 110, 0.95), 0 1px 3px rgba(0, 0, 0, 0.35);
}

.text-edit-swatch.muted {
  opacity: 0.45;
}

@media (max-width: 768px) {
  .text-edit-header {
    top: -40px;
  }

  .text-edit-size-slider {
    right: -24px;
    height: 180px;
  }

  .text-edit-size-slider input[type="range"] {
    width: 140px;
  }

  .text-edit-swatch-strip {
    left: 8px;
    right: 8px;
    bottom: -50px;
    gap: 8px;
  }
}

.slide-preview-container.editing-text .tiktok-safe-zone-overlay {
  display: none !important;
}

.slide-preview-container.editing-text .image-position-handle,
.slide-preview-container.editing-text .image-position-indicator {
  display: none !important;
}

/* ===========================================
   Filmstrip Styles
   =========================================== */

:root {
  --filmstrip-bg: #fafafa;
  --filmstrip-border: #e5e7eb;
  --filmstrip-nav-bg: white;
  --filmstrip-nav-border: #d1d5db;
  --filmstrip-nav-color: #374151;
  --filmstrip-nav-hover-bg: #f9fafb;
}

.dark {
  --filmstrip-bg: #374151;
  --filmstrip-border: #4b5563;
  --filmstrip-nav-bg: #4b5563;
  --filmstrip-nav-border: #6b7280;
  --filmstrip-nav-color: #d1d5db;
  --filmstrip-nav-hover-bg: #6b7280;
}

.filmstrip-container {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
  background: var(--filmstrip-bg, #fafafa);
  border: 1px solid var(--filmstrip-border, #e5e7eb);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.filmstrip-track {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  /*
   * Reserve permanent space for out-of-frame text edit controls
   * (top actions, right size slider, bottom swatches) so they do not clip.
   * Keeping this always-on avoids layout jumping when entering edit mode.
   */
  padding: 72px 44px 88px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.filmstrip-track::-webkit-scrollbar {
  height: 8px;
}

.filmstrip-track::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.filmstrip-track::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.filmstrip-track::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.filmstrip-slide {
  flex-shrink: 0;
  scroll-snap-align: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 12px;
  overflow: visible;
}

.filmstrip-slide::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  background: transparent;
  transition: all 0.3s ease;
  pointer-events: none;
}

.filmstrip-slide:hover::before {
  background: rgba(255, 0, 110, 0.1);
  box-shadow: 0 0 0 2px rgba(255, 0, 110, 0.3);
}

.filmstrip-slide-selected {
  transform: scale(1.03);
  z-index: 10;
}

.filmstrip-slide-selected::before {
  background: rgba(255, 0, 110, 0.2);
  box-shadow: 0 0 0 4px #FF006E, 0 12px 32px rgba(255, 0, 110, 0.6);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 0 4px #FF006E, 0 12px 32px rgba(255, 0, 110, 0.6);
  }
  50% {
    box-shadow: 0 0 0 4px #FF006E, 0 12px 40px rgba(255, 0, 110, 0.8);
  }
}

.filmstrip-slide-hidden {
  opacity: 0.5;
}

.filmstrip-slide-hidden:hover {
  opacity: 0.7;
}

.filmstrip-nav {
  flex-shrink: 0;
}

.filmstrip-nav-button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--filmstrip-nav-bg, white);
  border: 1px solid var(--filmstrip-nav-border, #d1d5db);
  border-radius: 8px;
  color: var(--filmstrip-nav-color, #374151);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.filmstrip-nav-button:hover:not(:disabled) {
  background: var(--filmstrip-nav-hover-bg, #f9fafb);
  border-color: #9ca3af;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filmstrip-nav-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--filmstrip-nav-hover-bg, #f9fafb);
}

/* ===========================================
   Alignment Handle Styles
   =========================================== */

.text-align-handle {
  align-items: center;
  justify-content: center;
}

.text-align-handle svg {
  width: 14px;
  height: 14px;
}

/* Style Cycle Handle */
.text-style-handle {
  align-items: center;
  justify-content: center;
}

.text-style-handle svg {
  width: 14px;
  height: 14px;
}

/* Background Color Picker Handle */
.text-color-handle {
  width: 28px !important;
  height: 28px !important;
  padding: 2px;
  -webkit-appearance: none;
  appearance: none;
}

.text-color-handle::-webkit-color-swatch-wrapper {
  padding: 0;
}

.text-color-handle::-webkit-color-swatch {
  border: 0;
  border-radius: 999px;
}

.text-color-handle::-moz-color-swatch {
  border: 0;
  border-radius: 999px;
}

/* Mobile - larger touch targets for alignment button */
@media (max-width: 768px) {
  .text-color-handle {
    width: 36px !important;
    height: 36px !important;
  }
}

/* ===========================================
   Control Panel Styles
   =========================================== */

/* ===========================================
   TikTok Safe Zone Overlay
   =========================================== */

.tiktok-safe-zone-overlay {
  display: none;
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 5;
}

.show-safe-zones .tiktok-safe-zone-overlay {
  display: block;
}

.safe-zone-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7.8%;
  background: rgba(239, 68, 68, 0.4);
  border-bottom: 2px dashed rgba(239, 68, 68, 0.8);
}

.safe-zone-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 16.7%;
  background: rgba(239, 68, 68, 0.4);
  border-top: 2px dashed rgba(239, 68, 68, 0.8);
}

.safe-zone-right {
  position: absolute;
  top: 7.8%;
  bottom: 16.7%;
  right: 0;
  width: 11.1%;
  background: rgba(239, 68, 68, 0.25);
  border-left: 2px dashed rgba(239, 68, 68, 0.6);
}

.safe-zone-left {
  position: absolute;
  top: 7.8%;
  bottom: 16.7%;
  left: 0;
  width: 5.6%;
  background: rgba(239, 68, 68, 0.15);
  border-right: 1px dashed rgba(239, 68, 68, 0.4);
}

/* ===========================================
   Image Vertical Repositioning Handle
   =========================================== */

.image-position-handle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  cursor: ns-resize;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.slide-preview-container:hover .image-position-handle {
  opacity: 1;
}

.image-position-handle.dragging {
  opacity: 1;
  background: rgba(255, 0, 110, 0.9);
  border-color: rgba(255, 0, 110, 1);
}

.image-position-handle-dots {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.image-position-handle-dots span {
  width: 12px;
  height: 2px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 1px;
}

.image-position-handle.dragging .image-position-handle-dots span {
  background: white;
}

.image-position-indicator {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 15;
}

.slide-control-panel {
  width: 100%;
}
