:root {
    --primary: #6B6BEF;
    --primary-light: #B8B8FF;
    --primary-lighter: #E4E4FF;
    --success: #52D6A1;
    --error: #FF7B7B;
    --text-main: #1C1C28;
    --text-secondary: #6B6B7A;
    --border: #E2E2EA;
    --bg-gradient-start: #F9FAFB;
    --bg-gradient-end: #E4E4FF;
    --white: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(107, 107, 239, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 30px 40px;
    color: var(--white);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.header p {
    font-size: 14px;
    opacity: 0.9;
}

.editor-wrapper {
    padding: 40px;
}

.section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-badge {
    background: var(--primary-lighter);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-pro {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--white);
}

/* Toggle view switcher */
.view-switcher {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    background: var(--bg-gradient-start);
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
    border: 2px solid var(--border);
}

.view-btn {
    padding: 10px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-btn:hover {
    color: var(--primary);
}

.view-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(107, 107, 239, 0.1);
}

.view-btn svg {
    width: 16px;
    height: 16px;
}

/* Mode code HTML */
.html-code-editor {
    display: none;
    width: 100%;
    min-height: 400px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    background: var(--text-main);
    color: var(--primary-lighter);
    resize: vertical;
}

.html-code-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(107, 107, 239, 0.1);
}

/* Wrapper pour cacher/montrer les éditeurs */
.editor-container {
    position: relative;
}

.editor-container.code-mode .tinymce-wrapper {
    display: none;
}

.editor-container.code-mode .html-code-editor {
    display: block;
}

.editor-container.visual-mode .tinymce-wrapper {
    display: block;
}

.editor-container.visual-mode .html-code-editor {
    display: none;
}

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(107, 107, 239, 0.1);
}

.preview-image {
    width: 100%;
    max-width: 600px;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    margin-top: 12px;
    border: 2px solid var(--border);
}

.help-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-text::before {
    content: "💡";
}

.actions {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    padding: 30px 40px;
    background: var(--bg-gradient-start);
    border-top: 1px solid var(--border);
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary {
    background: var(--white);
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(107, 107, 239, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(107, 107, 239, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(28, 28, 40, 0.8);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

.loading.active {
    display: flex;
}

.loading-text {
    color: var(--white);
    font-size: 16px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--primary-lighter);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success);
    color: var(--white);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(82, 214, 161, 0.3);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.toast.active {
    display: flex;
}

.toast.error {
    background: var(--error);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.info-box {
    background: var(--primary-lighter);
    border-left: 4px solid var(--primary);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-main);
}

.info-box strong {
    color: var(--primary);
}

.error-box {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(255, 123, 123, 0.3);
    border: 2px solid var(--error);
    max-width: 500px;
    z-index: 10001;
}

.error-box.active {
    display: block;
}

.error-box h3 {
    color: var(--error);
    margin-bottom: 16px;
}

.success-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(107, 107, 239, 0.95) 0%, rgba(184, 184, 255, 0.95) 100%);
    z-index: 10002;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 30px;
    animation: fadeIn 0.5s ease;
}

.success-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.success-content {
    text-align: center;
    color: var(--white);
}

.success-icon {
    width: 100px;
    height: 100px;
    border: 5px solid var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    margin: 0 auto 20px;
    animation: scaleIn 0.5s ease 0.3s both;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

.success-content h2 {
    font-size: 32px;
    margin-bottom: 12px;
}

.success-content p {
    opacity: 0.9;
}

/* PREVIEW MODAL */
.preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(28, 28, 40, 0.95);
    z-index: 10003;
    justify-content: center;
    align-items: flex-start;
    padding: 40px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

.preview-modal.active {
    display: flex;
}

.preview-content-wrapper {
    background: var(--white);
    width: 100%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    margin: auto 0;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-gradient-start);
    border-radius: 12px 12px 0 0;
}

.preview-header h2 {
    font-size: 20px;
    color: var(--text-main);
    margin: 0;
}

.close-preview {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 24px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.close-preview:hover {
    background: var(--border);
    color: var(--text-main);
}

.preview-body {
    padding: 40px;
    background: var(--white);
    border-radius: 0 0 12px 12px;
}