/**
 * UFK Cart Styles
 * Styles pour le panier, checkout et badges produits
 */

/* ============================================================================
   PANIER (Cart)
   ============================================================================ */

.cart-currency-selector {
    background: var(--color-gray-100, #f8f9fa);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.currency-form {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.currency-form label {
    font-weight: 600;
    margin: 0;
}

.currency-form select {
    flex: 1;
    max-width: 300px;
    padding: 0.5rem;
    border: 1px solid var(--color-gray-300, #dee2e6);
    border-radius: 4px;
    font-size: 1rem;
}

.currency-selector-top {
    background: var(--color-gray-100, #f8f9fa);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.cart-items {
    margin-bottom: 2rem;
}

.cart-item {
    display: grid;
    grid-template-columns: 100px 1fr auto auto auto;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--color-white, #fff);
    border: 1px solid var(--color-gray-200, #e9ecef);
    border-radius: 8px;
    margin-bottom: 1rem;
    align-items: center;
}

@media (max-width: 768px) {
    .cart-item {
        grid-template-columns: 80px 1fr;
        gap: 1rem;
    }
    
    .cart-item-quantity,
    .cart-item-price,
    .cart-item-actions {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

.cart-item-image {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-gray-100, #f8f9fa);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

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

.cart-item-info h3 {
    font-size: 1.2rem;
    margin: 0 0 0.5rem 0;
}

.cart-item-info h3 a {
    color: var(--color-primary, #007bff);
    text-decoration: none;
}

.cart-item-info h3 a:hover {
    text-decoration: underline;
}

.cart-item-meta {
    margin: 0.5rem 0;
}

.cart-item-description {
    color: var(--color-gray-600, #6c757d);
    font-size: 0.9rem;
    margin: 0.5rem 0 0 0;
}

.cart-item-quantity label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--color-gray-600, #6c757d);
}

.quantity-input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--color-gray-300, #dee2e6);
    border-radius: 4px;
    text-align: center;
    font-size: 1rem;
}

.cart-item-price {
    text-align: right;
}

.unit-price {
    font-size: 0.9rem;
    color: var(--color-gray-600, #6c757d);
    margin-bottom: 0.25rem;
}

.subtotal {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-primary, #007bff);
}

.cart-item-actions {
    display: flex;
    align-items: center;
}

.cart-summary {
    background: var(--color-gray-50, #f8f9fa);
    padding: 2rem;
    border-radius: 8px;
    position: sticky;
    top: 1rem;
}

.cart-summary h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.cart-summary-line {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-gray-200, #e9ecef);
}

.cart-summary-line.total {
    border-bottom: none;
    border-top: 2px solid var(--color-gray-300, #dee2e6);
    padding-top: 1rem;
    margin-top: 0.5rem;
    font-size: 1.2rem;
}

.total-amount {
    color: var(--color-primary, #007bff);
    font-size: 1.5rem;
}

.cart-summary-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-clear-cart {
    margin-top: 1rem;
    width: 100%;
}

.empty-cart {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-cart-actions {
    margin-top: 2rem;
}

/* ============================================================================
   CHECKOUT
   ============================================================================ */

.checkout-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 992px) {
    .checkout-container {
        grid-template-columns: 1fr;
    }
}

.checkout-summary,
.checkout-payment {
    background: var(--color-white, #fff);
    padding: 2rem;
    border: 1px solid var(--color-gray-200, #e9ecef);
    border-radius: 8px;
}

.checkout-summary h2,
.checkout-payment h2 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkout-items {
    margin-bottom: 1.5rem;
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-gray-100, #f8f9fa);
}

.checkout-item:last-child {
    border-bottom: none;
}

.checkout-item-info h4 {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
}

.checkout-item-price {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.checkout-item-price .quantity {
    font-size: 0.9rem;
    color: var(--color-gray-600, #6c757d);
}

.checkout-total {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 2px solid var(--color-gray-300, #dee2e6);
    font-size: 1.3rem;
    font-weight: 600;
}

.checkout-form {
    margin-top: 1.5rem;
}

.customer-info {
    background: var(--color-gray-50, #f8f9fa);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.payment-info {
    background: var(--color-info-light, #d1ecf1);
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid var(--color-info, #17a2b8);
    margin: 1.5rem 0;
}

.payment-info p {
    margin: 0.5rem 0;
}

.checkout-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

@media (max-width: 576px) {
    .checkout-actions {
        flex-direction: column;
    }
}

/* ============================================================================
   BADGES PRODUITS
   ============================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 4px;
    margin-right: 0.5rem;
}

.badge-type {
    background: var(--color-primary-light, #cfe2ff);
    color: var(--color-primary, #007bff);
}

.badge-subscription {
    background: var(--color-success-light, #d1e7dd);
    color: var(--color-success, #28a745);
}

.badge-consumable {
    background: var(--color-warning-light, #fff3cd);
    color: var(--color-warning, #ffc107);
}

.product-badges {
    margin: 0.5rem 0;
}

.subscription-interval {
    font-size: 0.9rem;
    color: var(--color-gray-600, #6c757d);
    margin-left: 0.25rem;
}

/* ============================================================================
   PAYMENT SUCCESS/CANCEL
   ============================================================================ */

.payment-success,
.payment-cancel {
    text-align: center;
    max-width: 600px;
    margin: 3rem auto;
    padding: 2rem;
}

.success-icon,
.cancel-icon {
    margin-bottom: 2rem;
}

.success-icon svg,
.cancel-icon svg {
    width: 80px;
    height: 80px;
}

.success-title {
    color: var(--color-success, #28a745);
    margin-bottom: 1rem;
}

.cancel-title {
    color: var(--color-warning, #ffc107);
    margin-bottom: 1rem;
}

.order-info {
    background: var(--color-gray-100, #f8f9fa);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
    text-align: left;
}

.success-actions,
.cancel-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* ============================================================================
   CART BADGE (Header)
   ============================================================================ */

.cart-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    overflow: visible !important; /* Permet au badge de déborder */
}

/* S'assurer que le bouton ghost permet aussi le débordement */
.btn-ghost.cart-badge {
    overflow: visible !important;
}

.cart-badge-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--color-primary, #007bff);
    color: white;
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0 3px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 100; /* Augmenté pour être sûr qu'il est au-dessus */
    border: 1px solid var(--color-white, #fff); /* Bordure blanche pour se détacher */
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

.cart-item-added {
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

