/**
 * cart.css
 * Chứa các style chỉ dành cho trang giỏ hàng (cart.html).
 * Phiên bản đã được sửa lỗi hiển thị cho bộ điều khiển số lượng.
 */

/* Bố cục chính của trang giỏ hàng */
.cart-layout {
    display: grid;
    grid-template-columns: 2fr 1fr; 
    gap: 40px;
    align-items: flex-start;
}

/* Khi giỏ hàng trống, chuyển layout thành 1 cột */
.cart-layout.cart-empty {
    grid-template-columns: 1fr;
}

/* Danh sách sản phẩm */
.cart-items-list {
    background: var(--color-white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-soft);
    width: 100%; 
}

/* Kiểu dáng cho từng sản phẩm trong giỏ hàng */
.cart-item {
    display: grid;
    /* Điều chỉnh lại độ rộng cột số lượng */
    grid-template-columns: 80px 1fr 120px 120px 40px; 
    gap: 20px;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--color-border);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item .cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}
.cart-item .cart-item-name {
    font-size: 1.1rem;
    color: var(--color-dark);
    font-weight: 500;
    margin: 0;
}
.cart-item .cart-item-price {
    color: var(--color-text);
    margin: 5px 0 0 0;
    font-size: 0.9rem;
}
.cart-item .cart-item-subtotal {
    font-weight: 700;
    color: var(--color-dark);
    font-size: 1.1rem;
    text-align: right;
    white-space: nowrap;
}
.cart-item .cart-item-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    padding: 5px;
    justify-self: center;
}
.cart-item .cart-item-remove-btn:hover {
    color: #ef5350;
}
.cart-item .cart-item-remove-btn svg {
    width: 20px;
    height: 20px;
}
    
/* === PHẦN CSS ĐÃ SỬA LỖI (KHÔNG DÙNG NESTING) === */
.cart-item-quantity {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-quantity .quantity-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    background-color: var(--color-white);
    color: var(--color-dark);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.3s;
}
.cart-item-quantity .quantity-btn:hover {
    background-color: var(--color-light);
}

.cart-item-quantity .decrease-btn {
    border-radius: 8px 0 0 8px;
}

.cart-item-quantity .increase-btn {
    border-radius: 0 8px 8px 0;
}

.cart-item-quantity .quantity-value {
    width: 40px;
    height: 32px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-left: none;
    border-right: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-dark);
    background: var(--color-white);
    -moz-appearance: textfield;
    pointer-events: none;
}
.cart-item-quantity .quantity-value::-webkit-outer-spin-button,
.cart-item-quantity .quantity-value::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
/* === KẾT THÚC PHẦN CSS ĐÃ SỬA === */

/* Thông báo khi giỏ hàng trống */
.cart-empty-message {
    padding: 40px;
    text-align: center;
    font-size: 1.2rem;
}
.cart-empty-message .btn {
    margin-top: 20px;
}

/* Khung tóm tắt đơn hàng */
.cart-summary-box {
    background: var(--color-light);
    padding: 30px;
    border-radius: var(--border-radius);
    position: sticky;
    top: 120px;
}
.cart-summary-box h3 {
    font-size: 1.5rem;
    color: var(--color-dark);
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--color-border);
}
.cart-summary-box .summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}
.cart-summary-box .summary-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-dark);
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}
.cart-summary-box .btn-checkout {
    width: 100%;
    margin-top: 25px;
    padding: 16px;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 992px) {
    .cart-layout {
        grid-template-columns: 1fr;
    }
    .cart-summary-box {
        position: static; 
    }
}

@media (max-width: 768px) {
    .cart-item {
        grid-template-columns: 60px 1fr auto;
        grid-template-rows: auto auto;
        row-gap: 15px;
    }
    .cart-item .cart-item-image {
        width: 60px;
        height: 60px;
        grid-row: 1 / 3;
    }
    .cart-item .cart-item-details {
        grid-row: 1;
        grid-column: 2;
    }
    .cart-item .cart-item-quantity {
        grid-row: 2;
        grid-column: 2;
        justify-self: start;
    }
    .cart-item .cart-item-subtotal {
        grid-row: 2;
        grid-column: 2;
        justify-self: end;
        align-self: center;
    }
    .cart-item .cart-item-remove-btn {
        grid-row: 1 / 3;
        grid-column: 3;
        align-self: center;
    }
}
