/**
 * Product Customization System - Complete Styles
 * 
 * Styles pour le système complet de personnalisation de produits
 * Compatible avec le design system existant de MakeYourProject
 * 
 * @author MakeYourProject
 * @version 1.0
 */

/* ============================================
   CONTENEUR PRINCIPAL
   ============================================ */
.customization-form-container {
    margin: 3rem 0;
    padding: 2.5rem;
    background: white;
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--gray-200, #e5e7eb);
}

.customization-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--gray-100, #f3f4f6);
}

.customization-header h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900, #111827);
    margin-bottom: 0.75rem;
    font-family: 'Outfit', sans-serif;
}

.customization-subtitle {
    font-size: 1.125rem;
    color: var(--gray-600, #4b5563);
    margin: 0;
}

/* ============================================
   SECTIONS
   ============================================ */
.customization-section {
    margin-bottom: 3rem;
    padding: 2rem;
    background: var(--gray-50, #f9fafb);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--gray-200, #e5e7eb);
}

.customization-section h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin-bottom: 1.5rem;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    font-size: 1.125rem;
    font-weight: 700;
}

/* ============================================
   ZONE D'UPLOAD
   ============================================ */
.customization-upload-area {
    margin-bottom: 2rem;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    border: 3px dashed var(--gray-300, #d1d5db);
    border-radius: var(--radius-md, 12px);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.upload-label:hover {
    border-color: var(--primary, #6366f1);
    background: var(--gray-50, #f9fafb);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
}

.upload-label svg {
    color: var(--primary, #6366f1);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900, #111827);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--gray-500, #6b7280);
}

/* ============================================
   CADRE DE PRÉVISUALISATION
   ============================================ */
.customization-preview-container {
    position: relative;
}

.customization-frame {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    margin: 0 auto;
    overflow: hidden;
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 3px solid var(--gray-200, #e5e7eb);
    background: white;
    /* Comme dans WooCommerce */
    touch-action: none;
    user-select: none;
}

/* Responsive pour tablette */
@media (max-width: 1024px) {
    .customization-frame {
        max-width: 400px;
        border-width: 2px;
    }
}

/* Responsive pour smartphone - Cadre pleine largeur */
@media (max-width: 768px) {
    .customization-form-container {
        margin: 1.5rem 0;
        padding: 1.5rem;
    }
    
    .customization-section {
        padding: 1rem;
        margin-bottom: 2rem;
    }
    
    .customization-frame {
        max-width: 100%;
        width: 100%;
        min-height: 280px;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    
    .upload-label {
        padding: 2rem 1rem;
    }
}

.frame-image {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    display: none; /* Cach\u00e9 par d\u00e9faut, affich\u00e9 par JS */
    z-index: 5;
    /* Transition douce comme dans WooCommerce */
    transition: transform 0.1s ease;
    -webkit-touch-callout: none;
    transition: filter 0.2s ease;
    z-index: 5; /* Entre le fond (0) et le masque (10) */
}

.frame-image:active {
    cursor: grabbing;
}

.frame-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    user-select: none;
}

/* ============================================
   CONTRÔLES DE MANIPULATION
   ============================================ */
.manipulation-controls {
    margin-top: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius, 8px);
    border: 1px solid var(--gray-200, #e5e7eb);
}

.control-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600, #4b5563);
    line-height: 1.6;
}

.control-hint svg {
    flex-shrink: 0;
    color: var(--primary, #6366f1);
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--gray-200, #e5e7eb);
    }
}

/* ============================================
   ZONE DE TEXTE
   ============================================ */
.text-input-container {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md, 12px);
    border: 1px solid var(--gray-200, #e5e7eb);
}

.text-input-container label {
    display: block;
    font-weight: 600;
    color: var(--gray-700, #374151);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.text-input-container textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--gray-300, #d1d5db);
    border-radius: var(--radius, 8px);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
}

.text-input-container textarea:focus {
    outline: none;
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.char-counter {
    text-align: right;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-500, #6b7280);
}

.char-counter span {
    font-weight: 600;
    color: var(--primary, #6366f1);
}

/* ============================================
   ACTIONS / BOUTONS
   ============================================ */
.customization-actions {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--gray-200, #e5e7eb);
    text-align: center;
}

#validateCustomizationButton {
    min-width: 280px;
    padding: 1.25rem 2.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    text-transform: none;
    letter-spacing: 0;
}

#validateCustomizationButton.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

#validateCustomizationButton.validated {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.validation-notice {
    font-size: 0.875rem;
    color: var(--gray-500, #6b7280);
    margin: 0;
    font-style: italic;
}

/* ============================================
   MESSAGE DE SUCCÈS
   ============================================ */
.customization-success-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 2px solid #34d399;
    border-radius: var(--radius-md, 12px);
    color: #065f46;
    margin-bottom: 2rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    transition: opacity 0.3s ease;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.customization-success-message svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .customization-form-container {
        padding: 2rem;
    }
    
    .customization-section {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .customization-form-container {
        padding: 1.5rem;
        margin: 2rem 0;
    }
    
    .customization-header h2 {
        font-size: 1.75rem;
    }
    
    .customization-subtitle {
        font-size: 1rem;
    }
    
    .customization-section {
        padding: 1.25rem;
        margin-bottom: 2rem;
    }
    
    .customization-section h3 {
        font-size: 1.25rem;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .upload-label {
        padding: 2rem 1rem;
    }
    
    .customization-frame {
        max-width: 100%;
    }
    
    #validateCustomizationButton {
        width: 100%;
        min-width: auto;
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .customization-header {
        margin-bottom: 2rem;
        padding-bottom: 1.5rem;
    }
    
    .customization-header h2 {
        font-size: 1.5rem;
    }
    
    .upload-label svg {
        width: 36px;
        height: 36px;
    }
    
    .upload-text {
        font-size: 1rem;
    }
}

/* ============================================
   ÉTATS ET ANIMATIONS
   ============================================ */
.customization-frame.loading {
    opacity: 0.6;
    pointer-events: none;
}

.customization-frame.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-300, #d1d5db);
    border-top-color: var(--primary, #6366f1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ============================================
   TOOLTIPS / HINTS
   ============================================ */
.customization-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.customization-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--gray-900, #111827);
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    border-radius: var(--radius-sm, 6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.customization-tooltip:hover::after {
    opacity: 1;
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   RESPONSIVE DESIGN - MULTI-DISPOSITIFS
   ============================================ */

/* Desktop Large (> 1280px) - Affichage optimal */
@media (min-width: 1280px) {
    .customization-form-container {
        padding: 3rem;
    }
    
    .customization-frame {
        max-width: 500px;
    }
}

/* Desktop Standard (1024px - 1280px) */
@media (max-width: 1280px) and (min-width: 1024px) {
    .customization-form-container {
        padding: 2.5rem;
    }
    
    .customization-section {
        margin-bottom: 2rem;
    }
}

/* Tablette Paysage (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    .customization-form-container {
        padding: 2rem;
        margin: 2rem 0;
    }
    
    .customization-header h2 {
        font-size: 1.75rem;
    }
    
    .customization-frame {
        max-width: 400px;
        border-width: 2px;
    }
    
    .upload-label {
        padding: 2rem;
    }
    
    .upload-label svg {
        width: 40px;
        height: 40px;
    }
    
    #validateCustomizationButton {
        min-width: 240px;
        padding: 1rem 2rem;
        font-size: 1rem;
    }
}

/* Tablette Portrait & Smartphone Large (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    .customization-form-container {
        padding: 1.5rem;
        margin: 1.5rem 0;
        border-radius: 12px;
    }
    
    .customization-header h2 {
        font-size: 1.5rem;
    }
    
    .customization-subtitle {
        font-size: 0.95rem;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .customization-section h3 {
        font-size: 1.25rem;
    }
    
    .customization-frame {
        max-width: 100%;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    
    .upload-label {
        padding: 1.5rem;
    }
    
    .upload-text {
        font-size: 1rem;
    }
    
    .manipulation-controls {
        padding: 1rem;
    }
    
    .control-hint {
        font-size: 0.8rem;
    }
    
    #validateCustomizationButton {
        width: 100%;
        min-width: auto;
        padding: 1.125rem 1.5rem;
        font-size: 1rem;
    }
    
    .text-input-container textarea {
        font-size: 0.95rem;
        padding: 0.875rem;
    }
}

/* Smartphone Standard (320px - 480px) */
@media (max-width: 480px) {
    .customization-form-container {
        padding: 1rem;
        margin: 1rem 0;
        border-radius: 8px;
    }
    
    .customization-header {
        margin-bottom: 1.5rem;
    }
    
    .customization-header h2 {
        font-size: 1.25rem;
        line-height: 1.3;
    }
    
    .customization-subtitle {
        font-size: 0.875rem;
    }
    
    .customization-section {
        margin-bottom: 1.5rem;
    }
    
    .customization-section h3 {
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
        margin-right: 0.5rem;
    }
    
    /* Zone d'upload plus compacte */
    .customization-upload-area {
        margin-bottom: 1rem;
    }
    
    .upload-label {
        padding: 1.25rem 1rem;
    }
    
    .upload-label svg {
        width: 36px;
        height: 36px;
        margin-bottom: 0.5rem;
    }
    
    .upload-text {
        font-size: 0.95rem;
    }
    
    .upload-hint {
        font-size: 0.75rem;
    }
    
    /* Cadre de prévisualisation optimisé mobile */
    .customization-frame {
        border-width: 2px;
        border-radius: 6px;
    }
    
    /* Contrôles de manipulation */
    .manipulation-controls {
        padding: 0.75rem;
        margin-top: 0.75rem;
    }
    
    .control-hint {
        font-size: 0.75rem;
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    .control-hint svg {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }
    
    .control-hint.mobile-only {
        display: block;
    }
    
    /* Zone de texte */
    .text-input-container {
        margin-top: 1rem;
    }
    
    .text-input-container label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }
    
    .text-input-container textarea {
        font-size: 0.875rem;
        padding: 0.75rem;
        min-height: 100px;
    }
    
    .char-counter {
        font-size: 0.75rem;
    }
    
    /* Bouton de validation pleine largeur */
    .customization-actions {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }
    
    #validateCustomizationButton {
        width: 100%;
        min-width: auto;
        padding: 1rem 1.25rem;
        font-size: 0.95rem;
        gap: 0.5rem;
    }
    
    .validation-notice {
        font-size: 0.75rem;
        padding: 0 0.5rem;
    }
    
    /* Message de succès */
    .customization-success-message {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
}

/* Smartphone Très Petit (< 360px) */
@media (max-width: 360px) {
    .customization-form-container {
        padding: 0.75rem;
    }
    
    .customization-header h2 {
        font-size: 1.125rem;
    }
    
    .step-number {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    
    .upload-label {
        padding: 1rem 0.75rem;
    }
    
    .upload-text {
        font-size: 0.875rem;
    }
}

/* Focus visible pour accessibilité clavier */
.upload-label:focus-visible,
.frame-image:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--primary, #6366f1);
    outline-offset: 2px;
}

/* ============================================
   SLIDERS D'AJUSTEMENT D'IMAGE
   ============================================ */
.image-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.image-slider:hover {
    background: #d1d5db;
}

/* Chrome, Safari, Edge */
.image-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
    transition: all 0.2s;
}

.image-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.6);
}

/* Firefox */
.image-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
    transition: all 0.2s;
}

.image-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.6);
}

/* Boutons d'ajustement */
.btn-remove-bg:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-reset-adjustments:hover {
    background: #d1d5db;
}

.btn-remove-bg:active,
.btn-reset-adjustments:active {
    transform: translateY(0);
}

/* État de chargement pour suppression du fond */
.btn-remove-bg.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-remove-bg.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* ============================================
   OVERLAY DE CHARGEMENT POUR SUPPRESSION FOND
   ============================================ */
.bg-removal-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 12px;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: #667eea;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================
   MESSAGES D'ERREUR ET DE SUCCÈS
   ============================================ */
.customization-success-message,
.customization-error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease-out;
    transition: opacity 0.3s ease-out;
}

.customization-success-message {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 2px solid #10b981;
    color: #065f46;
}

.customization-success-message svg {
    color: #10b981;
    flex-shrink: 0;
}

.customization-error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid #ef4444;
    color: #991b1b;
}

.customization-error-message svg {
    color: #ef4444;
    flex-shrink: 0;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .customization-form-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .manipulation-controls,
    .customization-actions {
        display: none;
    }
}
