/**
 * Frvoya Ajax Cart Styles - Horizontal Layout
 * Palette 2026 (Webstore Sécurité)
 * Primary: #034991
 * Navy:    #092546
 * Accent:  #298568
 */

/* Overlay */
.ajaxcart-overlay {
    /* Palette scoped (ne pollue pas le site) */
    --ws-primary: #034991;
    --ws-primary-hover: #092546;
    --ws-accent: #298568;
    --ws-accent-hover: #1f6f57;

    --ws-surface: #ffffff;
    --ws-bg: #f8fafc;
    --ws-border: #e6eaf0;

    --ws-text: #0f172a;
    --ws-muted: #64748b;

    --ws-danger: #e74c3c;

    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.70);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Modal Container */
.ajaxcart-modal {
    background: var(--ws-surface);
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 60px rgba(2, 6, 23, 0.35);
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.28s ease-in-out;
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.ajaxcart-modal.active {
    transform: scale(1);
    opacity: 1;
}

/* Close Button */
.ajaxcart-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #94a3b8;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transition: all 0.18s ease;
    z-index: 10;
}

.ajaxcart-close:hover {
    background: var(--ws-bg);
    color: var(--ws-text);
}

/* Modal Content */
.ajaxcart-content {
    padding: 28px;
}

/* Header - Icône et titre sur la même ligne */
.ajaxcart-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.ajaxcart-icon {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.45s ease-out;
    border: 1px solid rgba(15, 23, 42, 0.06);
}

/* Succès: accent (teal) cohérent */
.ajaxcart-icon.success {
    background: var(--ws-accent);
    color: #fff;
}

.ajaxcart-icon svg {
    width: 24px;
    height: 24px;
}

@keyframes scaleIn {
    0% {
        transform: scale(0.0);
        opacity: 0;
    }
    60% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.ajaxcart-title {
    flex: 1;
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    color: var(--ws-text);
}

/* Main - Produit et Résumé côte à côte */
.ajaxcart-main {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--ws-border);
}

.ajaxcart-product {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.ajaxcart-product-image {
    flex: 0 0 72px;
}

.ajaxcart-product-image img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--ws-border);
    background: var(--ws-bg);
}

.ajaxcart-product-details {
    flex: 1;
}

.ajaxcart-product-details h3 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ws-text);
    line-height: 1.35;
}

.ajaxcart-product-price {
    font-size: 16px;
    font-weight: 900;
    color: var(--ws-primary);
}

/* Cart Summary */
.ajaxcart-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--ws-bg);
    border-radius: 12px;
    min-width: 210px;
    border: 1px solid var(--ws-border);
}

.ajaxcart-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.ajaxcart-summary-item span {
    color: var(--ws-muted);
    font-size: 13px;
    font-weight: 600;
}

.ajaxcart-summary-item strong {
    color: var(--ws-text);
    font-size: 14px;
    font-weight: 900;
}

/* Action Buttons */
.ajaxcart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.ajaxcart-btn {
    padding: 12px 18px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.22s ease;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

/* Secondaire */
.ajaxcart-btn-continue {
    background: var(--ws-surface);
    border: 2px solid var(--ws-border);
    color: var(--ws-text);
}

.ajaxcart-btn-continue:hover {
    background: var(--ws-bg);
    border-color: #cbd5e1;
}

/* Voir le panier: Navy */
.ajaxcart-btn-cart {
    background: var(--ws-primary-hover);
    color: #fff;
}

.ajaxcart-btn-cart:hover {
    filter: brightness(1.06);
    color: #fff;
}

/* Commander: Primary blue */
.ajaxcart-btn-checkout {
    grid-column: 1 / -1;
    background: var(--ws-primary);
    color: #fff;
    box-shadow: 0 10px 24px rgba(3, 73, 145, 0.18);
}

.ajaxcart-btn-checkout:hover {
    background: var(--ws-primary-hover);
    color: #fff;
    box-shadow: 0 12px 28px rgba(9, 37, 70, 0.22);
}

/* Related Products Section */
.ajaxcart-related {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--ws-border);
}

.ajaxcart-related-title {
    font-size: 16px;
    font-weight: 900;
    margin: 0 0 14px;
    color: var(--ws-text);
    text-align: center;
}

/* Carousel Container */
.ajaxcart-related-carousel {
    position: relative;
}

.ajaxcart-related-container {
    overflow: hidden;
}

