/**
 * Cart Page Styles
 * سلة التسوق - أنماط CSS
 */

/* ===== CRITICAL: Prevent Wizard Flash ===== */
/* Hide wizard until initialized to prevent FOUC */
.checkout-tab-steps {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out;
}
.checkout-tab-steps.wizard-initialized {
    opacity: 1;
    visibility: visible;
}

/* Pre-style wizard structure before JS loads */
.checkout-tab-steps > fieldset {
    display: none;
}
.checkout-tab-steps > fieldset:first-of-type {
    display: block;
}
.checkout-tab-steps > h6 {
    display: none;
}

/* Show loading skeleton while wizard loads */
.wizard-loading-placeholder {
    min-height: 400px;
    background: #f8f8f8;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}
.wizard-loading-placeholder .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #7367f0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Card styles */
.checkout-items .ecommerce-card {
    margin-bottom: 1rem;
}
.checkout-items .item-img {
    position: relative;
}
.checkout-items .item-img img {
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
}
.checkout-options .card {
    position: sticky;
    top: 100px;
}

/* Discount Badge */
.discount-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    font-size: 0.75rem;
    padding: 4px 8px;
}

/* Stock Status Badge */
.stock-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}
.stock-badge.in-stock {
    background: rgba(40, 199, 111, 0.12);
    color: #28c76f;
}
.stock-badge.out-of-stock {
    background: rgba(234, 84, 85, 0.12);
    color: #ea5455;
}

/* Brand and Stock Row */
.brand-stock-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 5px;
}

/* Variant badges */
.variant-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: #f3f2f7;
    border-radius: 5px;
    font-size: 0.85rem;
    margin-top: 5px;
    margin-left: 5px;
    color: #5e5873;
}
.variant-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid #ddd;
}

/* Item Description */
.item-description {
    font-size: 0.85rem;
    color: #6e6b7b;
    line-height: 1.5;
    margin-top: 8px;
    margin-bottom: 8px;
}

/* Quantity Wrapper */
.quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}
.quantity-wrapper .quantity-title {
    font-weight: 600;
    color: #5e5873;
    margin: 0;
    min-width: 50px;
}
.quantity-btn-group {
    display: flex;
    align-items: center;
    border: 1px solid #d8d6de;
    border-radius: 5px;
    overflow: hidden;
}
.quantity-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f8f8f8;
    color: #7367f0;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.quantity-btn:hover {
    background: #7367f0;
    color: #fff;
}
.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.quantity-input {
    width: 50px;
    height: 36px;
    border: none;
    border-left: 1px solid #d8d6de;
    border-right: 1px solid #d8d6de;
    text-align: center;
    font-weight: 600;
    color: #5e5873;
    background: #fff;
}
.quantity-input:focus {
    outline: none;
}

/* Price Section */
.price-section {
    padding-bottom: 15px;
    border-bottom: 1px solid #ebe9f1;
    margin-bottom: 15px;
}
.item-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: #7367f0;
    margin-bottom: 5px;
}
.original-price {
    font-size: 0.9rem;
    color: #b9b9c3;
    margin-bottom: 5px;
}
.shipping-info {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(40, 199, 111, 0.1);
    color: #28c76f;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}
.shipping-info.paid {
    background: rgba(255, 159, 67, 0.1);
    color: #ff9f43;
}

/* Action Buttons */
.item-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none !important;
    border: 2px solid transparent;
    width: 100%;
}
.btn-remove {
    background: #fff;
    color: #ea5455;
    border-color: #ea5455;
}
.btn-remove:hover {
    background: #ea5455;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(234, 84, 85, 0.35);
}
.btn-view {
    background: #7367f0;
    color: #fff;
    border-color: #7367f0;
}
.btn-view:hover {
    background: #5e50ee;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(115, 103, 240, 0.35);
}

/* Empty cart */
.empty-cart-section {
    text-align: center;
    padding: 60px 20px;
}
.empty-cart-section i {
    font-size: 80px;
    color: #ddd;
    margin-bottom: 20px;
}

/* Price styles in summary */
.discount-amt {
    color: #28c76f !important;
}
.total-amt {
    font-weight: bold;
    color: #7367f0;
}

