/* Shopping Cart Sidebar CSS */

/* Body adjustments for collapsible sidebar */
body.cart-sidebar-open {
    overflow-x: visible !important; /* Allow horizontal scrolling when sidebar is open */
}

/* Hide mobile menu when cart sidebar is open */
body.cart-sidebar-open .offcanvas {
    visibility: hidden !important;
}

/* Hide cart hover dropdown when cart sidebar is open */
body.cart-sidebar-open .cart-box-wrapper,
body.cart-sidebar-open .apt_cart_box {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Main wrapper adjustments for collapsible sidebar */
.main-wrapper {
    transition: margin-right 0.3s ease-in-out !important;
}

.main-wrapper.cart-sidebar-open {
    margin-right: 400px !important; /* Make space for sidebar */
    overflow-x: visible !important; /* Allow content to be pushed */
    max-width: none !important; /* Remove max-width restrictions */
}

/* Cart Sidebar Container - Real collapsible sidebar */
.cart-sidebar {
    position: fixed;
    top: var(--header-height, 120px); /* Start below the header */
    right: -400px; /* Hidden by default */
    width: 400px;
    height: calc(100vh - var(--header-height, 120px)); /* Height minus header */
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 999; /* Lower than header */
    transition: right 0.3s ease-in-out;
    overflow-y: auto;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

/* Show the sidebar */
.cart-sidebar.show {
    right: 0;
}

/* Cart Sidebar Header */
.cart-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.cart-sidebar-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 10px 0;
    color: #333;
    padding-right: 40px; /* Space for close button */
}

.cart-date {
    font-weight: 400;
    color: #666;
    font-size: 14px;
}

.cart-header-info {
    margin-bottom: 15px;
}

.cart-items-count {
    font-size: 14px;
    color: #666;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
}

.cart-header-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.cart-control-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.cart-control-btn:hover {
    background: #f8f9fa;
    border-color: #006633;
    color: #006633;
}

.cart-control-btn i {
    font-size: 11px;
}

.cart-search-box {
    margin-top: 10px;
    position: relative;
}

.cart-search-input {
    width: 100%;
    padding: 8px 30px 8px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    outline: none;
}

.cart-search-input:focus {
    border-color: #006633;
    box-shadow: 0 0 0 2px rgba(0, 102, 51, 0.1);
}

.cart-search-close {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    padding: 2px;
}

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

.cart-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

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

/* Cart Sidebar Content */
.cart-sidebar-content {
    padding: 20px;
    flex: 1;
}

/* Add Item Section */
.cart-add-item-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.cart-add-item-btn {
    width: 100%;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 6px;
    padding: 10px 15px;
    color: #666;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    min-height: auto;
    height: auto;
}

.cart-add-item-btn:hover {
    background: #e9ecef;
    border-color: #006633;
    color: #006633;
}

.cart-add-item-btn i {
    font-size: 16px;
}

/* Cart Items List */
.cart-sidebar-items {
    margin-bottom: 20px;
}

.cart-sidebar-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.cart-item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    margin-right: 15px;
    flex-shrink: 0;
}