.ajaxcart-related-track {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Carousel Navigation Buttons - Hidden */
.ajaxcart-carousel-prev,
.ajaxcart-carousel-next {
    display: none;
}

/* Related Product Item - Optimized for 4 items */
.related-product-item {
    flex: 0 0 145px;
    width: 145px;
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.22s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.related-product-item:hover {
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.10);
    border-color: rgba(15, 23, 42, 0.12);
}

.related-product-link {
    display: flex;
    flex-direction: column;
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.related-product-image {
    width: 100%;
    height: 130px;
    overflow: hidden;
    background: var(--ws-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.related-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.22s ease;
}

.related-product-item:hover .related-product-image img {
    transform: scale(1.05);
}

.related-product-info {
    padding: 10px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.related-product-name {
    font-size: 12px;
    font-weight: 800;
    margin: 0 0 6px;
    color: var(--ws-text);
    line-height: 1.3;
    height: 31px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.related-product-price {
    font-size: 14px;
    font-weight: 900;
    color: var(--ws-primary);
    margin-top: auto;
}

.related-product-price .old-price {
    font-size: 12px;
    color: #94a3b8;
    text-decoration: line-through;
    margin-right: 5px;
    font-weight: 600;
    display: block;
}

.related-product-price .special-price {
    color: var(--ws-danger);
    display: block;
}

/* Add to Cart Button */
.related-product-addtocart {
    width: 100%;
    padding: 9px 10px;
    background: var(--ws-primary);
    color: #fff;
    border: none;
    border-radius: 0 0 12px 12px;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.22s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.related-product-addtocart:hover {
    background: var(--ws-primary-hover);
}

.related-product-addtocart svg {
    width: 13px;
    height: 13px;
}

/* Etat ajouté: accent (teal) */
.related-product-addtocart.added {
    background: var(--ws-accent);
}

.related-product-addtocart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.related-product-addtocart span {
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .ajaxcart-modal {
        max-width: 100%;
        margin: 20px;
    }

    .ajaxcart-content {
        padding: 22px 18px;
    }

    .ajaxcart-main {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .ajaxcart-summary {
        min-width: auto;
    }

    .ajaxcart-actions {
        grid-template-columns: 1fr;
    }

    .ajaxcart-btn-checkout {
        grid-column: auto;
    }

    .related-product-item {
        flex: 0 0 135px;
        width: 135px;
    }

    .related-product-image {
        height: 120px;
    }
}

@media (max-width: 480px) {
    .ajaxcart-header {
        gap: 10px;
    }

    .ajaxcart-icon {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
    }

    .ajaxcart-title {
        font-size: 16px;
    }

    .ajaxcart-product-image {
        flex: 0 0 60px;
    }

    .related-product-item {
        flex: 0 0 120px;
        width: 120px;
    }

    .related-product-image {
        height: 100px;
    }

    .related-product-name {
        font-size: 11px;
    }

    .related-product-price {
        font-size: 13px;
    }
}

/* Loading State */
button[disabled].tocart {
    opacity: 0.6;
    cursor: not-allowed;
}


/* =========================================================
   AjaxCart - Mobile fixes for related products carousel
   ========================================================= */
@media (max-width: 768px) {

  /* Make the related products area horizontally scrollable (swipe) */
  .ajaxcart-related-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    padding-bottom: 8px;
  }
  .ajaxcart-related-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }

  /* Force a horizontal track */
  .ajaxcart-related-track {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 0 12px 12px;
  }

  /* Cards: show ~1.3 item to hint swipe */
  .related-product-item {
    flex: 0 0 72%;
    max-width: 72%;
    scroll-snap-align: start;
    border-radius: 12px;
    overflow: hidden;
  }

  /* Improve image sizing */
  .related-product-image {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .related-product-image img {
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  /* Text sizing so it doesn’t look like a ransom note */
  .related-product-name {
    font-size: 13px;
    line-height: 1.2;
    min-height: 34px; /* keeps cards aligned */
  }
  .related-product-price {
    font-size: 13px;
    line-height: 1.2;
  }

  /* Button: no more cut text */
  .related-product-addtocart {
    width: 100%;
    padding: 10px 8px;
    font-size: 12px;
    line-height: 1.15;
    white-space: normal; /* allow wrap instead of cutting */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }
}

/* Very small phones: show bigger cards */
@media (max-width: 420px) {
  .related-product-item {
    flex-basis: 80%;
    max-width: 80%;
  }
}

