/* Dev Mode Styles */

/* Dev Mode Button (styles from 34bca20 styles.css) */
.dev-button {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.5), 0 0 20px rgba(59, 130, 246, 0.4);
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    background: linear-gradient(45deg, #ec4899, #ef4444, #3b82f6, #6366f1);
    background-size: 300% 300%;
    animation: cyberpunk-gradient-button 5s ease infinite;
}
@keyframes cyberpunk-gradient-button {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.dev-button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.8), 0 0 30px rgba(59, 130, 246, 0.6);
}
.dev-button.active {
    border-color: #ffffff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px 5px rgba(255, 255, 255, 0.7);
    animation: active-button-glow 1.5s ease-in-out infinite alternate, cyberpunk-gradient-button 5s ease infinite;
}

/* NEW Keyframe Animation for Active Button Glow */
@keyframes active-button-glow {
    0% {
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px 5px rgba(255, 255, 255, 0.7);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 1), inset 0 0 15px rgba(255, 255, 255, 0.8), 0 0 30px 8px rgba(236, 72, 153, 0.8), 0 0 30px 8px rgba(59, 130, 246, 0.8);
    }
}

.dev-button.active:hover {
    border-color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 1), inset 0 0 15px rgba(255, 255, 255, 0.8), 0 0 30px 8px rgba(236, 72, 153, 0.8), 0 0 30px 8px rgba(59, 130, 246, 0.8);
}

/* Dev Mode Highlight (styles from 34bca20 styles.css)*/
.dev-highlight {
    outline: 2px dashed red !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.8) !important; /* More opaque red shadow */
    /* Prevent any transforms that could cause rotation/floating */
    transform: none !important;
    will-change: auto !important;
    position: relative !important;
    /* Ensure red border takes priority over blue selection */
    background-color: transparent !important;
    /* Enable drag from outline (like Figma) */
    cursor: move !important;
    /* CRITICAL: Don't change opacity - keep element fully visible */
    opacity: 1 !important;
}

/* Special handling for autolayout containers - never change opacity */
.autolayout-container-dev.dev-highlight,
.autolayout-container.dev-highlight,
[data-autolayout-enabled="true"].dev-highlight,
.content-slot[data-autolayout-container="true"].dev-highlight,
.content-slot[data-autolayout-container="true"] .autolayout-container-dev.dev-highlight,
.content-slot[data-autolayout-container="true"] [data-autolayout-enabled="true"].dev-highlight {
    opacity: 1 !important;
    background-color: transparent !important;
}

/* CRITICAL: Prevent any opacity changes on autolayout containers, even from inline styles */
.content-slot[data-autolayout-container="true"],
.content-slot[data-autolayout-container="true"] .autolayout-container-dev,
.content-slot[data-autolayout-container="true"] [data-autolayout-enabled="true"] {
    opacity: 1 !important;
}

/* Draggable elements - show move cursor on hover */
.dev-draggable.dev-highlight:hover,
.dev-draggable.dev-slot-selected:hover {
    cursor: move !important;
}

/* Multiple Selection Styles - Only for multi-selection (Shift/Cmd+Click) - Lightweight */
.dev-slot-selected {
    outline: 1px solid rgba(59, 130, 246, 0.4) !important;
    outline-offset: 2px;
    /* Removed: box-shadow and background-color for cleaner look */
}

/* When both classes are present, red highlight should take priority */
.dev-highlight.dev-slot-selected,
.dev-slot-selected.dev-highlight {
    outline: 2px dashed red !important;
    box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.8) !important; /* More opaque red shadow */
    background-color: transparent !important;
}

/* AutoLayout Container Styles */
.autolayout-container {
    position: relative;
    min-height: 40px; /* Ensure container has minimum height */
}

.autolayout-container-dev {
    border: 2px dashed #10b981 !important;
    border-radius: 4px;
    padding: 4px;
    margin: 2px;
    position: relative;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: visible !important;  /* Allow delete buttons to be visible outside container */
}

/* CRITICAL: Ensure green border is always visible in dev mode, even if other CSS loads after */
[data-autolayout-enabled="true"].autolayout-container-dev,
.content-slot[data-autolayout-container="true"] .autolayout-container-dev,
.content-slot[data-autolayout-container="true"] [data-autolayout-enabled="true"].autolayout-container-dev {
    border: 2px dashed #10b981 !important;
}

