/**
 * Cart Panel Styles
 * Modern, responsive design with RTL support
 * Matches Zdesigner theme design system
 */

/* Overlay */
.cart-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cart-panel-overlay.show {
    opacity: 1;
}

/* Cart Panel Container */
.cart-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100%;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RTL Support */
[dir="rtl"] .cart-panel {
    right: auto;
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
}

.cart-panel.cart-panel-open {
    transform: translateX(0);
}

.cart-panel-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Prevent body scroll when cart is open */
body.cart-panel-active {
    overflow: hidden;
}

/* Header */
.cart-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.cart-panel-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1b180d;
    margin: 0;
}

.cart-panel-title .material-symbols-outlined {
    font-size: 1.5rem;
    color: #d4af37;
}

.cart-panel-count {
    font-size: 1rem;
    font-weight: 500;
    color: #6b7280;
}

.cart-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-panel-close:hover {
    background: #d4af37;
    color: white;
    transform: rotate(90deg);
}

/* Content */
.cart-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #fafafa;
}

/* Loading State */
.cart-panel-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.cart-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f4f6;
    border-top-color: #d4af37;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.cart-panel-loading p {
    margin-top: 1rem;
    color: #6b7280;
    font-size: 0.875rem;
}

/* Empty State */
.cart-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.cart-empty-icon {
    font-size: 4rem;
    color: #d1d5db;
    margin-bottom: 1rem;
}

.cart-panel-empty h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1b180d;
    margin-bottom: 0.5rem;
}

.cart-panel-empty p {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.cart-continue-shopping {
    padding: 0.75rem 1.5rem;
    background: #d4af37;
    color: #1b180d;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-continue-shopping:hover {
    background: #c19d2f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

/* Cart Items */
.cart-panel-items-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-panel-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    position: relative;
}

.cart-panel-item.removing {
    opacity: 0.5;
    pointer-events: none;
}

.cart-item-image {
    flex-shrink: 0;
    width: 96px;
    height: 128px;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.cart-item-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1b180d;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-variation {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 0.25rem;
    line-height: 1.3;
}

.cart-item-price {
    font-size: 1rem;
    font-weight: 700;
    color: #d4af37;
    margin-top: 0.375rem;
}

.cart-item-quantity,
.cart-item-quantity-fixed {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.cart-item-quantity {
    background: #f3f4f6;
    border-radius: 0.5rem;
    padding: 0.25rem;
    width: fit-content;
}

.cart-qty-minus,
.cart-qty-plus {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 600;
    color: #1b180d;
    transition: all 0.2s ease;
}

.cart-qty-minus:hover,
.cart-qty-plus:hover {
    background: #d4af37;
    color: white;
    border-color: #d4af37;
    transform: scale(1.05);
}

.cart-panel-qty-input {
    width: 3rem;
    height: 2rem;
    text-align: center;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    font-weight: 600;
    color: #1b180d;
    background: white;
}

.cart-panel-qty-input:focus {
    outline: none;
    border-color: #d4af37;
}

.cart-item-quantity-fixed {
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
    margin-top: 0.5rem;
}

.cart-item-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

[dir="rtl"] .cart-item-remove {
    right: auto;
    left: 0.5rem;
}

.cart-item-remove:hover {
    background: #fee2e2;
    color: #dc2626;
    transform: scale(1.1);
}

/* Footer */
.cart-panel-footer {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.cart-shipping-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #fef3c7;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #92400e;
}

.cart-shipping-notice .material-symbols-outlined {
    color: #d97706;
    font-size: 1.25rem;
}

.cart-panel-subtotal,
.cart-panel-shipping {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.cart-panel-subtotal {
    border-bottom: 1px solid #e5e7eb;
}

.subtotal-amount,
.shipping-amount {
    font-weight: 600;
    color: #1b180d;
}

.cart-panel-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-top: 2px solid #e5e7eb;
    margin-top: 0.5rem;
}

.total-label {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1b180d;
}

.total-amount {
    font-size: 1.5rem;
    font-weight: 900;
    color: #d4af37;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

/* Action Buttons */
.cart-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.cart-view-btn,
.cart-checkout-btn {
    display: block;
    width: 100%;
    padding: 0.875rem 1rem;
    text-align: center;
    font-weight: 600;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.cart-view-btn {
    background: white;
    border: 2px solid #e5e7eb;
    color: #1b180d;
}

.cart-view-btn:hover {
    border-color: #d4af37;
    background: #fef3c7;
}

.cart-checkout-btn {
    background: #d4af37;
    color: #1b180d;
    border: 2px solid #d4af37;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.cart-checkout-btn:hover {
    background: #c19d2f;
    border-color: #c19d2f;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(212, 175, 55, 0.4);
}

/* Trust Badges */
.cart-trust-badges {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.trust-badge {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
}

.trust-badge .material-symbols-outlined {
    font-size: 1.25rem;
    color: #d4af37;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .cart-panel {
        max-width: 100%;
        top: auto;
        bottom: 0;
        height: 85vh;
        border-radius: 1rem 1rem 0 0;
        transform: translateY(100%);
    }
    
    [dir="rtl"] .cart-panel {
        transform: translateY(100%);
    }
    
    .cart-panel.cart-panel-open {
        transform: translateY(0);
    }
    
    .cart-panel-header {
        padding: 1.25rem;
    }
    
    .cart-panel-content {
        padding: 1rem;
    }
    
    .cart-panel-footer {
        padding: 1.25rem;
    }
    
    .cart-item-quantity {
        width: 100%;
        justify-content: space-between;
    }
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Scrollbar Styling */
.cart-panel-content::-webkit-scrollbar {
    width: 6px;
}

.cart-panel-content::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.cart-panel-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.cart-panel-content::-webkit-scrollbar-thumb:hover {
    background: #d4af37;
}

/* ============================================
   CART SYNCHRONIZATION STYLES
   ============================================ */

/* Global loading state */
body.cart-updating {
    cursor: wait;
}

body.cart-updating * {
    pointer-events: none;
}

/* Loading overlay for cart updates */
body.cart-updating::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 99999;
    pointer-events: all;
}

/* Cart sync notifications */
.cart-sync-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100000;
    animation: slideInFromRight 0.3s ease-out;
    max-width: 350px;
    font-size: 14px;
    line-height: 1.5;
}

[dir="rtl"] .cart-sync-notification {
    right: auto;
    left: 20px;
    animation: slideInFromLeft 0.3s ease-out;
}

.cart-sync-notification.success {
    border-left: 4px solid #10b981;
    color: #065f46;
}

[dir="rtl"] .cart-sync-notification.success {
    border-left: none;
    border-right: 4px solid #10b981;
}

.cart-sync-notification.error {
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

[dir="rtl"] .cart-sync-notification.error {
    border-left: none;
    border-right: 4px solid #ef4444;
}

.cart-sync-notification.warning {
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

[dir="rtl"] .cart-sync-notification.warning {
    border-left: none;
    border-right: 4px solid #f59e0b;
}

/* Animations */
@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Item removing state */
.cart-panel-item.removing,
.cart-product-card.removing {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.cart-panel-item.removing::after,
.cart-product-card.removing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Updating spinner */
.cart-updating-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100001;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #d4af37;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