/* Offers */
.offers-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(40, 199, 111, 0.12);
    color: #28c76f;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 5px;
}

/* Coupon section */
.coupons .coupon-form .input-group {
    border-radius: 5px;
    overflow: hidden;
}
.applied-coupon {
    border-radius: 5px;
}

/* Options title */
.options-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #5e5873;
}

/* Price details */
.price-details p {
    font-weight: 600;
    color: #5e5873;
}

/* Free Shipping Progress */
.free-shipping-progress {
    padding: 12px;
    background: linear-gradient(135deg, #f8f7fc 0%, #f3f2f7 100%);
    border-radius: 8px;
    border: 1px solid #ebe9f1;
}
.free-shipping-progress .progress {
    background: #e9e7f6;
    border-radius: 10px;
    overflow: hidden;
}
.free-shipping-progress .progress-bar {
    background: linear-gradient(118deg, #7367f0, #9f94ff);
    border-radius: 10px;
    transition: width 0.3s ease;
    /* إيقاف الـ animation */
    animation: none !important;
}
.free-shipping-achieved .alert-success {
    background: rgba(40, 199, 111, 0.12);
    border: none;
    border-radius: 8px;
}
.free-shipping-achieved .alert-success i {
    color: #28c76f;
}

/* Shipping Info Badge - Free */
.shipping-info.free {
    background: rgba(40, 199, 111, 0.15);
    color: #28c76f;
    font-weight: 600;
}
.shipping-info.free i {
    color: #28c76f;
}

/* Badge styling for free shipping */
.badge.badge-success {
    background: #28c76f !important;
    color: #fff;
    font-weight: 600;
    padding: 5px 12px;
}

/* ================================
   Address Step Styles
   ================================ */
#checkout-address .card {
    margin-bottom: 1.5rem;
}
#checkout-address .form-group label {
    font-weight: 600;
    color: #5e5873;
    margin-bottom: 0.5rem;
}
.saved-addresses .customer-card {
    border: 2px solid #ebe9f1;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}
.saved-addresses .customer-card:hover {
    border-color: #7367f0;
    box-shadow: 0 4px 15px rgba(115, 103, 240, 0.15);
}
.saved-addresses .customer-card.border-primary {
    border-color: #7367f0 !important;
    background: rgba(115, 103, 240, 0.05);
}

/* ================================
   Payment Step Styles
   ================================ */
.payment-options li {
    padding: 15px;
    border: 1px solid #ebe9f1;
    border-radius: 10px;
    transition: all 0.3s ease;
}
.payment-options li:hover {
    border-color: #7367f0;
    background: rgba(115, 103, 240, 0.03);
}
.payment-options .custom-control-input:checked ~ .custom-control-label {
    font-weight: 600;
}
.payment-options .payment-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-details, .bank-details {
    padding: 15px;
    background: #f8f8f8;
    border-radius: 8px;
}
.card-details input {
    background: #fff;
}
.bank-details .alert {
    margin-bottom: 0;
    background: #fff;
    border: 1px solid #ebe9f1;
}
.order-summary-payment {
    padding: 15px;
    background: #f8f7fc;
    border-radius: 8px;
    margin-top: 1rem;
}

/* ================================
   Wizard Steps Enhancements
   ================================ */
.checkout-tab-steps .actions {
    margin-top: 1.5rem;
}
.checkout-tab-steps .actions a[href="#next"],
.checkout-tab-steps .actions a[href="#finish"] {
    background: linear-gradient(118deg, #7367f0, #9f94ff);
    color: #fff;
    padding: 10px 25px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}
.checkout-tab-steps .actions a[href="#next"]:hover,
.checkout-tab-steps .actions a[href="#finish"]:hover {
    box-shadow: 0 4px 15px rgba(115, 103, 240, 0.35);
    transform: translateY(-2px);
}
.checkout-tab-steps .actions a[href="#previous"] {
    background: #f8f8f8;
    color: #5e5873;
    padding: 10px 25px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}
.checkout-tab-steps .actions a[href="#previous"]:hover {
    background: #ebe9f1;
}

/* ================================
   Saved Address Card Styles
   ================================ */
.address-card {
    background: #fff;
    border: 2px solid #ebe9f1;
    border-radius: 10px;
    padding: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    margin-bottom: 1rem;
}
.address-card:hover {
    border-color: #7367f0;
    box-shadow: 0 4px 15px rgba(115, 103, 240, 0.15);
}
.address-card.selected {
    border-color: #7367f0;
    background: rgba(115, 103, 240, 0.05);
}
.address-card .address-title {
    font-weight: 600;
    font-size: 1rem;
    color: #5e5873;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.address-card .address-title i {
    color: #7367f0;
}
.address-card .default-badge {
    background: #28c76f;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.address-card .receiver-info {
    font-size: 0.9rem;
    color: #6e6b7b;
    margin-bottom: 5px;
}
.address-card .receiver-info i {
    width: 18px;
    color: #7367f0;
}
.address-card .address-text {
    font-size: 0.85rem;
    color: #82868b;
    line-height: 1.6;
}
.address-card .select-address-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}
.address-card:hover .select-address-btn {
    opacity: 1;
}
.address-card.selected .select-address-btn {
    opacity: 1;
    background: #7367f0;
    border-color: #7367f0;
}
.address-card .selected-check {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #7367f0;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
}
.address-card.selected .selected-check {
    display: flex;
}

/* Loading skeleton for addresses */
.address-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 10px;
    height: 120px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Coupon Styles ===== */
/* Loading state for quantity buttons */
.quantity-btn-group.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}
.quantity-btn-group.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid #7367f0;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.quantity-btn-group.pending::before {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #ffc107;
    border-radius: 50%;
    z-index: 10;
}

