/* Éditeur Visuel WYSIWYG - Food & Beer */
/* Styles pour l'interface d'édition en ligne */

/* Ajuster le body quand toolbar présente */
body.edit-mode {
    padding-top: 80px !important;
}

/* Barre d'outils */
#visual-editor-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #1f2937;
    color: white;
    padding: 1rem 2rem;
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.toolbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 0.5rem;
}

.toolbar-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.toolbar-info {
    color: #10b981;
    font-weight: 500;
    font-size: 0.95rem;
}

.toolbar-changes {
    color: #fbbf24;
    font-size: 0.875rem;
    font-weight: 600;
    display: none;
}

.btn-toolbar {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background: #374151;
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-toolbar:hover:not(:disabled) {
    background: #4b5563;
    transform: translateY(-1px);
}

.btn-toolbar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-toolbar.btn-primary {
    background: #3b82f6;
}

.btn-toolbar.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-toolbar.btn-exit {
    background: #ef4444;
}

.btn-toolbar.btn-exit:hover {
    background: #dc2626;
}

/* Éléments éditables */
.editable-element {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.editable-hover {
    outline: 2px dashed #3b82f6 !important;
    outline-offset: 4px;
    background: rgba(59, 130, 246, 0.05) !important;
}

.editable-selected {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 4px;
    background: rgba(59, 130, 246, 0.1) !important;
}

/* Panneau d'édition */
.edit-panel {
    position: absolute;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 9999;
    min-width: 320px;
    max-width: 500px;
    animation: slideInUp 0.2s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.edit-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    font-weight: 600;
    font-size: 0.95rem;
}

.close-panel {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: white;
    line-height: 1;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-panel:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.edit-panel-body {
    padding: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input[type="file"] {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.5rem;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

#upload-progress {
    margin-top: 0.5rem;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 50%;
    background: #3b82f6;
    animation: progress 1s ease infinite;
}

@keyframes progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

.edit-panel-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.btn-apply,
.btn-cancel {
    flex: 1;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-apply {
    background: #10b981;
    color: white;
}

.btn-apply:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-cancel {
    background: #f3f4f6;
    color: #1f2937;
}

.btn-cancel:hover {
    background: #e5e7eb;
}

/* Actions de section */
.section-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-section {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: left;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-section:hover {
    background: #f9fafb;
    border-color: #3b82f6;
    transform: translateX(4px);
}

.btn-section.btn-danger {
    color: #ef4444;
    border-color: #fee2e2;
}

.btn-section.btn-danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    #visual-editor-toolbar {
        padding: 0.75rem 1rem;
    }
    
    .toolbar-content {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: center;
    }
    
    .toolbar-center {
        order: -1;
        text-align: center;
    }
    
    .toolbar-info {
        font-size: 0.8rem;
    }
    
    .btn-toolbar {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }
    
    .edit-panel {
        min-width: 280px;
        max-width: calc(100vw - 40px);
        left: 20px !important;
        right: 20px;
    }
    
    body.edit-mode {
        padding-top: 140px !important;
    }
}

/* Animation pour les changements */
@keyframes highlight {
    0%, 100% {
        background: transparent;
    }
    50% {
        background: rgba(16, 185, 129, 0.2);
    }
}

.just-updated {
    animation: highlight 0.6s ease;
}

/* Curseur personnalisé en mode édition */
body.edit-mode * {
    cursor: default !important;
}

body.edit-mode .editable-element {
    cursor: pointer !important;
}

body.edit-mode .edit-panel,
body.edit-mode .edit-panel * {
    cursor: auto !important;
}

/* Désactiver la sélection de texte sauf dans les inputs */
body.edit-mode {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

body.edit-mode input,
body.edit-mode textarea {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    cursor: text !important;
}
