/**
 * Cekonay Dimensions - Styles
 * Version 3.0
 */

/* ========================================
   Conteneur principal
   ======================================== */

.cekonay-dimensions-wrapper {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.cekonay-dimensions-wrapper h3 {
    margin: 0 0 20px;
    color: #2c3e50;
    font-size: 1.3em;
    font-weight: 600;
    border-bottom: 2px solid #e6dbed;
    padding-bottom: 10px;
}

/* ========================================
   Sections de formulaire
   ======================================== */

.dimension-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.form-group label {
    font-weight: 600;
    color: #495057;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.form-group label .required {
    color: #e74c3c;
    font-weight: bold;
}

/* ========================================
   Champs de formulaire
   ======================================== */
.calculateurpanier input {
    font-size: 18px !important;
}

.cekonay-input,
.cekonay-select {
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.3s ease;
    background: white;
    width: 100%;
}

.cekonay-input:focus,
.cekonay-select:focus {
    outline: none;
    border-color: #8fa2dd;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.cekonay-input:hover,
.cekonay-select:hover {
    border-color: #adb5bd;
}

.cekonay-input.valid {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.05);
}

.cekonay-input.error {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.05);
}

/* ========================================
   Messages d'information
   ======================================== */

.dimension-info {
    font-size: 0.85em;
    min-height: 20px;
    transition: all 0.3s ease;
}

.dimension-info.info {
    color: #6c757d;
}

.dimension-info.success {
    color: #27ae60;
    font-weight: 600;
}

.dimension-info.error {
    color: #e74c3c;
    font-weight: 600;
}

.conversion-cm {
    font-size: 0.85em;
    color: #6c757d;
    font-style: italic;
    min-height: 18px;
    display: block;
}

/* ========================================
   Section poignées
   ======================================== */

.poignees-section {
    margin: 10px 0;
}

.poignees-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.poignee-option {
    cursor: pointer;
    position: relative;
}

.poignee-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.poignee-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-align: center;
}

.poignee-card:hover {
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
    transform: translateY(-2px);
}

.poignee-option input:checked+.poignee-card {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.05);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.poignee-option.selected .poignee-card {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.05);
}

.poignee-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 8px;
    border-radius: 4px;
}

.poignee-nom {
    font-size: 0.85em;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    display: block;
}

.poignee-prix {
    font-size: 0.9em;
    color: #27ae60;
    font-weight: 600;
}

/* Preview poignée */
.poignee-preview {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    max-width: 400px;
}

.poignee-preview img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* ========================================
   Affichage du prix
   ======================================== */

.price-display {
    background: linear-gradient(135deg, #7a1270 0%, #6f2985 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.price-detail {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.95em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.price-detail:last-of-type {
    border-bottom: none;
    margin-bottom: 10px;
}

.price-detail span:first-child {
    opacity: 0.9;
}

.price-detail span:last-child {
    font-weight: 600;
}

.price-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 0px solid rgba(255, 255, 255, 0.3);
    margin-top: 10px;
}

.price-total strong {
    font-size: 1em;
}

