/* ================================================
 * TUNNEL WYSIWYG v1.0
 * Styles pour l'éditeur inline WYSIWYG
 * Préfixe: .tc-wysiwyg-*
 * ================================================ */

/* ── Active state on preview frame ── */
.tc-wysiwyg-active [data-editable] {
    cursor: text;
    border-radius: 4px;
    /* No transitions on editable elements — prevents visual glitch on focus */
}

.tc-wysiwyg-active [data-editable]:hover:not(.tc-wysiwyg-editing) {
    outline: 2px dashed rgba(139, 92, 246, 0.4);
    outline-offset: 2px;
    background: rgba(139, 92, 246, 0.04);
}

/* ── Editing state ── */
.tc-wysiwyg-editing {
    outline: 2px solid #8b5cf6 !important;
    outline-offset: 2px;
    background: rgba(139, 92, 246, 0.06) !important;
    min-height: 1.2em;
    padding: 2px 4px;
    caret-color: #a78bfa;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Ensure selected text stays visible while editing */
.tc-wysiwyg-editing::selection {
    background: rgba(139, 92, 246, 0.3);
    color: inherit;
}
.tc-wysiwyg-editing::-moz-selection {
    background: rgba(139, 92, 246, 0.3);
    color: inherit;
}

/* ── Section highlight ── */
.tc-wysiwyg-highlight {
    outline: 2px solid rgba(139, 92, 246, 0.3);
    outline-offset: 4px;
    border-radius: 8px;
}

/* ── Drag handle ── */
.tc-wysiwyg-handle {
    position: absolute;
    top: 8px;
    left: -28px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.3);
    cursor: grab;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    z-index: 10;
    user-select: none;
}

.tc-wysiwyg-active [data-section]:hover > .tc-wysiwyg-handle {
    opacity: 1;
}

.tc-wysiwyg-handle:hover {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

.tc-wysiwyg-handle:active {
    cursor: grabbing;
}

/* ── Dragging state ── */
.tc-wysiwyg-dragging {
    opacity: 0.4;
    outline: 2px dashed #8b5cf6;
}

/* ── Drop marker ── */
.tc-wysiwyg-drop-marker {
    height: 3px;
    background: linear-gradient(90deg, transparent, #8b5cf6, transparent);
    margin: 4px 0;
    border-radius: 2px;
    animation: tc-wysiwyg-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes tc-wysiwyg-pulse {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* ── Floating Toolbar ── */
.tc-wysiwyg-toolbar {
    position: fixed;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(20, 20, 35, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100000;
    transform: translateX(-50%);
}

.tc-wysiwyg-toolbar button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    min-width: 28px;
    transition: background 0.15s, color 0.15s;
}

.tc-wysiwyg-toolbar button:hover {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.tc-wysiwyg-sep {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 2px;
}

.tc-wysiwyg-color {
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.tc-wysiwyg-color::-webkit-color-swatch-wrapper { padding: 2px; }
.tc-wysiwyg-color::-webkit-color-swatch { border-radius: 2px; border: none; }

/* ── Section hover outlines ── */
.tc-wysiwyg-active [data-section] {
    position: relative;
    transition: outline 0.15s;
}

.tc-wysiwyg-active [data-section]:hover {
    outline: 1px dashed rgba(255, 255, 255, 0.15);
    outline-offset: 4px;
}

/* ── Section ⋮ Menu Button ── */
.tc-wysiwyg-section-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.3);
    background: rgba(15, 15, 26, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    z-index: 20;
    user-select: none;
    backdrop-filter: blur(8px);
}

.tc-wysiwyg-active [data-section]:hover > .tc-wysiwyg-section-btn {
    opacity: 1;
}

.tc-wysiwyg-section-btn:hover {
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
}

/* ── Section Menu Popup ── */
.tc-wysiwyg-section-menu {
    position: fixed;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: rgba(20, 20, 35, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    z-index: 100001;
    min-width: 150px;
}

.tc-wysiwyg-section-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
}

.tc-wysiwyg-section-menu button:hover {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
}

.tc-wysiwyg-section-menu button[data-action="delete"] {
    color: rgba(239, 68, 68, 0.8);
}

.tc-wysiwyg-section-menu button[data-action="delete"]:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* ── Image Drop Zone Highlight ── */
.tc-wysiwyg-img-drop-highlight {
    outline: 3px dashed #8b5cf6 !important;
    outline-offset: -3px;
    background: rgba(139, 92, 246, 0.08) !important;
    position: relative;
}

.tc-wysiwyg-img-drop-highlight::after {
    content: '📷 Déposer l\'image ici';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(139, 92, 246, 0.9);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    z-index: 50;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Prompt Modal ── */
.tc-wysiwyg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200000;
    backdrop-filter: blur(4px);
}

.tc-wysiwyg-modal {
    background: rgba(20, 20, 35, 0.98);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 14px;
    padding: 24px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.tc-wysiwyg-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 16px;
}

.tc-wysiwyg-modal-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.tc-wysiwyg-modal-input:focus {
    border-color: #8b5cf6;
}

.tc-wysiwyg-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.tc-wysiwyg-modal-cancel {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.tc-wysiwyg-modal-cancel:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
}

.tc-wysiwyg-modal-ok {
    padding: 8px 20px;
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    border: none;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.15s;
}

.tc-wysiwyg-modal-ok:hover {
    opacity: 0.85;
}

/* ── Section Video Embed ── */
.tc-wysiwyg-video-embed {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 16px auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.tc-wysiwyg-video-embed iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 12px;
}

/* ── Section Background Image ── */
.tc-wysiwyg-bg-image {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* ── Ensure preview has room for drag handles ── */
.tc-wysiwyg-active .tcc-pv-page {
    padding-left: 36px;
}