/* Coupon discount styles */
.discount-amt {
    color: #28a745 !important;
    font-weight: 600;
}
.coupon-discount-row {
    background: rgba(40, 167, 69, 0.05);
    padding: 0.5rem;
    border-radius: 8px;
    margin-top: 0.5rem;
}
.coupon-discount-row .detail-title {
    color: #28a745;
}

/* Applied Coupon Wrapper - الزر خارج الكارد */
.applied-coupon-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}
.applied-coupon-wrapper .applied-coupon-card {
    flex: 1;
}
.applied-coupon-wrapper .remove-coupon-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    font-size: 14px;
}
.applied-coupon-wrapper .remove-coupon-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Applied Coupon Card */
.applied-coupon-card {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #28a745;
    border-radius: 12px;
    padding: 10px 12px;
}
.coupon-success-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: #155724;
    font-weight: 700;
    font-size: 13px;
}
.coupon-success-header i {
    font-size: 16px;
    color: #28a745;
}
.coupon-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.coupon-code-display {
    display: flex;
    align-items: center;
    gap: 6px;
}
.coupon-code-display .code-label {
    color: #155724;
    font-size: 12px;
}
.coupon-code-display .code-value {
    background: #fff;
    color: #155724;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    border: 1px dashed #28a745;
    letter-spacing: 1px;
}
.coupon-discount-display {
    display: flex;
    align-items: center;
    gap: 8px;
}
.coupon-discount-display .discount-badge {
    background: #28a745;
    color: #fff;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.coupon-discount-display .discount-value {
    color: #155724;
    font-weight: 700;
    font-size: 15px;
}
.bg-light-success {
    background: rgba(40, 167, 69, 0.1) !important;
}

/* No shipping zone message */
.no-shipping-zone {
    text-align: center;
    padding: 2rem;
    background: #fff8e1;
    border-radius: 12px;
    border: 1px dashed #ffc107;
}
.no-shipping-zone i {
    font-size: 3rem;
    color: #f57c00;
    margin-bottom: 1rem;
    display: block;
}
.no-shipping-zone h5 {
    color: #e65100;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.no-shipping-zone p {
    color: #f57c00;
    margin-bottom: 0;
}

/* Responsive */
@media (max-width: 991px) {
    .checkout-options .card {
        position: relative;
        top: auto;
    }
    .payment-options .payment-icon {
        width: 40px;
        height: 40px;
    }
    .saved-addresses .customer-card {
        margin-bottom: 1rem;
    }
    .address-card .select-address-btn {
        opacity: 1;
    }
}
