/* ===================================
   Cart Sidebar Styles
   =================================== */

/* Sidebar Container */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 9000; /* Below SweetAlert notifications */
    pointer-events: none;
}

.cart-sidebar.active {
    pointer-events: auto;
}

/* Overlay */
.cart-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    backdrop-filter: none;
    z-index: 9000; /* Below SweetAlert notifications (99999) */
}

.cart-sidebar.active .cart-sidebar-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

/* Sidebar Content */
.cart-sidebar-content {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100%;
    background: #fff;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
    transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9001; /* Above overlay but below SweetAlert (99999) */
}

.cart-sidebar.active .cart-sidebar-content {
    right: 0;
}

/* LTR (English) Support */
body:not([dir="rtl"]) .cart-sidebar-content,
body[dir="ltr"] .cart-sidebar-content {
    right: auto;
    left: -450px;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

body:not([dir="rtl"]) .cart-sidebar.active .cart-sidebar-content,
body[dir="ltr"] .cart-sidebar.active .cart-sidebar-content {
    right: auto;
    left: 0;
}

/* Sidebar Header */
.cart-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
}

.cart-sidebar-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1a1a1a;
}

.cart-sidebar-title .icon {
    width: 24px;
    height: 24px;
}

.cart-sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: #1a1a1a;
}

.cart-sidebar-close:hover {
    transform: rotate(90deg);
}

.cart-sidebar-close svg {
    width: 24px;
    height: 24px;
}

/* Sidebar Items Container */
.cart-sidebar-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px 25px;
}

.cart-sidebar-items::-webkit-scrollbar {
    width: 6px;
}

.cart-sidebar-items::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.cart-sidebar-items::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.cart-sidebar-items::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Empty Cart State */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.cart-empty-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.cart-empty p {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1a1a1a;
}

.cart-empty span {
    font-size: 14px;
    color: #999;
}

/* Cart Item */
.cart-item {
    display: flex;
    gap: 15px;
    padding: 20px 0;
    border-bottom: 1px solid #e5e5e5;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* LTR Animation */
body:not([dir="rtl"]) .cart-item,
body[dir="ltr"] .cart-item {
    animation: slideInLTR 0.3s ease;
}

@keyframes slideInLTR {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cart-item-image {
    width: 100px;
    height: 130px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimizeQuality;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    filter: blur(0.3px) contrast(1.1) saturate(1.15) brightness(1.03) sharpen(0.5);
    transform: translateZ(0) scale(1.001);
    backface-visibility: hidden;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0) scale(1.001);
}

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item-brand {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    letter-spacing: 0.5px;
}

.cart-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.4;
    margin: 0;
}

.cart-item-size {
    font-size: 13px;
    color: #666;
}

.cart-item-price {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-top: auto;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
}

.cart-item-quantity button {
    background: #fff;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    color: #1a1a1a;
}

.cart-item-quantity button:hover {
    background: #f5f5f5;
}

.cart-item-quantity button:active {
    background: #e5e5e5;
}

.cart-item-quantity span {
    padding: 0 12px;
    font-size: 14px;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.cart-item-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    transition: color 0.2s ease;
    margin-right: auto;
}

.cart-item-remove:hover {
    color: #e74c3c;
}

.cart-item-remove svg {
    width: 18px;
    height: 18px;
}

/* Sidebar Footer */
.cart-sidebar-footer {
    padding: 20px 25px;
    border-top: 1px solid #e5e5e5;
    background: #fff;
    display: none; /* Hidden by default */
}

.cart-sidebar-footer.show {
    display: block;
}

.cart-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 16px;
}

.cart-subtotal-amount {
    font-weight: 700;
    font-size: 20px;
    color: #1a1a1a;
}

.cart-shipping-note {
    font-size: 12px;
    color: #999;
    margin: 0 0 20px 0;
    text-align: center;
}

.cart-checkout-btn,
.cart-view-btn {
    display: block;
    width: 100%;
    padding: 16px;
    text-align: center;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.cart-checkout-btn {
    background: #1a1a1a;
    color: #fff;
    border: 2px solid #1a1a1a;
    margin-bottom: 12px;
}

.cart-checkout-btn:hover {
    background: #000;
    border-color: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cart-view-btn {
    background: #fff;
    color: #1a1a1a;
    border: 2px solid #1a1a1a;
}

.cart-view-btn:hover {
    background: #f5f5f5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cart-sidebar-content {
        width: 100%;
        right: -100%;
    }

    .cart-sidebar.active .cart-sidebar-content {
        right: 0;
    }

    /* LTR Mobile */
    body:not([dir="rtl"]) .cart-sidebar-content,
    body[dir="ltr"] .cart-sidebar-content {
        right: auto;
        left: -100%;
    }

    body:not([dir="rtl"]) .cart-sidebar.active .cart-sidebar-content,
    body[dir="ltr"] .cart-sidebar.active .cart-sidebar-content {
        right: auto;
        left: 0;
    }
}

@media (max-width: 480px) {
    .cart-sidebar-header {
        padding: 15px 20px;
    }

    .cart-sidebar-title {
        font-size: 18px;
    }

    .cart-sidebar-items {
        padding: 15px 20px;
    }

    .cart-item-image {
        width: 80px;
        height: 110px;
    }

    .cart-sidebar-footer {
        padding: 15px 20px;
    }
}

/* ===================================
   FORCE SweetAlert Above Cart Sidebar
   =================================== */
.swal2-container {
    z-index: 99999 !important; /* FORCE above everything including cart sidebar */
}

/* Ensure toast notifications are also above */
.swal2-container.swal2-top-start,
.swal2-container.swal2-top-end,
.swal2-container.swal2-top {
    z-index: 99999 !important;
}

/* ===================================
   Cart Sidebar Skeleton Loading
   =================================== */
.cart-item-skeleton {
    opacity: 0.7;
    pointer-events: none;
}

.skeleton-image {
    width: 100px;
    height: 130px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 14px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-brand {
    width: 60%;
    height: 12px;
}

.skeleton-name {
    width: 90%;
    height: 16px;
}

.skeleton-size {
    width: 50%;
    height: 12px;
}

.skeleton-price {
    width: 40%;
    height: 14px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
