/* Cart Styles for Assemblinators */

/* --- Cart Icon in Navigation --- */
.cart-icon-wrapper {
    position: relative;
    display: inline-flex;
}

#cart-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--brand-green-dark);
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

#cart-icon-btn:hover {
    background-color: rgba(127, 168, 122, 0.1);
}

#cart-icon-btn svg {
    width: 24px;
    height: 24px;
}

#cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--brand-orange, #e07a5f);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* Header cart button badge */
.site-header__cart {
    position: relative;
}

.site-header__cart #cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
}

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

#cart-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* --- Cart Drawer --- */
#cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100%;
    background: #fff;
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
}

#cart-drawer.open {
    transform: translateX(0);
}

/* --- Cart Header --- */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.cart-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--brand-green-dark, #5a7d5a);
    font-weight: 700;
}

#cart-close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

#cart-close-btn:hover {
    color: var(--brand-orange, #e07a5f);
}

/* --- Cart Empty State --- */
#cart-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.cart-empty-icon {
    width: 80px;
    height: 80px;
    color: #ccc;
    margin-bottom: 1rem;
}

#cart-empty h3 {
    margin: 0 0 0.5rem;
    color: var(--brand-text, #333);
    font-size: 1.2rem;
}

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

/* --- Cart Content --- */
#cart-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* --- Cart Items List --- */
#cart-items {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
}

.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: #fafafa;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    position: relative;
}

.cart-item:last-child {
    margin-bottom: 0;
}

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

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

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

.cart-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--brand-text, #333);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-right: 1.5rem;
}

.cart-item-price {
    font-weight: 700;
    color: var(--brand-green-dark, #5a7d5a);
    font-size: 0.95rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    border-color: var(--brand-green-light, #8FBC8F);
    background: rgba(127, 168, 122, 0.1);
}

.qty-value {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.cart-item-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #999;
    transition: color 0.2s ease;
}

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

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

/* --- Cart Footer --- */
.cart-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.cart-subtotal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.cart-subtotal-label {
    font-size: 1rem;
    color: #666;
}

#cart-subtotal {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-green-dark, #5a7d5a);
}

#cart-checkout-btn {
    width: 100%;
    padding: 1rem;
    background: var(--brand-orange, #e07a5f);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#cart-checkout-btn:hover:not(:disabled) {
    background: #b06545;
    transform: translateY(-1px);
}

#cart-checkout-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.cart-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

#cart-clear-btn {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#cart-clear-btn:hover {
    border-color: #e53935;
    color: #e53935;
}

/* --- Add to Cart Button --- */
.add-to-cart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--brand-orange, #e07a5f);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.add-to-cart-btn:hover {
    background: #c96d57;
    transform: translateY(-1px);
}

.add-to-cart-btn svg {
    width: 16px;
    height: 16px;
}

/* --- Buy Now Button --- */
.buy-now-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--brand-orange, #e07a5f);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.buy-now-btn:hover {
    background: #b06545;
    transform: translateY(-1px);
}

.buy-now-btn svg {
    width: 16px;
    height: 16px;
}

/* Product card specific add to cart button */
.product-card .add-to-cart-btn,
.homepage-product-card .add-to-cart-btn {
    margin-top: auto;
    width: 100%;
}

/* --- Cart Notification Toast --- */
.cart-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--brand-green-dark, #5a7d5a);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.cart-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.cart-notification-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-notification-icon {
    width: 20px;
    height: 20px;
    color: #4ade80;
}

/* --- Mobile Adjustments --- */
@media (max-width: 860px) {
    #cart-drawer {
        max-width: 100%;
    }

    .cart-item {
        padding: 0.75rem;
    }

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

    .cart-notification {
        bottom: 80px;
    }
}

/* --- Product Detail Page Buy Box Buttons --- */
.buy-box-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.buy-box-buttons .add-to-cart-btn,
.buy-box-buttons .buy-now-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    border-radius: 20px;
}

.buy-box-buttons .add-to-cart-btn {
    background: var(--brand-orange, #e07a5f);
    color: #fff;
    border: 1px solid #c96d57;
}

.buy-box-buttons .add-to-cart-btn:hover {
    background: #c96d57;
}

.buy-box-buttons .buy-now-btn {
    background: #8FBC8F;
    border: 1px solid #7aa87a;
}

.buy-box-buttons .buy-now-btn:hover {
    background: #7aa87a;
}

/* --- Search Results Add to Cart --- */
.product-meta .add-to-cart-btn {
    flex-basis: 100%;
    margin-top: 0.5rem;
}

/* --- Homepage Carousel Add to Cart --- */
.homepage-product-meta .add-to-cart-btn {
    flex-basis: 100%;
    margin-top: 0.5rem;
}
