/**
 * Certificat Manager — Bouton dédié + modale Product Table Pro
 * Le bouton (shortcode [certificat_etalonnage_add_to_cart]) ouvre la
 * modale : infos produit, quantité, choix du certificat, total.
 */

/* ---- Bouton dédié (remplace/complète le bouton natif Barn2) ---- */
.certificat-etalonnage-add-btn.certificat-etalonnage-add-btn {
    background-color: #c00000 !important;
    border: 1px solid #c00000 !important;
    color: #ffffff !important;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: nowrap;
}

.certificat-etalonnage-add-btn.certificat-etalonnage-add-btn:hover,
.certificat-etalonnage-add-btn.certificat-etalonnage-add-btn:focus {
    background-color: #a00000 !important;
    border-color: #a00000 !important;
    color: #ffffff !important;
}

#certificat-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.60);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

body.certificat-modal-open {
    overflow: hidden;
}

#certificat-modal {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 28px;
    box-sizing: border-box;
}

#certificat-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    padding: 6px 10px;
    border-radius: 4px;
}

#certificat-modal-close:hover,
#certificat-modal-close:focus {
    color: #c00000;
    background-color: #f5f5f5;
    outline: none;
}

/* ---- Infos produit ---- */
#certificat-modal-product {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-right: 30px;
    margin-bottom: 18px;
}

#certificat-modal-product-image {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border: 1px solid #eee;
    border-radius: 4px;
    flex-shrink: 0;
}

#certificat-modal-title {
    margin: 0 0 4px 0;
    font-size: 1rem;
    font-weight: 700;
    color: #000;
    line-height: 1.3;
}

#certificat-modal-product-price {
    font-size: 0.95rem;
    font-weight: 600;
    color: #c00000;
}

/* ---- Quantité ---- */
#certificat-modal-quantity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

#certificat-modal-quantity-row label {
    font-weight: 600;
    color: #000;
    font-size: 0.9rem;
}

#certificat-modal-quantity-stepper {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}

#certificat-modal-quantity-stepper button {
    background: #f5f5f5;
    border: none;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    color: #333;
}

#certificat-modal-quantity-stepper button:hover {
    background: #e8e8e8;
}

#certificat-modal-quantity {
    width: 48px;
    height: 32px;
    border: none;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    text-align: center;
    font-size: 14px;
    -moz-appearance: textfield;
}

#certificat-modal-quantity::-webkit-outer-spin-button,
#certificat-modal-quantity::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---- Liste des certificats (réutilise le style .certificat-item existant) ---- */
#certificat-modal-body .certificat-item {
    background: #f5f5f5;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 12px 14px;
    margin: 0 0 8px 0;
    cursor: pointer;
}

#certificat-modal-body .certificat-item:hover {
    border-color: #c00000;
    background: #fafafa;
}

#certificat-modal-body .certificat-item.selected {
    background: #fff;
    border-color: #c00000;
    border-width: 2px;
    padding: 11px 13px;
}

#certificat-modal-body .certificat-option-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    cursor: pointer;
}

#certificat-modal-body .certificat-option-label input[type="radio"] {
    margin: 0;
    width: 16px;
    height: 16px;
    accent-color: #c00000;
    flex-shrink: 0;
}

#certificat-modal-body .certificat-nom {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
    color: #000;
}

#certificat-modal-body .certificat-price-display {
    font-weight: 700;
    font-size: 14px;
    color: #000;
    white-space: nowrap;
}

/* ---- Total ---- */
#certificat-modal-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid #e5e5e5;
    font-weight: 600;
}

#certificat-modal-total-value {
    font-weight: 700;
    font-size: 17px;
    color: #c00000;
}

/* ---- Pied de modale ---- */
#certificat-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

#certificat-modal-cancel.button {
    background-color: #f0f0f0;
    border: 1px solid #d0d0d0;
    color: #444;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}

#certificat-modal-confirm.button {
    background-color: #c00000;
    border: 1px solid #c00000;
    color: #fff;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
}

#certificat-modal-confirm.button:hover:not(:disabled) {
    background-color: #a00000;
}

#certificat-modal-confirm.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#certificat-modal-loading {
    text-align: center;
    color: #666;
    padding: 8px 0;
}

@media (max-width: 480px) {
    #certificat-modal {
        padding: 20px 16px;
    }

    #certificat-modal-footer {
        flex-direction: column-reverse;
    }

    #certificat-modal-cancel.button,
    #certificat-modal-confirm.button {
        width: 100%;
        text-align: center;
    }
}
