/**
 * Cart Sidebar Styles
 * 
 * @package ABMart
 */

/* Cart Sidebar Container */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    z-index: 9999;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s ease, opacity 0.3s ease;
}

.cart-sidebar.active {
    visibility: visible;
    opacity: 1;
}

/* Overlay */
.cart-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-sidebar.active .cart-sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* Cart Sidebar Content - Slide Animation */
.cart-sidebar-content {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: #fff;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.cart-sidebar.active .cart-sidebar-content {
    transform: translateX(0);
}

/* Cart Header */
.cart-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.cart-sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cart-sidebar-icon {
    width: 1.5rem;
    height: 1.5rem;
    color: #333;
}

.cart-sidebar-title h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

.cart-sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.clear-cart-btn {
    background: none;
    border: none;
    color: #666;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
    font-family: inherit;
}

.clear-cart-btn:hover {
    color: #333;
    text-decoration: underline;
}

.clear-cart-btn:focus {
    outline: none;
    color: #333;
}

.cart-sidebar-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.2s;
}

.cart-sidebar-close:hover {
    color: #333;
}

.cart-sidebar-close .close-icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* Cart Body */
.cart-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.cart-empty p {
    margin: 0 0 1.5rem 0;
    color: #666;
    font-size: 1rem;
}

.cart-empty .btn-primary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--abmart-primary, #2563eb);
    color: var(--abmart-primary-text, #fff);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background 0.2s;
}

.cart-empty .btn-primary:hover {
    background: var(--abmart-primary-hover, #1d4ed8);
    color: var(--abmart-primary-text, #fff);
    text-decoration: none;
}

.cart-items-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Cart Item */
.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}

.cart-item-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #f9fafb;
}

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

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

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.cart-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

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

.cart-item-name a {
    color: #333;
    text-decoration: none;
}

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

.cart-item-remove {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    transition: color 0.2s;
    flex-shrink: 0;
}

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

.cart-item-remove .remove-icon {
    width: 1rem;
    height: 1rem;
}

.cart-item-price {
    font-size: 0.875rem;
    color: #666;
}

.cart-item-quantity-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.25rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    background: var(--abmart-primary, #2563eb);
    border-radius: 24px;
    padding: 2px 5px;
    gap: 0;
    position: relative;
    z-index: 5;
    cursor: pointer;
    height: 36px;
}


.cart-item-total {
    font-size: 1rem;
    color: #333;
}

/* Cart Footer */
.cart-sidebar-footer {
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.cart-subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.subtotal-label {
    font-size: 1rem;
    font-weight: 500;
    color: #333;
}

.subtotal-amount {
    font-size: 1.125rem;
    font-weight: 700;
    color: #333;
}

.cart-checkout-btn {
    display: block;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--abmart-primary, #2563eb);
    color: var(--abmart-primary-text, #fff) !important;
    text-align: center;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}

.cart-checkout-btn:hover {
    background: var(--abmart-primary-hover, #1d4ed8);
    text-decoration: none;
}

/* Responsive */
@media (max-width: 480px) {
    .cart-sidebar {
        max-width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }
    
    .cart-sidebar-content {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }
    
    .cart-sidebar-footer {
        /* Match mobile bottom navigation styling */
        position: sticky;
        bottom: 0;
        padding: 1rem 1.25rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        margin-bottom: 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        /* Ensure footer stays above browser UI like mobile nav */
        z-index: 10;
    }
    
    .cart-item {
        padding: 0.75rem;
    }
    
    .cart-item-image {
        width: 60px;
        height: 60px;
    }
    
    .cart-item-name {
        font-size: 12px;
    }
}

/* Floating Cart Button */
.floating-cart-btn {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--abmart-primary, #2563eb);
    border: none;
    color: var(--abmart-primary-text, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 9998;
    padding: 0;
}

.floating-cart-btn:hover {
    background: var(--abmart-primary-dark, #1e40af);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.floating-cart-btn:active {
    transform: translateY(0);
}

.floating-cart-icon {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.floating-cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: var(--abmart-primary-text, #fff);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid var(--abmart-primary-text, #fff);
    line-height: 1;
}

/* Hide floating cart button on mobile (since there's bottom nav) */
@media (max-width: 768px) {
    .floating-cart-btn {
        display: none;
    }
}

/* Adjust position on tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .floating-cart-btn {
        bottom: 80px;
        right: 20px;
    }
}

