/**
 * Styles pour les modales - Catalogue Manager
 */

/* === Modal de base === */
.cm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cm-modal.cm-modal-open {
    opacity: 1;
    visibility: visible;
}

.cm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
}

.cm-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 1;
}

.cm-modal.cm-modal-open .cm-modal-content {
    transform: scale(1);
}

.cm-body-locked {
  overflow: hidden !important;
}


/* === Bouton fermeture === */
.cm-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.cm-modal-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

/* === Modal produit === */
.cm-product-modal-content {
    width: 800px;
    padding: 40px;
}

.cm-product-modal-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.cm-product-modal-image {
    position: relative;
    padding-top: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
}

.cm-product-modal-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cm-product-modal-details {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cm-product-modal-title {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.cm-product-modal-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cm-product-modal-brand img {
    max-width: 80px;
    max-height: 40px;
    object-fit: contain;
}

.cm-product-modal-brand-name {
    font-size: 16px;
    font-weight: 600;
    color: #666;
}

.cm-product-modal-categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cm-product-modal-category {
    display: inline-block;
    padding: 5px 12px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 13px;
    color: #666;
}

.cm-product-modal-price {
    font-size: 32px;
    font-weight: 700;
    color: #0073aa;
    margin: 10px 0;
}

.cm-product-modal-description {
    font-size: 15px;
    line-height: 1.7;
    color: #555;
}

.cm-product-modal-actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.cm-add-to-cart-btn {
    flex: 1;
    padding: 15px 30px;
    background: #156a2b !important;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cm-add-to-cart-btn:hover {
    background: #218838 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.cm-add-to-cart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* === Modal devis === */
.cm-quote-modal-content {
    width: 700px;
    padding: 40px;
}

.cm-quote-modal-content h3 {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin: 0 0 30px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cm-quote-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cm-form-row {
    display: grid;
    gap: 20px;
}

.cm-form-row-2 {
    grid-template-columns: 1fr 1fr;
}

.cm-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cm-form-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cm-form-group input,
.cm-form-group textarea,
.cm-form-group select {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.cm-form-group input:hover,
.cm-form-group textarea:hover,
.cm-form-group select:hover {
    border-color: #c0c0c0;
}

.cm-form-group input:focus,
.cm-form-group textarea:focus,
.cm-form-group select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.cm-form-group input[required] + label::after,
.cm-form-group label:has(+ input[required])::after,
.cm-form-group label:has(+ textarea[required])::after,
.cm-form-group label:has(+ select[required])::after {
    content: '';
    color: #dc3545;
}

.cm-form-actions {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.cm-button-secondary {
    background: #6c757d !important;
    color: white !important;
}

.cm-button-secondary:hover {
    background: #5a6268 !important;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3) !important;
}

.cm-form-message {
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    margin-top: 15px;
}

.cm-form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.cm-form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* === Loading state === */
.cm-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.cm-modal-loading::after {
    content: "";
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: cm-spin 1s linear infinite;
}

@keyframes cm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === Responsive === */
@media (max-width: 900px) {
    .cm-product-modal-content {
        width: 95%;
        padding: 30px 20px;
    }

    .cm-product-modal-inner {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .cm-quote-modal-content {
        width: 95%;
        padding: 30px 20px;
    }

    .cm-quote-modal-content h3 {
        font-size: 24px;
    }

    .cm-form-row-2 {
        grid-template-columns: 1fr;
    }

    .cm-form-actions {
        flex-direction: column;
    }
    
    .cm-form-actions button {
        width: 100%;
    }
}