/* FIGMA-LIKE BEHAVIOR: Children inside AutoLayout lose absolute positioning */
/* Remove individual borders, padding, and margin from children when inside AutoLayout */
.autolayout-container-dev > [data-dev-slot-id],
.autolayout-container-dev > .autolayout-child,
.autolayout-container-dev > .content-slot[data-autolayout-child="true"],
.autolayout-container > [data-dev-slot-id],
.autolayout-container > .autolayout-child,
.autolayout-container > .content-slot[data-autolayout-child="true"] {
    /* Remove all individual spacing - AutoLayout container handles it */
    border: none !important;
    outline: none !important;
    padding: 0 !important; /* Padding is on the container, not children */
    margin: 0 !important; /* Gap handles spacing between children */
    /* CRITICAL: Ensure children are draggable */
    pointer-events: auto !important;
    cursor: move !important;
    
    /* FIGMA-LIKE: Children become relative to container, not absolute */
    position: relative !important;
    /* Remove any absolute positioning that might interfere */
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    
    /* CRITICAL: Don't force width/height with !important - let JavaScript apply sizing via inline styles */
    /* Inline styles have higher specificity, so JavaScript can override these defaults */
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    
    /* Children should not have fixed dimensions unless explicitly set */
    /* They should hug content or fill container based on AutoLayout sizing */
    /* JavaScript will apply the correct sizing via inline styles (which override this) */
}

/* Children should not show individual selection borders when parent is selected */
.autolayout-container-dev.dev-highlight > [data-dev-slot-id],
.autolayout-container-dev.dev-slot-selected > [data-dev-slot-id],
.autolayout-container-dev.dev-highlight > .autolayout-child,
.autolayout-container-dev.dev-slot-selected > .autolayout-child,
.autolayout-container.dev-highlight > [data-dev-slot-id],
.autolayout-container.dev-slot-selected > [data-dev-slot-id] {
    outline: none !important;
    box-shadow: none !important;
}

/* Ensure children respond to AutoLayout container (like Figma frames) */
.autolayout-container-dev > *,
.autolayout-container > * {
    /* Children inherit layout from parent AutoLayout */
    flex-shrink: 0; /* Prevent shrinking unless explicitly set */
    /* Children should flow naturally within the container */
    display: block; /* Default, will be overridden by flexbox/grid */
}

/* Enhanced visual feedback when selected */
.autolayout-container-dev.dev-highlight,
.autolayout-container-dev.dev-slot-selected {
    border-color: #3b82f6;
    border-style: solid;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), inset 0 0 0 1px rgba(59, 130, 246, 0.3);
}

.autolayout-container-dev::before {
    content: 'AutoLayout';
    position: absolute;
    top: -12px;
    left: 8px;
    background: #10b981;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 2px;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
}

/* Direction indicator badge - removed ::after, now using real element */

/* Direction indicator element */
.autolayout-direction-indicator {
    position: absolute !important;
    top: -12px !important;
    right: 8px !important;
    width: 20px !important;
    height: 20px !important;
    background: rgba(16, 185, 129, 0.2) !important;
    border: 1px solid #10b981 !important;
    border-radius: 3px !important;
    z-index: 1000 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* CRITICAL: Ensure icon is visible even if parent has styles that might hide it */
.autolayout-container-dev .autolayout-direction-indicator,
[data-autolayout-enabled="true"] .autolayout-direction-indicator,
.content-slot[data-autolayout-container="true"] .autolayout-direction-indicator {
    position: absolute !important;
    top: -12px !important;
    right: 8px !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1000 !important;
}

.autolayout-direction-indicator:hover {
    background: rgba(16, 185, 129, 0.4);
    /* Prevent any transform or position changes on hover */
    transform: none !important;
    top: -12px !important;
    right: 8px !important;
}

/* AutoLayout Padding Overlay - Visual representation of padding */
.autolayout-padding-overlay {
    position: absolute;
    background: rgba(16, 185, 129, 0.1);
    border: 1px dashed rgba(16, 185, 129, 0.5);
    pointer-events: none;
    z-index: 1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 2px;
}

/* Show padding overlay when container is selected */
.autolayout-container-dev.dev-highlight .autolayout-padding-overlay,
.autolayout-container-dev.dev-slot-selected .autolayout-padding-overlay {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.6);
}

/* AutoLayout Gap Indicators */
.autolayout-gap-indicator {
    position: absolute;
    background: rgba(16, 185, 129, 0.3);
    pointer-events: none;
    z-index: 2;
}

.autolayout-gap-indicator.horizontal {
    width: 2px;
    height: 100%;
}

.autolayout-gap-indicator.vertical {
    width: 100%;
    height: 2px;
}

