/*
 * 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;
}

/* Classic TikTok Style - White text with black stroke */
.text-style-classic {
  color: white !important;
  font-family: 'TikTok Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 600; /* SemiBold to match ImageMagick rendering */
  background: transparent !important;
  padding: 0 !important;
  text-align: center;
  box-sizing: border-box;
  /* Toned down black stroke to match ImageMagick rendering */
  text-shadow:
    1.5px 1.5px 0 #000,
    -1.5px 1.5px 0 #000,
    1.5px -1.5px 0 #000,
    -1.5px -1.5px 0 #000 !important;
}

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

.text-style-classic.text-subtext {
  font-size: 12px;
  font-weight: 600; /* SemiBold to match headline */
  line-height: 1.3;
  display:inline-block;
}

/* 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;
}

/* TikTok Highlight Style - Black text with white background per line */
.text-style-highlight {
  font-family: 'TikTok Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  color: transparent !important;
  background: transparent !important;
  text-shadow: none !important;
  padding: 0 !important;
  max-width: 82%;
}

.text-style-highlight.text-headline {
  font-size: 16px;
  line-height: 2.2;
  margin-bottom: 12px;
  display: inline-block;
}

.text-style-highlight.text-subtext {
  font-size: 12px;
  line-height: 2;
  display: inline-block;
}

/* 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-classic.text-headline {
  font-size: 11.5px;  /* 17.5 * 0.67 */
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000 !important;
}

.preview-small .text-style-classic.text-subtext {
  font-size: 7.5px;  /* 11 * 0.67 */
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000 !important;
}

.preview-small .text-style-highlight.text-headline {
  font-size: 11.5px;
  line-height: 1.8;
}

.preview-small .text-style-highlight.text-subtext {
  font-size: 7.5px;
  line-height: 1.6;
}

.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: 600 !important;
}

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

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

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

/* Text Resize Handles */
.text-resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #FF006E;
  border: 2px solid white;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 25;
}

[data-draggable="true"]:hover .text-resize-handle,
[data-draggable="true"].selected .text-resize-handle,
[data-draggable="true"].dragging .text-resize-handle,
[data-draggable="true"].resizing .text-resize-handle {
  opacity: 1;
}

.text-resize-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.text-resize-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.text-resize-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.text-resize-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

.text-resize-handle.n { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.text-resize-handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.text-resize-handle.e { right: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.text-resize-handle.w { left: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

/* Delete Handle (Trash Icon) */
.text-delete-handle {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  background: #FF006E;
  border: 2px solid white;
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
  z-index: 25;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: opacity 0.2s, visibility 0.2s;
}

[data-draggable="true"]:hover .text-delete-handle,
[data-draggable="true"].selected .text-delete-handle,
[data-draggable="true"].dragging .text-delete-handle,
[data-draggable="true"].resizing .text-delete-handle {
  opacity: 1 !important;
  visibility: visible !important;
  display: flex !important;
}

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

/* Mobile - larger touch targets */
@media (max-width: 768px) {
  .text-resize-handle {
    width: 20px;
    height: 20px;
    opacity: 0.8;
  }

  .text-resize-handle.nw { top: -10px; left: -10px; }
  .text-resize-handle.ne { top: -10px; right: -10px; }
  .text-resize-handle.sw { bottom: -10px; left: -10px; }
  .text-resize-handle.se { bottom: -10px; right: -10px; }
  .text-resize-handle.n { top: -10px; }
  .text-resize-handle.s { bottom: -10px; }
  .text-resize-handle.e { right: -10px; }
  .text-resize-handle.w { left: -10px; }

  .text-delete-handle {
    width: 36px;
    height: 36px;
    top: -40px;
  }

  .text-delete-handle svg {
    width: 20px;
    height: 20px;
  }
}

.text-size-indicator {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.resizing .text-size-indicator {
  opacity: 1 !important;
  visibility: visible !important;
}

.dragging .text-size-indicator,
.selected .text-size-indicator {
  opacity: 0.7 !important;
  visibility: visible !important;
}

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

.filmstrip-container {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
  background: #fafafa;
  border: 1px solid #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;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 20px 24px;
  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: white;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  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: #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: #f9fafb;
}

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

.text-align-handle {
  position: absolute;
  top: -32px;
  right: 32px;
  width: 28px;
  height: 28px;
  background: #FF006E;
  border: 2px solid white;
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
  z-index: 25;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: opacity 0.2s, visibility 0.2s;
}

[data-draggable="true"]:hover .text-align-handle,
[data-draggable="true"].selected .text-align-handle,
[data-draggable="true"].dragging .text-align-handle,
[data-draggable="true"].resizing .text-align-handle {
  opacity: 1 !important;
  visibility: visible !important;
  display: flex !important;
}

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

/* Mobile - larger touch targets for alignment button */
@media (max-width: 768px) {
  .text-align-handle {
    width: 36px;
    height: 36px;
    top: -40px;
    right: 40px;
  }

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

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

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