.cart-item-details {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price {
    font-size: 14px;
    color: #006633;
    font-weight: 600;
    margin-bottom: 5px;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 25px;
    height: 25px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: #666;
}

.qty-btn:hover {
    background: #f5f5f5;
    border-color: #006633;
    color: #006633;
}

.qty-input {
    width: 40px;
    height: 25px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

.cart-item-remove {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.cart-item-remove:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* Cart Summary */
.cart-sidebar-summary {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
    margin-top: 15px;
}

.cart-summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
}

.cart-summary-row.total {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    border-top: 1px solid #e0e0e0;
    padding-top: 10px;
    margin-top: 15px;
}

.cart-summary-price {
    color: #006633;
    font-weight: 600;
}

/* Cart Actions */
.cart-sidebar-actions {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    position: sticky;
    bottom: 0;
}

.cart-action-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.cart-action-btn.primary {
    background: #006633;
    color: white;
}

.cart-action-btn.primary:hover {
    background: #004d26;
}

.cart-action-btn.secondary {
    background: white;
    color: #006633;
    border: 1px solid #006633;
}

.cart-action-btn.secondary:hover {
    background: #006633;
    color: white;
}

/* Empty Cart State */
.cart-sidebar-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.cart-sidebar-empty img {
    max-width: 120px;
    margin-bottom: 20px;
    opacity: 0.7;
}

.cart-sidebar-empty h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
}

.cart-sidebar-empty p {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

/* Cart Overlay - Removed for collapsible sidebar */
/* No overlay needed for real collapsible sidebar */

/* Mobile Responsive */
@media (max-width: 768px) {
    /* On mobile, use overlay style instead of pushing content */
    .main-wrapper.cart-sidebar-open {
        margin-right: 0 !important; /* Don't push content on mobile */
    }

    .cart-sidebar {
        width: 320px; /* Smaller width on mobile */
        right: -320px;
        top: var(--header-height, 120px); /* Ensure mobile also starts below header */
        height: calc(100vh - var(--header-height, 120px)); /* Height minus header on mobile */
        z-index: 1000; /* Lower z-index than mobile menu (1080) */
    }

    .cart-sidebar.show {
        right: 0;
    }

    .cart-sidebar-header {
        padding: 15px;
    }

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

    .cart-date {
        font-size: 12px;
    }

    .cart-header-controls {
        flex-direction: column;
        gap: 8px;
    }

    .cart-control-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .cart-add-item-btn {
        padding: 8px 12px;
        font-size: 12px;
        gap: 5px;
    }

    .cart-sidebar-content {
        padding: 15px;
    }

    .cart-sidebar-actions {
        padding: 12px 15px;
    }

    .cart-item-image {
        width: 50px;
        height: 50px;
        margin-right: 10px;
    }

    .cart-item-name {
        font-size: 13px;
    }

    .cart-item-price {
        font-size: 13px;
    }

    /* Mobile responsive for confirmation modal */
    .cart-confirmation-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    .cart-confirmation-header {
        padding: 20px 20px 15px;
    }

    .cart-confirmation-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
        margin-bottom: 10px;
    }

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

    .cart-confirmation-body {
        padding: 15px 20px;
    }

    .cart-confirmation-message {
        font-size: 14px;
    }

    .cart-confirmation-footer {
        padding: 15px 20px 20px;
        flex-direction: column;
    }

    .cart-confirmation-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* Confirmation Modal Styles */
.cart-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.cart-confirmation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cart-confirmation-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 100%;
    animation: slideIn 0.3s ease;
    overflow: hidden;
}

.cart-confirmation-header {
    text-align: center;
    padding: 30px 30px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.cart-confirmation-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 24px;
}

.cart-confirmation-icon-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.cart-confirmation-icon-error {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.cart-confirmation-icon-success {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.cart-confirmation-icon-info {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

.cart-confirmation-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.cart-confirmation-body {
    padding: 20px 30px;
}

.cart-confirmation-message {
    font-size: 16px;
    color: #666;
    line-height: 1.5;
    margin: 0;
    text-align: center;
}

.cart-confirmation-footer {
    padding: 20px 30px 30px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.cart-confirmation-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

.cart-confirmation-btn-cancel {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
}

.cart-confirmation-btn-cancel:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.cart-confirmation-btn-confirm {
    background: #dc3545;
    color: white;
}

.cart-confirmation-btn-confirm:hover {
    background: #c82333;
}

/* Animation for cart icon when item added */
.cart-icon-bounce {
    animation: cartBounce 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cartBounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(-5px);
    }
}

/* Cart counter animation */
.cart-counter-animate {
    animation: counterPulse 0.5s ease;
}

@keyframes counterPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}