.calculated-price {
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.calculated-price.updated {
    animation: priceUpdate 0.3s ease;
}

@keyframes priceUpdate {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* ========================================
   Bouton Ajouter au panier
   ======================================== */

.single_add_to_cart_button {
    transition: all 0.3s ease;
}

.single_add_to_cart_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #adb5bd !important;
}

.single_add_to_cart_button:not(.disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Messages de notification
   ======================================== */

.cekonay-notice {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cekonay-notice.error {
    background: #fff5f5;
    border-left: 4px solid #e74c3c;
    color: #c0392b;
}

.cekonay-notice.info {
    background: #e3f2fd;
    border-left: 4px solid #3498db;
    color: #1976d2;
}

.cekonay-notice.success {
    background: #f1f8f4;
    border-left: 4px solid #27ae60;
    color: #1e7e34;
}

/* ========================================
   Responsive Design
   ======================================== */

@media screen and (max-width: 768px) {
    .cekonay-dimensions-wrapper {
        padding: 20px 15px;
        margin: 15px 0 20px;
    }

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

    .poignees-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .poignee-card {
        padding: 8px;
    }

    .poignee-card img {
        width: 60px;
        height: 60px;
    }

    .calculated-price {
        font-size: 1.4em;
    }

    .price-display {
        padding: 15px;
    }
}

@media screen and (max-width: 480px) {

    .cekonay-input,
    .cekonay-select {
        padding: 10px 12px;
        font-size: 0.95em;
    }

    .cekonay-dimensions-wrapper {
        padding: 15px 10px;
    }

    .poignees-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cekonay-dimensions-wrapper h3 {
        font-size: 1.1em;
    }
}

/* ========================================
   Compatibilité Divi
   ======================================== */

.et_pb_module .cekonay-dimensions-wrapper {
    max-width: 100%;
}

.et_pb_wc_add_to_cart .cekonay-dimensions-wrapper {
    margin-top: 0;
}

/* ========================================
   Accessibilité
   ======================================== */

.cekonay-input:focus-visible,
.cekonay-select:focus-visible {
    outline: 1px solid #e8c3ab;
    outline-offset: 2px;
}

.poignee-option:focus-within .poignee-card {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* ========================================
   Print styles
   ======================================== */

@media print {
    .cekonay-dimensions-wrapper {
        border: 1px solid #000;
        box-shadow: none;
    }

    .price-display {
        background: #f0f0f0;
        color: #000;
    }

    .single_add_to_cart_button,
    .poignee-preview {
        display: none;
    }

    .poignees-grid {
        break-inside: avoid;
    }
}

/* ========================================
   Performance
   ======================================== */

.calculated-price,
.single_add_to_cart_button,
.poignee-card {
    will-change: transform;
}

.cekonay-notice {
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Layout hauteur/largeur côte à côte */
.dimensions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Inputs numériques optimisés */
.cekonay-number {
    width: 100%;
    padding: 12px 40px 12px 15px;
    /* Espace à droite pour les flèches */
    font-size: 1.1em;
    font-weight: 500;
    text-align: left;
}

/* Flèches spinner à droite */
.cekonay-number::-webkit-inner-spin-button,
.cekonay-number::-webkit-outer-spin-button {
    opacity: 1;
    position: absolute;
    right: 5px;
    height: 100%;
}

/* Validation visuelle */
.cekonay-input.error {
    border-color: #e74c3c !important;
    background: #fff5f5 !important;
}

.cekonay-input.valid {
    border-color: #27ae60 !important;
    background: #f1f8f4 !important;
}

/* Conversion cm */
.conversion-cm {
    display: block;
    font-size: 0.9em;
    color: #766998;
    font-style: italic;
    min-height: 20px;
}

/* Preview poignée */
.poignee-preview-content {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

#poignee-image-container {
    flex-shrink: 0;
}

.poignee-info {
    flex: 1;
}

#poignee-preview {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Radio orientation */
input[name="cekonay_poignee_orientation"] {
    margin-right: 8px;
}

/* Responsive Mobile */
@media screen and (max-width: 768px) {
    .dimensions-row {
        grid-template-columns: 1fr 1fr;
        /* Garde côte à côte */
        gap: 10px;
    }

    .cekonay-number {
        font-size: 1em;
        padding: 10px 35px 10px 12px;
    }

    .poignee-preview-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

@media screen and (max-width: 480px) {
    .dimensions-row {
        gap: 8px;
    }
}

/* Alignement vertical radio buttons */
input[name="cekonay_poignee_orientation"] {
    margin-right: 8px;
    vertical-align: middle;
    position: relative;
    top: -1px;
    /* Ajustement fin si nécessaire */
}

/* Alternative avec flexbox (plus robuste) */
#orientation-choice label {
    display: flex !important;
    align-items: center;
    margin-bottom: 5px;
    cursor: pointer;
    gap: 8px;
}

#orientation-choice label input[type="radio"] {
    margin: 0;
    flex-shrink: 0;
}

.woocommerce .quantity input.qty {
    margin-top: 0px !important;
}

.cekonay-handle-alert {
    margin-top: 10px;
    padding: 12px;
    background: #edf4fb;
    border-left: 4px solid #c7bebd;
    border-radius: 4px;
    font-size: 0.9em;
    color: #a7182b;
    animation: slideIn 0.3s ease;
    line-height: 1.6;

}
/* ═══════════════════════════════════════════════════════════════════════════
   AJOUT CSS POUR LIGNE PRIX POIGNÉE
   ═══════════════════════════════════════════════════════════════════════════ */

/* Ligne prix poignée avec animation d'apparition */
.price-poignee-line {
    animation: slideInPoignee 0.3s ease;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

@keyframes slideInPoignee {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-top: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 50px;
        padding-top: 8px;
        padding-bottom: 8px;
        transform: translateY(0);
    }
}

/* Animation de disparition */
.price-poignee-line[style*="display: none"] {
    animation: slideOutPoignee 0.2s ease;
}

@keyframes slideOutPoignee {
    from {
        opacity: 1;
        max-height: 50px;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        transform: translateY(-10px);
    }
}

/* Mise en évidence de la valeur poignée */
.poignee-price-value {
    font-weight: 600;
    color: #ffd700; /* Or pour se distinguer */
}

/* Responsive - ajustement mobile */
@media screen and (max-width: 768px) {
    .price-poignee-line {
        font-size: 0.9em;
    }
}