/* Chronocarpe Widget — Frontend Styles */

:root {
    --ccwp-primary:   #e84c3d;
    --ccwp-accent:    #2c3e50;
    --ccwp-green:     #27ae60;
    --ccwp-green-h:   #219a52;
    --ccwp-bg:        #f9f9f9;
    --ccwp-border:    #e5e5e5;
    --ccwp-radius:    8px;
    --ccwp-shadow:    0 2px 12px rgba(0,0,0,0.08);
}

.ccwp-widget {
    font-family: inherit;
    margin: 20px 0;
}

.ccwp-widget-title {
    font-size: 1.4em;
    color: var(--ccwp-accent);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--ccwp-primary);
}

/* ===== GRILLE ===== */
.ccwp-layout-grid .ccwp-products-grid {
    display: grid;
    gap: 20px;
}
.ccwp-layout-grid.ccwp-cols-1 .ccwp-products-grid { grid-template-columns: 1fr; }
.ccwp-layout-grid.ccwp-cols-2 .ccwp-products-grid { grid-template-columns: repeat(2, 1fr); }
.ccwp-layout-grid.ccwp-cols-3 .ccwp-products-grid { grid-template-columns: repeat(3, 1fr); }
.ccwp-layout-grid.ccwp-cols-4 .ccwp-products-grid { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .ccwp-layout-grid .ccwp-products-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 600px) {
    .ccwp-layout-grid .ccwp-products-grid { grid-template-columns: 1fr !important; }
}

/* ===== LISTE ===== */
.ccwp-layout-list .ccwp-products-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ccwp-layout-list .ccwp-product-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}
.ccwp-layout-list .ccwp-image-link {
    flex-shrink: 0;
    width: 100px;
}
.ccwp-layout-list .ccwp-product-image {
    width: 100px;
    height: 100px;
    aspect-ratio: auto;
}
.ccwp-layout-list .ccwp-product-image img {
    width: 100px;
    height: 100px;
}
.ccwp-layout-list .ccwp-product-info {
    flex: 1;
}

/* ===== CARROUSEL ===== */
.ccwp-layout-carousel .ccwp-products-grid {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
    scrollbar-width: thin;
}
.ccwp-layout-carousel .ccwp-product-card {
    flex: 0 0 240px;
    scroll-snap-align: start;
}

/* ===== CARROUSEL AUTOPLAY ===== */
.ccwp-autoplay-wrapper {
    overflow: hidden;
    width: 100%;
}

.ccwp-autoplay-track {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    width: max-content;
    animation: ccwp-scroll linear infinite;
    animation-duration: 25s; /* écrasé inline par PHP */
}

.ccwp-autoplay-track:hover {
    animation-play-state: paused;
}

@keyframes ccwp-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); } /* -50% car les cartes sont dupliquées */
}

.ccwp-autoplay .ccwp-product-card {
    flex: 0 0 240px;
    margin-right: 0;
}

/* ===== CARTE PRODUIT ===== */
.ccwp-product-card {
    background: #fff;
    border: 1px solid var(--ccwp-border);
    border-radius: var(--ccwp-radius);
    overflow: hidden;
    box-shadow: var(--ccwp-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}
.ccwp-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.13);
}
.ccwp-product-card.backorder {
    opacity: 0.88;
}

/* --- Lien image --- */
.ccwp-image-link {
    display: block;
    text-decoration: none;
}
.ccwp-product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--ccwp-bg);
}
.ccwp-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
    transition: transform 0.3s ease;
    display: block;
}
.ccwp-image-link:hover .ccwp-product-image img {
    transform: scale(1.05);
}

/* --- Infos produit --- */
.ccwp-product-info {
    padding: 12px 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.ccwp-product-brand {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ccwp-primary);
    font-weight: 700;
}
.ccwp-product-title {
    font-size: 0.88em;
    font-weight: 600;
    color: var(--ccwp-accent);
    line-height: 1.35;
    margin: 0;
    flex: 1;
    text-decoration: none;
}
.ccwp-product-desc {
    font-size: 0.8em;
    color: #777;
    line-height: 1.4;
    margin: 2px 0 0;
}

/* --- Prix --- */
.ccwp-product-price {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ccwp-price {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--ccwp-accent);
}
.ccwp-price-original {
    font-size: 0.88em;
    text-decoration: line-through;
    color: #aaa;
}
.ccwp-price-sale {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--ccwp-primary);
}

/* --- Bouton Acheter --- */
.ccwp-btn-buy {
    display: block;
    margin-top: 10px;
    padding: 9px 14px;
    background: var(--ccwp-green);
    color: #fff !important;
    text-align: center;
    text-decoration: none !important;
    font-size: 0.85em;
    font-weight: 700;
    border-radius: 5px;
    transition: background 0.2s ease, transform 0.15s ease;
    letter-spacing: 0.3px;
}
.ccwp-btn-buy:hover {
    background: var(--ccwp-green-h);
    transform: translateY(-1px);
    color: #fff !important;
}

/* ===== BADGES ===== */
/* Positionnés par rapport à .ccwp-product-card (position:relative) */
.ccwp-badge {
    position: absolute;
    top: 10px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.70em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    line-height: 1.4;
    pointer-events: none;
}

/* PROMO → haut droite */
.ccwp-badge-promo {
    right: 10px;
    background: var(--ccwp-primary);
    color: #fff;
}

/* SUR COMMANDE → haut gauche */
.ccwp-badge-backorder {
    left: 10px;
    background: #f39c12;
    color: #fff;
}

.ccwp-no-products {
    color: #777;
    font-style: italic;
}
