/* Enhanced Edit Mode Styles - Système CMS complet */

/* Variables CSS pour la cohérence */
:root {
    --edit-primary: #667eea;
    --edit-secondary: #764ba2;
    --edit-success: #10b981;
    --edit-error: #ef4444;
    --edit-warning: #f59e0b;
    --edit-info: #3b82f6;
    --edit-bg-overlay: rgba(0, 0, 0, 0.7);
    --edit-border-radius: 8px;
    --edit-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --edit-transition: all 0.3s ease;
}

/* Barre d'édition améliorée */
.edit-mode-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--edit-primary) 0%, var(--edit-secondary) 100%);
    color: white;
    padding: 1rem;
    z-index: 1000;
    box-shadow: var(--edit-shadow);
    display: none;
    backdrop-filter: blur(10px);
}

.edit-mode-bar.active {
    display: flex;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.edit-mode-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 2rem;
}

.edit-mode-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
}

.edit-mode-info i {
    font-size: 1.2rem;
}

.edit-mode-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.edit-mode-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--edit-border-radius);
    cursor: pointer;
    transition: var(--edit-transition);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-mode-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.edit-mode-btn.has-changes {
    background: var(--edit-warning);
    border-color: var(--edit-warning);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.edit-mode-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Éléments éditables */
.editable-element {
    position: relative;
    cursor: pointer;
    transition: var(--edit-transition);
    border-radius: 4px;
}

.editable-element:hover {
    background: rgba(102, 126, 234, 0.1);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    transform: scale(1.01);
}

.editable-element::after {
    content: '✏️';
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--edit-primary);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: var(--edit-transition);
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.editable-element:hover::after {
    opacity: 1;
    transform: scale(1.1);
}

/* Modal d'édition amélioré */
.edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--edit-bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--edit-transition);
    backdrop-filter: blur(5px);
}

.edit-modal.active {
    opacity: 1;
    visibility: visible;
}

.edit-modal-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: var(--edit-transition);
    display: flex;
    flex-direction: column;
}

/* Header fixe */
.edit-modal-header {
    flex-shrink: 0;
}

/* Contenu scrollable */
.edit-modal-content form {
    padding: 1.5rem 2rem;
    flex: 1;
    overflow-y: auto;
}

/* Actions fixes en bas */
.edit-form-actions {
    flex-shrink: 0;
    margin-top: auto;
}

.edit-modal.active .edit-modal-content {
    transform: scale(1);
}

.edit-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--edit-primary), var(--edit-secondary));
    color: white;
}

.edit-modal-title {
    font-size: 1.25rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-modal-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--edit-transition);
}

.edit-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Formulaire d'édition */
.edit-form-group {
    margin-bottom: 1.5rem;
}

.edit-form-label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.edit-form-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: var(--edit-border-radius);
    font-size: 1rem;
    transition: var(--edit-transition);
}

.edit-form-input:focus {
    outline: none;
    border-color: var(--edit-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Éditeur riche */
.rich-editor-container {
    border: 2px solid #e5e7eb;
    border-radius: var(--edit-border-radius);
    overflow: hidden;
    margin-top: 1rem;
}

.rich-editor-toolbar {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.toolbar-btn {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--edit-transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background: var(--edit-primary);
    color: white;
    border-color: var(--edit-primary);
}

.toolbar-btn.active {
    background: var(--edit-primary);
    color: white;
    border-color: var(--edit-primary);
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #d1d5db;
    margin: 0 0.25rem;
}

.rich-editor-content {
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    border: none;
    outline: none;
}

.rich-editor-content:focus {
    background: #fefefe;
}

.rich-editor-preview {
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    padding: 1rem;
}

.rich-editor-preview h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preview-content {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 1rem;
    min-height: 100px;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Actions du formulaire */
.edit-form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem 2rem;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
}

.edit-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--edit-border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--edit-transition);
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-btn-cancel {
    background: #f3f4f6;
    color: #374151;
}

.edit-btn-cancel:hover {
    background: #e5e7eb;
}

.edit-btn-save {
    background: linear-gradient(135deg, var(--edit-primary), var(--edit-secondary));
    color: white;
}

.edit-btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.edit-btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Notification de sauvegarde améliorée */
.save-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--edit-success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--edit-border-radius);
    box-shadow: var(--edit-shadow);
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: var(--edit-transition);
    max-width: 400px;
    font-weight: 500;
}

.save-notification.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.save-notification i {
    margin-right: 0.5rem;
}

/* Ajustement du contenu en mode édition */
body.edit-mode-active {
    padding-top: 80px;
}

/* Styles pour les différents types de contenu */
.editable-element[data-editable*="title"] {
    font-weight: bold;
}

.editable-element[data-editable*="email"]:hover::before {
    content: "📧 ";
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
}

.editable-element[data-editable*="phone"]:hover::before {
    content: "📞 ";
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
}

.editable-element[data-editable*="address"]:hover::before {
    content: "📍 ";
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
}

/* Responsive design */
@media (max-width: 768px) {
    .edit-mode-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .edit-mode-controls {
        justify-content: center;
    }
    
    .edit-modal-content {
        width: 98%;
        margin: 1rem;
    }
    
    .edit-modal-header {
        padding: 1rem;
    }
    
    .edit-form-actions {
        padding: 1rem;
        flex-direction: column;
    }
    
    .rich-editor-toolbar {
        padding: 0.5rem;
    }
    
    .toolbar-btn {
        width: 32px;
        height: 32px;
    }
    
    body.edit-mode-active {
        padding-top: 120px;
    }
}

/* Animations supplémentaires */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.edit-modal.active .edit-modal-content {
    animation: fadeInUp 0.3s ease-out;
}

/* États de chargement */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Styles pour les éléments de liste dans l'éditeur */
.rich-editor-content ul,
.rich-editor-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.rich-editor-content li {
    margin: 0.25rem 0;
}

.rich-editor-content a {
    color: var(--edit-primary);
    text-decoration: underline;
}

.rich-editor-content strong {
    font-weight: bold;
}

.rich-editor-content em {
    font-style: italic;
}

.rich-editor-content u {
    text-decoration: underline;
}

/* Indicateurs de validation */
.validation-error {
    color: var(--edit-error);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.validation-success {
    color: var(--edit-success);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Amélioration de l'accessibilité */
.edit-mode-btn:focus,
.toolbar-btn:focus,
.edit-btn:focus {
    outline: 2px solid var(--edit-primary);
    outline-offset: 2px;
}

.rich-editor-content:focus {
    box-shadow: 0 0 0 2px var(--edit-primary);
}

/* Styles pour le mode sombre (optionnel) */
@media (prefers-color-scheme: dark) {
    .edit-modal-content {
        background: #1f2937;
        color: white;
    }
    
    .edit-form-input {
        background: #374151;
        border-color: #4b5563;
        color: white;
    }
    
    .rich-editor-toolbar {
        background: #374151;
        border-color: #4b5563;
    }
    
    .toolbar-btn {
        background: #4b5563;
        border-color: #6b7280;
        color: white;
    }
    
    .rich-editor-content {
        background: #374151;
        color: white;
    }
    
    .rich-editor-preview {
        background: #374151;
        border-color: #4b5563;
    }
    
    .preview-content {
        background: #4b5563;
        border-color: #6b7280;
        color: white;
    }
}
