/**
 * Slide Editor Styles - Inline Editing Mode
 * Direct canvas editing with bottom sheet (mobile) and inline input (desktop)
 */

/* ============================================
   CSS Variables - Use brand colors
   ============================================ */
:root {
    --slide-primary: var(--color-primary, #970747);
    --slide-primary-rgb: 151, 7, 71;
    --slide-primary-light: rgba(151, 7, 71, 0.1);
    --slide-primary-glow: rgba(151, 7, 71, 0.3);
}

/* ============================================
   Slide Editor Container
   ============================================ */
.slide-editor {
    max-width: 48rem;
    margin: 0 auto;
}

/* Mobile: Full screen canvas */
@media (max-width: 767px) {
    .slide-editor {
        max-width: 100%;
        padding: 0;
    }
}

/* ============================================
   Preview Canvas
   ============================================ */
.slide-preview-canvas {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 16;
    max-height: 70vh;
    /* Increased from 55vh - more room without form panel */
    margin: 0 auto;
    background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@media (max-width: 767px) {
    .slide-preview-canvas {
        max-height: 65vh;
        /* Much more room on mobile without form */
        border-radius: 0;
    }
}

/* ============================================
   Editable Layers - Interactive Elements
   ============================================ */

/* Make editable layers clickable */
.slide-preview-text.editable,
.slide-preview-image.editable {
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Hover/focus state for editable text */
.slide-preview-text.editable:hover,
.slide-preview-text.editable:focus {
    outline: 2px dashed rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
}

/* Active/editing state */
.slide-preview-text.editable.editing {
    outline: 2px solid var(--slide-primary);
    outline-offset: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 4px 8px;
    min-width: 50px;
    cursor: text;
    -webkit-user-select: text;
    user-select: text;
}

/* Mobile: contenteditable focus state */
.slide-preview-text.editable[contenteditable="true"] {
    outline: 2px solid var(--slide-primary);
    outline-offset: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 8px 12px;
    min-width: 80px;
    min-height: 30px;

    /* Prevent rich text editing - plain text only */
    -webkit-user-modify: read-write-plaintext-only;

    /* Force font style inheritance from data attributes */
    font-size: inherit !important;
    font-family: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
    text-align: inherit !important;
    line-height: inherit !important;
    letter-spacing: inherit !important;
}

/* Ensure pasted content maintains styling */
.slide-preview-text.editable[contenteditable="true"] * {
    font-size: inherit !important;
    font-family: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
}

/* Edit icon that appears on hover */
.editable-icon {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--slide-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 20;
}

.editable-icon svg {
    width: 14px;
    height: 14px;
    fill: white;
}

.slide-preview-text.editable:hover .editable-icon,
.slide-preview-image.editable:hover .editable-icon {
    opacity: 1;
    transform: scale(1);
}

/* Empty image placeholder */
.slide-preview-image.editable.empty {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}

.slide-preview-image.editable.empty:hover {
    border-color: var(--slide-primary);
    background: rgba(151, 7, 71, 0.1);
}

.image-upload-hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    text-align: center;
}

.image-upload-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   First-time User Hint
   ============================================ */
.tap-hint {
    text-align: center;
    padding: 12px 16px;
    color: #64748b;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tap-hint-icon {
    font-size: 20px;
}

/* ============================================
   Bottom Sheet & Inline Input
   ============================================ 
   NOTE: These components now use Tailwind classes 
   in customize.php for styling and animation.
   See the edit-sheet and inline-input-container elements.
   ============================================ */

/* Animation keyframes for inline input popup */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.animate-pop-in {
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Hide scrollbar but keep scroll functionality */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* ============================================
   Image Upload Modal (Touch-Friendly)
   ============================================ */
.image-upload-sheet {
    /* Applied together with .edit-sheet class, shares same base styles */
    padding-top: 24px;
}

.image-upload-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.image-upload-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.image-upload-option:hover {
    border-color: var(--slide-primary);
    background: var(--slide-primary-light);
}

.image-upload-option-icon {
    width: 48px;
    height: 48px;
    background: var(--slide-primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--slide-primary);
}

.image-upload-option-text {
    flex: 1;
}

.image-upload-option-text strong {
    display: block;
    color: #1e293b;
    margin-bottom: 2px;
}

.image-upload-option-text span {
    font-size: 13px;
    color: #64748b;
}

/* ============================================
   Slide Navigation (Simplified)
   ============================================ */
.slide-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.slide-nav-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-weight: 500;
    transition: color 0.2s;
    text-decoration: none;
}

.slide-nav-back:hover {
    color: var(--slide-primary);
}

.slide-nav-title {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.875rem;
}

.slide-nav-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.slide-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slide-dot.active {
    background: var(--slide-primary);
    width: 28px;
    border-radius: 5px;
}

.slide-dot.completed {
    background: #22c55e;
}

/* ============================================
   Navigation Buttons (Bottom)
   ============================================ */
.slide-editor-nav {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.slide-editor-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s;
    text-decoration: none;
}

.slide-editor-btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.slide-editor-btn-secondary:hover {
    background: #e2e8f0;
}

.slide-editor-btn-primary {
    background: var(--slide-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 14px var(--slide-primary-glow);
}

.slide-editor-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--slide-primary-glow);
}

/* Fixed Bottom Bar on Mobile */
.slide-editor-mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .slide-editor-mobile-nav {
        display: none;
    }
}

@media (max-width: 767px) {
    .slide-editor-nav {
        display: none;
    }
}

/* ============================================
   Loading & Empty States
   ============================================ */
.slide-preview-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.slide-preview-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty state for layer without value */
.slide-layer-empty {
    opacity: 0.5;
    font-style: italic;
}

/* ============================================
   Preview layer base styles (kept for compatibility)
   ============================================ */
.slide-preview-text {
    pointer-events: none;
    z-index: 10;
}

.slide-preview-image {
    pointer-events: none;
    z-index: 5;
}

.slide-preview-bg {
    z-index: 0;
}