/* Dev Mode Guide Lines (styles from 34bca20 styles.css) */
.dev-guide-line {
    position: fixed;
    background: linear-gradient(90deg, #ec4899, #3b82f6, #ec4899);
    background-size: 200% 1px;
    z-index: 9990;
    pointer-events: none;
    animation: guide-gradient-shift-horizontal 1s linear infinite;
}
.dev-guide-line.vertical {
    background: linear-gradient(180deg, #ec4899, #3b82f6, #ec4899); /* Vertical gradient */
    background-size: 1px 200%;
    animation-name: guide-gradient-shift-vertical; /* Use vertical animation */
}
@keyframes guide-gradient-shift-horizontal {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}
@keyframes guide-gradient-shift-vertical {
    0% { background-position: center 0%; }
    100% { background-position: center 200%; }
}

/* Dev Mode Tag Display */
.dev-tag-display {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    background-color: var(--color-primary-accent, #ec4899);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
}
.dev-tag-display.visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

/* Dev Mode Spec Box */
.dev-spec-box {
    position: fixed;
    z-index: 10001; /* Higher than everything else */
    color: rgb(226, 232, 240);
    font-family: monospace;
    font-size: 0.875rem; /* Increased from 0.75rem for better readability */
    line-height: 1.5; /* Increased from 1.4 */
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Disabled when not visible */
    box-shadow: rgba(0, 0, 0, 0.5) 0px 8px 24px, rgba(0, 0, 0, 0.3) 0px 4px 12px; /* Enhanced shadow */
    min-width: 200px; /* Increased from 180px */
    max-width: 450px; /* Increased from 420px */
    overflow-wrap: break-word;
    background: rgba(30, 41, 59, 0.98); /* More opaque for better contrast */
    padding: 0.75rem 1rem; /* Increased padding */
    border-radius: 0.5rem; /* Slightly larger radius */
    transition: opacity 0.2s, visibility linear 0.2s;
    border-width: 1px;
    border-style: solid;
    border-color: rgba(71, 85, 105, 0.8); /* Slightly more visible border */
    border-image: initial;
    /* CRITICAL: Make it clickeable when visible */
    user-select: text; /* Allow text selection for editing */
}

.dev-spec-box.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* CRITICAL: Enable clicks when visible */
}

/* RESTORED: Specific styles for content within the spec box */
.dev-spec-box .spec-title {
    font-weight: bold;
    color: #66b3ff; /* Light blue for title */
    display: block;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dev-spec-box .spec-details {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #D1D5DB; /* Light gray for values - Lighter for visibility */
}
/* Style for the labels (W:, M:, P:, etc.) */
.dev-spec-box .spec-label {
    font-weight: 600;
    margin-right: 0.5em;
    color: #9CA3AF; /* Muted gray for labels */
}
/* Style for the values */
.dev-spec-box .spec-value {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: #E5E7EB; /* Brighter for the actual value */
}
.dev-spec-box .spec-details strong {
    display: inline;
    color: #a3a3a3; /* Lighter gray for labels like P:, M: */
    font-weight: normal;
}

/* Dev Mode Border Container & Margins (styles from 34bca20 styles.css) */
.dev-mode-border-container {
    position: fixed;
    inset: 0;
    border-radius: 1rem; /* This should match the mask's border-radius */
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    pointer-events: none;
    overflow: hidden;
    z-index: 9997; /* Below other dev UI, above page content */
    will-change: transform;
}

body.dev-mode-on .dev-mode-border-container {
    opacity: 1;
    pointer-events: none; /* Let clicks pass through to the content below */
}

/* --- FINAL IMPLEMENTATION V4: True rotating amorphous glow --- */

/* Keyframes for rotation */
@keyframes rotate-border {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/*
  ::before is the source of the light. It's a massive (200% x 200%) conic gradient
  that spins continuously. By making it oversized and placing it centered, we ensure
  the gradient covers the entire edge of the viewport smoothly.
*/
.dev-mode-border-container::before {
    content: '';
    position: absolute;
    left: -50%;
    top: -50%;
    width: 200%;
    height: 200%;
    /* REVISED: Vibrant, multi-color gradient using brand tones */
    background: transparent; /* As per user request, remove fill */
    animation: rotate-border 6s linear infinite; /* Slightly slower for a smoother feel */
}

/* The ::after element is now a container for the rotating glow emitters */
.dev-mode-border-container::after {
    content: '';
    position: absolute;
    inset: 4px; /* CONTROLS THE BORDER THICKNESS */
    background: transparent; /* Make the center transparent to show page content */
    border-radius: 0.75rem; /* Slightly smaller than parent to avoid aliasing */
    z-index: 1;
}

/* Dev Mode Margin Visualizers (JS Controlled - Vertical Text Version) */

/* Keyframes for entry/exit animations */
@keyframes dev-margin-enter-left {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0%); opacity: 1; }
}
@keyframes dev-margin-enter-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0%); opacity: 1; }
}
/* These exit keyframes are not currently used by the transition-based exit, but are kept for potential future use */
@keyframes dev-margin-exit-left {
  from { transform: translateX(0%); opacity: 1; }
  to   { transform: translateX(-100%); opacity: 0; }
}
@keyframes dev-margin-exit-right {
  from { transform: translateX(0%); opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

.dev-margin-visualizer {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 0; /* Controlled by JS */
    /* UPDATED: Brighter colors for better visibility in dark mode */
    background-color: rgba(255, 0, 255, 0.15); /* Bright magenta, more visible */
    border: 1px dashed rgba(255, 0, 255, 0.6); /* Brighter magenta */
    z-index: 9970; /* z-index below guides/button */
    pointer-events: none !important; /* CRITICAL: Non-interactive - prevent any hover effects */
    opacity: 0; /* Hidden by default, final state set by JS */
    /* Use flexbox for vertical text centering */
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 11px;
    color: rgba(255, 107, 255, 1); /* Bright, solid magenta text */
    white-space: nowrap; /* Prevent wrapping */
    text-orientation: mixed;
    transition: opacity 0.4s ease-out; /* Add transition for fade-out */
    /* CRITICAL: Prevent any theme changes or background color changes */
    background-color: rgba(255, 0, 255, 0.15) !important;
    /* Ensure no hover effects can change theme */
    will-change: opacity;
}

/* --- ADDED: Class to trigger entry animation --- */
.dev-margin-visualizer-entering.left {
    animation: dev-margin-enter-left 0.4s ease-out forwards;
}
.dev-margin-visualizer-entering.right {
    animation: dev-margin-enter-right 0.4s ease-out forwards;
}

.dev-margin-visualizer.left {
    left: 0;
    border-left: none;
    border-right: 1px dashed rgba(255, 0, 255, 0.6); /* Brighter magenta */
    /* Vertical text */
    writing-mode: vertical-rl;
}
.dev-margin-visualizer.right {
    right: 0;
    border-right: none;
    border-left: 1px dashed rgba(255, 0, 255, 0.6); /* Brighter magenta */
    /* Vertical text */
    writing-mode: vertical-lr;
}
/* Class to trigger entering animation */
@keyframes dev-margin-enter-left {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0%); opacity: 1; }
}
@keyframes dev-margin-enter-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0%); opacity: 1; }
}
/* Class to trigger exiting animation */
@keyframes dev-margin-exit-left {
  from { transform: translateX(0%); opacity: 1; }
  to   { transform: translateX(-100%); opacity: 0; }
}
@keyframes dev-margin-exit-right {
  from { transform: translateX(0%); opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

.dev-margin-visualizer-exiting {
    opacity: 0;
}

/* Styles for Dev Mode Slot Editing - Lightweight, no visual clutter */
.dev-mode-slots-active .content-slot {
  /* Removed: border, background-color, padding-top - cleaner look */
  padding-bottom: 1rem;
  padding-inline: 0; /* remove horizontal padding */
  margin-bottom: 1rem;
  position: relative;
  /* Subtle hover indication only */
  transition: outline 0.2s ease;
}

/* Light hover indication - no border or background by default */
.dev-mode-slots-active .content-slot:hover {
  outline: 1px solid rgba(59, 130, 246, 0.3); /* Very subtle blue outline on hover */
  outline-offset: 2px;
}

/* RESTORED: Style to show the '+ Add Section' button when dev mode slots are active */
.dev-mode-slots-active #dev-add-section-btn.hidden {
  display: block; /* Override the 'hidden' utility class */
}

/* Show slot controls (drag, delete) - hidden by default, shown on hover */
.dev-mode-slots-active .content-slot .dev-slot-control {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

/* Show controls on hover - but NOT for autolayout children when hovering parent */
.dev-mode-slots-active .content-slot:hover .dev-slot-control {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Prevent autolayout container hover from affecting children */
.dev-mode-slots-active .autolayout-container-dev:hover .autolayout-child .dev-slot-control,
.dev-mode-slots-active .autolayout-container:hover .autolayout-child .dev-slot-control {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Only show children controls when directly hovering the child */
.dev-mode-slots-active .autolayout-child:hover .dev-slot-control,
.dev-mode-slots-active [data-autolayout-child="true"]:hover .dev-slot-control {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Show controls when selected */
.dev-mode-slots-active .content-slot.dev-highlight .dev-slot-control,
.dev-mode-slots-active .content-slot.dev-slot-selected .dev-slot-control {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Exception for showcase delete button - it uses opacity/visibility instead */
/* Updated to use flex for better icon alignment and prevent layout shift */
.dev-mode-slots-active .content-slot .showcase-delete-btn {
    display: inline-flex !important; /* Use flex for better icon alignment */
    align-items: center;
    justify-content: center;
    width: 1.5rem; /* Fixed width to prevent layout shift */
    height: 1.5rem; /* Fixed height to prevent layout shift */
    min-width: 1.5rem; /* Prevent shrinking */
    min-height: 1.5rem; /* Prevent shrinking */
    padding: 0; /* Remove default button padding */
}

/* Style for the text cursor (caret) in editable Dev Mode slots */
/* MODIFIED: Use session-wide class so caret is always visible when editing is possible */
body.dev-session-active [contenteditable="true"] {
    caret-color: #ec4899; /* Use active pink color - replace with design system variable when confirmed */
    /* CRITICAL: Ensure contenteditable elements never get position fixed/absolute */
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
}

/* Dev Mode Animation Classes */
@keyframes activating-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes deactivating-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Example usage with JS adding classes */
.dev-mode-activating .dev-mode-border-container, .dev-mode-activating .dev-guide-line, .dev-mode-activating .dev-tag-display, .dev-mode-activating .dev-spec-box {
    animation: activating-fade-in 0.7s forwards;
}

.dev-mode-deactivating .dev-mode-border-container, .dev-mode-deactivating .dev-guide-line, .dev-mode-deactivating .dev-tag-display, .dev-mode-deactivating .dev-spec-box {
     animation: deactivating-fade-out 0.5s forwards;
}

.dev-margin-visualizer.left {
    left: 0;
}

.dev-margin-visualizer.right {
    right: 0;
}

.dev-margin-visualizer-exiting {
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

/* Additional styles for dev mode elements */
.dev-slot-control {
    /* Styles for delete/add buttons */
    z-index: 100;
    cursor: pointer;
}

/* All delete buttons - hidden by default, shown on hover/selection */
.content-slot.dev-slot-active .delete-button {
    display: inline-flex !important; /* Use flex for better icon alignment */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 1001; /* Higher z-index to be above autolayout container controls */
    position: absolute !important; /* Ensure position is fixed */
    top: 0.5rem !important;
    right: 0.5rem !important;
    width: 1.5rem; /* Fixed width to prevent layout shift */
    height: 1.5rem; /* Fixed height to prevent layout shift */
    min-width: 1.5rem; /* Prevent shrinking */
    min-height: 1.5rem; /* Prevent shrinking */
    padding: 0; /* Remove default button padding */
}

/* For autolayout containers, ensure wrapper controls are above the inner container */
.content-slot.dev-slot-active[data-autolayout-container="true"] .delete-button {
    z-index: 1002; /* Even higher for autolayout wrapper controls */
}

/* Autolayout container delete button - show on hover and selection */
.content-slot.dev-slot-active[data-autolayout-container="true"]:hover .delete-button,
.content-slot.dev-slot-active[data-autolayout-container="true"] .delete-button:hover {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.content-slot.dev-slot-active[data-autolayout-container="true"].dev-highlight .delete-button,
.content-slot.dev-slot-active[data-autolayout-container="true"].dev-slot-selected .delete-button {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Hide drag handle inside autolayout container (drag and drop is handled differently) */
.autolayout-container-dev .drag-handle,
.autolayout-container .drag-handle {
    display: none !important; /* Hide drag handle inside autolayout container */
}

/* Show delete button for autolayout children - positioned to the right side of component */
/* Target both direct children and any element with data-autolayout-child */
.autolayout-container-dev > [data-dev-slot-id] .delete-button,
.autolayout-container-dev > [data-autolayout-child="true"] .delete-button,
.autolayout-container-dev > .autolayout-child .delete-button,
.autolayout-container-dev > .content-slot[data-autolayout-child="true"] .delete-button,
.autolayout-container > [data-dev-slot-id] .delete-button,
.autolayout-container > [data-autolayout-child="true"] .delete-button,
.autolayout-container > .autolayout-child .delete-button,
.autolayout-container > .content-slot[data-autolayout-child="true"] .delete-button {
    display: inline-flex !important;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 1001;
    position: absolute !important;
    /* Position to the right side, vertically centered */
    top: 50% !important;
    right: -2rem !important;  /* Position outside element, to the right */
    transform: translateY(-50%) !important;  /* Center vertically */
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    min-height: 1.5rem;
    padding: 0;
}

/* Ensure wrapper allows overflow for delete button visibility */
.autolayout-container-dev > [data-dev-slot-id],
.autolayout-container-dev > [data-autolayout-child="true"],
.autolayout-container > [data-dev-slot-id],
.autolayout-container > [data-autolayout-child="true"] {
    overflow: visible !important;  /* Allow delete button to be visible outside */
    position: relative !important;  /* Ensure positioning context */
}

/* For small elements, position delete button further to the right */
.autolayout-container-dev > [data-dev-slot-id] .delete-button,
.autolayout-container-dev > [data-autolayout-child="true"] .delete-button {
    /* Use a larger offset for better visibility */
    right: -2.5rem !important;
}

/* Show delete button on hover/selection for autolayout children */
.autolayout-container-dev > [data-dev-slot-id]:hover .delete-button,
.autolayout-container-dev > [data-dev-slot-id] .delete-button:hover,
.autolayout-container-dev > [data-autolayout-child="true"]:hover .delete-button,
.autolayout-container-dev > [data-autolayout-child="true"] .delete-button:hover,
.autolayout-container-dev > .autolayout-child:hover .delete-button,
.autolayout-container-dev > .autolayout-child .delete-button:hover,
.autolayout-container-dev > .content-slot[data-autolayout-child="true"]:hover .delete-button,
.autolayout-container-dev > .content-slot[data-autolayout-child="true"] .delete-button:hover,
.autolayout-container > [data-dev-slot-id]:hover .delete-button,
.autolayout-container > [data-dev-slot-id] .delete-button:hover,
.autolayout-container > [data-autolayout-child="true"]:hover .delete-button,
.autolayout-container > [data-autolayout-child="true"] .delete-button:hover,
.autolayout-container > .autolayout-child:hover .delete-button,
.autolayout-container > .autolayout-child .delete-button:hover,
.autolayout-container > .content-slot[data-autolayout-child="true"]:hover .delete-button,
.autolayout-container > .content-slot[data-autolayout-child="true"] .delete-button:hover {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.autolayout-container-dev > [data-dev-slot-id].dev-highlight .delete-button,
.autolayout-container-dev > [data-dev-slot-id].dev-slot-selected .delete-button,
.autolayout-container-dev > [data-autolayout-child="true"].dev-highlight .delete-button,
.autolayout-container-dev > [data-autolayout-child="true"].dev-slot-selected .delete-button,
.autolayout-container-dev > .autolayout-child.dev-highlight .delete-button,
.autolayout-container-dev > .autolayout-child.dev-slot-selected .delete-button,
.autolayout-container-dev > .content-slot[data-autolayout-child="true"].dev-highlight .delete-button,
.autolayout-container-dev > .content-slot[data-autolayout-child="true"].dev-slot-selected .delete-button,
.autolayout-container > [data-dev-slot-id].dev-highlight .delete-button,
.autolayout-container > [data-dev-slot-id].dev-slot-selected .delete-button,
.autolayout-container > [data-autolayout-child="true"].dev-highlight .delete-button,
.autolayout-container > [data-autolayout-child="true"].dev-slot-selected .delete-button,
.autolayout-container > .autolayout-child.dev-highlight .delete-button,
.autolayout-container > .autolayout-child.dev-slot-selected .delete-button,
.autolayout-container > .content-slot[data-autolayout-child="true"].dev-highlight .delete-button,
.autolayout-container > .content-slot[data-autolayout-child="true"].dev-slot-selected .delete-button {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Delete button for autolayout container itself - positioned relative to container */
.autolayout-container-dev .delete-button:not([data-autolayout-child="true"]),
.autolayout-container .delete-button:not([data-autolayout-child="true"]) {
    display: inline-flex !important;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 1002; /* Higher than children delete buttons */
    position: absolute !important;
    top: 0.5rem !important;
    right: 0.5rem !important;
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    min-height: 1.5rem;
    padding: 0;
}

/* Show delete button on hover/selection for autolayout container */
/* CRITICAL: Only show when hovering the container DIRECTLY, not when hovering children */
/* Use :not() to exclude hover when over children */
.autolayout-container-dev:hover:not(:has([data-autolayout-child="true"]:hover)) > .delete-button:not([data-autolayout-child="true"]),
.autolayout-container-dev:hover:not(:has([data-dev-slot-id]:hover)) > .delete-button:not([data-autolayout-child="true"]),
.autolayout-container-dev > .delete-button:not([data-autolayout-child="true"]):hover,
.autolayout-container:hover:not(:has([data-autolayout-child="true"]:hover)) > .delete-button:not([data-autolayout-child="true"]),
.autolayout-container:hover:not(:has([data-dev-slot-id]:hover)) > .delete-button:not([data-autolayout-child="true"]),
.autolayout-container > .delete-button:not([data-autolayout-child="true"]):hover {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Fallback for browsers that don't support :has() - hide when any child is hovered */
.autolayout-container-dev:hover > [data-autolayout-child="true"]:hover ~ .delete-button:not([data-autolayout-child="true"]),
.autolayout-container-dev:hover > [data-dev-slot-id]:hover ~ .delete-button:not([data-autolayout-child="true"]),
.autolayout-container:hover > [data-autolayout-child="true"]:hover ~ .delete-button:not([data-autolayout-child="true"]),
.autolayout-container:hover > [data-dev-slot-id]:hover ~ .delete-button:not([data-autolayout-child="true"]) {
    opacity: 0 !important;
    pointer-events: none !important;
}

.autolayout-container-dev.dev-highlight > .delete-button:not([data-autolayout-child="true"]),
.autolayout-container-dev.dev-slot-selected > .delete-button:not([data-autolayout-child="true"]),
.autolayout-container.dev-highlight > .delete-button:not([data-autolayout-child="true"]),
.autolayout-container.dev-slot-selected > .delete-button:not([data-autolayout-child="true"]) {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Show delete button when slot is hovered - prevent flickering by keeping it visible when hovering directly */
.content-slot.dev-slot-active:hover .delete-button,
.content-slot.dev-slot-active .delete-button:hover {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Show delete button when slot is selected/clicked */
.content-slot.dev-slot-active.dev-highlight .delete-button,
.content-slot.dev-slot-active.dev-slot-selected .delete-button {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Ensure delete button icon is properly sized and centered */
.content-slot.dev-slot-active .delete-button svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Drag handle - also hidden by default, shown on hover */
.content-slot.dev-slot-active .drag-handle {
    display: inline-flex !important; /* Use flex for better icon alignment */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 1001; /* Higher z-index to be above autolayout container controls */
    position: absolute !important; /* Ensure position is fixed */
    top: 0.5rem !important;
    left: 0.5rem !important;
    width: 1.5rem; /* Fixed width to prevent layout shift */
    height: 1.5rem; /* Fixed height to prevent layout shift */
    min-width: 1.5rem; /* Prevent shrinking */
    min-height: 1.5rem; /* Prevent shrinking */
}

/* For autolayout containers, hide drag handle - drag still works from outline */
.content-slot.dev-slot-active[data-autolayout-container="true"] .drag-handle {
    display: none !important; /* Hide drag handle to avoid confusion with child drag */
}

/* Show drag handle on hover - prevent flickering by keeping it visible when hovering directly */
.content-slot.dev-slot-active:hover .drag-handle,
.content-slot.dev-slot-active .drag-handle:hover {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Show drag handle when selected */
.content-slot.dev-slot-active.dev-highlight .drag-handle,
.content-slot.dev-slot-active.dev-slot-selected .drag-handle {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Ensure drag handle icon is properly sized and centered */
.content-slot.dev-slot-active .drag-handle svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Style for links that are disabled in Dev Mode */
a.dev-link-disabled {
    cursor: default !important; /* Show default cursor, not pointer */
}

/* Add styles for the saving indicator */
#saving-indicator {
    /* Basic styling provided in JS. Add more here if needed. */
    /* HTMX manages display: none/block via .htmx-indicator class */
    background-color: #1f2937; /* Match dev tool theme */
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 10000; /* High z-index */
    /* Position is handled in JS, but could be refined here */
    position: fixed; /* Ensure fixed position */
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

/* HTMX provides classes to show/hide the indicator */
#saving-indicator.htmx-indicator {
    /* HTMX adds this class while request is active */
     display: block; /* Ensure it's visible */
}

/* --- Local Element Saving Indicator Styles --- */
/* Add a pseudo-element to the editable element when it's saving */
[contenteditable="true"].is-saving {
    position: relative; /* Needed for absolute positioning of the loader */
}

[contenteditable="true"].is-saving::after {
    content: '';
    position: absolute;
    /* Position near the right edge */
    top: 50%;
    right: 5px; /* Distance from the right edge */
    transform: translateY(-50%); /* Vertically center */
    /* Spinner styles */
    border: 2px solid rgba(0, 0, 0, 0.3); /* Darker border for light theme */
    border-top: 2px solid #fff; /* White spinner for light theme */
    border-radius: 50%;
    width: 15px;
    height: 15px;
    animation: spin 1s linear infinite; /* Keep spin animation */
    z-index: 10; /* Ensure it's above the text */
}

/* Dark Mode adjustments for the loader */
body.dark .content-slot [contenteditable="true"].is-saving::after {
     border: 2px solid rgba(255, 255, 255, 0.3); /* Lighter border for dark theme */
    border-top: 2px solid #000; /* Black spinner for dark theme */
}

/* Define the spin animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ADDED: Styles for nested elements within rendered slots to preserve formatting */
.content-slot h1[contenteditable="true"] p,
.content-slot p[contenteditable="true"] p,
.content-slot h1[contenteditable="true"] div,
.content-slot p[contenteditable="true"] div {
    /* Inherit font styles from the parent editable element */
    font-size: inherit;
    font-weight: inherit;
    /* Remove default margins added by browser for p/div within contenteditable */
    margin: 0;
    padding: 0;
    /* Add a small bottom margin for paragraph breaks */
    margin-bottom: 0.5em; /* Adjust spacing as needed */
}

/* Handle <br> tags added by contenteditable */
.content-slot h1[contenteditable="true"] br,
.content-slot p[contenteditable="true"] br {
    /* Ensure <br> adds a line break without extra space */
    display: inline; /* Or inline-block if needed for spacing */
}

/* Ensure nested P/DIV within editable H1/P inherit styles */
/* Making this more specific to direct children inserted by browser */
[contenteditable="true"] > p,
[contenteditable="true"] > div {
    font-size: inherit !important;
    font-weight: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
    font-family: inherit !important;
    margin: 0 !important; /* Reset margins for nested blocks */
    padding: 0 !important; /* Reset padding for nested blocks */
    /* Add any other inheritable properties you need */
}

/* Ensure H1s and Ps themselves within content-slots don't get extra margins from browser defaults */
/* This rule seems okay, it targets H1/P that are direct children of .content-slot */
.content-slot > h1,
.content-slot > p {
    margin-block-start: 0;
    margin-block-end: 0;
}

/* More specific styling for contenteditable direct children, if they are block elements */
.content-slot [contenteditable="true"] > div,
.content-slot [contenteditable="true"] > p {
    display: block; /* Ensure they behave as blocks */
    /* You might want to preserve some minimal space for actual paragraph breaks,
       or rely on the natural line break from being a block element.
       If Enter creates multiple divs for multiple line breaks, each will be a block.
       Consider how <br> tags are handled vs new block elements.
    */
}

/* Attempt to vertically center the local loader within its parent slot */
.content-slot.is-saving::before {
    content: '';
    display: inline-block; /* Changed from block to inline-block */
    vertical-align: middle; /* Added for inline-block centering */
    height: 100%;
}

.content-slot.is-saving .local-slot-loader {
    display: inline-block; /* Changed from block to inline-block */
    vertical-align: middle; /* Added for inline-block centering */
    /* Keep other loader styles like position, transform, etc. */
    position: absolute; /* Keep this if you want it overlaid */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Ensure loader is above the text content if overlaid */
    z-index: 10; 
}

/* If the loader is shifting text, we need to ensure the text itself
   doesn't try to wrap around an absolutely positioned loader.
   If .is-saving makes the text container have padding/margin for the loader,
   that's one approach. If the loader is purely an overlay, text shifting
   should ideally not happen unless the dimensions of the .content-slot change.
*/

/* Styles for loader (spinner) */
.local-slot-loader {
  border: 4px solid rgba(255, 255, 255, 0.3); /* Light border */
  border-left-color: #FFF; /* White for the spinner part */
  border-radius: 50%;
  width: 24px; /* Adjust size as needed */
  height: 24px;
  animation: spin 1s linear infinite;
  /* Positioning is now handled by .content-slot.is-saving .local-slot-loader */
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Ensure vertical spacing within CTA slots even when Dev Mode is off */
/* Target H1 and P directly inside a content-slot */
.content-slot h1,
.content-slot p {
    margin-bottom: 1rem; /* Corresponds to Tailwind's mb-4 */
}

/* Target the Div containing the button inside a content-slot */
.content-slot .text-center { /* Using .text-center as a selector for the button container div */
    margin-top: 1rem; /* Add some space above the button */
}

/* Adjust if button itself needs padding/margin fix */
.content-slot .cta-button-link-wrapper {
     /* Ensure this inline-block has necessary spacing if the parent div is not enough */
     display: inline-block; /* Already set, ensure margin applies if needed */
     /* margin-top: 1rem; */ /* Alternative if margin on parent div is not preferred */
     /* Prevents clicks on the link wrapper in dev mode to allow editing the button text */
     pointer-events: none;
}

/* ADDED: Styles for the placeholder text in editable elements */
.is-placeholder {
    font-style: normal; /* Restore original style */
    opacity: 1; /* Make it fully visible */
    color: var(--text-color, #e5e7eb); /* Use a bright, primary text color */
}

/* --- ADDED: Mobile-specific overrides --- */
@media (max-width: 768px) { /* Applies to tablet sizes and below */
    /*
      This class is added to slots that contain full-width components (like the navbar)
      to prevent the slot's own padding from creating horizontal overflow on mobile.
    */
    .dev-mode-slots-active .content-slot.slot-full-bleed-mobile {
        padding-left: 0;
        padding-right: 0;
    }
} 