/* Reset CSS để loại bỏ các mặc định của trình duyệt */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Thiết lập font chung cho trang web */
body {
    font-family: arial, sans-serif;
    background-color: #f2f2f2;
    display: grid;
    grid-template-columns: 70% 30%;
    /* Chia trang thành hai cột */
    max-width: 1200px;
    /* Độ rộng tối đa trang web */
    margin: 0 auto;
    /* Canh giữa trang web trên màn hình*/
}

header {
    background-color: #c7cc19;
    color: #fff;
    padding: 20px;
    text-align: center;
    grid-column: 1 / span 2;
    /* Trải đều qua cả hai cột*/
}

/*Phần menu điều hướng*/
nav {
    background-color: #ffa486;
    color: #fff;
    text-align: center;
    padding: 10px;
    grid-column: 1/ span 2;
    /*Trải đều qua cả hai cột*/
}

nav ul {
    list-style: none;
}

nav ul li {
    display: inline;
    margin-right: 20px;
}

/* Phần danh sách sản phẩm */
.product-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Hiển thị 3 sản phẩm trên mỗi hàng */
    gap: 20px;
    /* Khoảng cách giữa các sản phẩm */
    padding: 20px;
    grid-column: 1;
    /* Chỉ nằm ở cột đầu tiên */
}

.product-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    width: 100%;
    text-align: center; /* Căn giữa nội dung trong sản phẩm */
}

.product-card img {
    max-width: 100%;
    height: auto;
}

/* Tối ưu card */
.card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

/* Ảnh card cùng kích thước */
.card-img-top {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 10px 10px 0 0;
}

/* Card body flex để nút căn đáy */
.card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 1.25rem;
}

.card-text:not(:last-of-type) {
    flex-grow: 1;
}

.card-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
}

.btn-primary {
    background-color: #007bff;
    border: none;
    margin-top: auto;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.btn-primary:hover {
    background-color: #0056b3;
}

/* Phần sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.sidebar-box {
    background-color: #007bff;
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sidebar-box h5 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.sidebar-box ul {
    list-style: none;
    padding: 0;
}

.sidebar-box li {
    margin-bottom: 0.5rem;
}

.sidebar-box a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.sidebar-box a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Header */
.site-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Footer */
.footer-section {
    background-color: #343a40;
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-box {
    text-align: center;
    border-right: 1px solid #555;
    padding: 1.5rem;
}

.footer-box:last-child {
    border-right: none;
}

.footer-box h3 {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #20c997;
}

/* Cart items */
.cart-items-list {
    max-height: 500px;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    transition: background 0.3s ease;
}

.cart-item:hover {
    background: #e9ecef;
}

.cart-item-info {
    flex-grow: 1;
    margin-bottom: 0.75rem;
}

.cart-item-name {
    font-weight: 700;
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.cart-item-price {
    color: #dc3545;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    border-radius: 6px;
    border: 1px solid #ddd;
    width: fit-content;
}

.cart-item-qty button {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
}

.cart-item-qty button:hover {
    background: #0056b3;
}

.cart-item-qty span {
    padding: 0 0.75rem;
    font-weight: 600;
    color: #333;
    min-width: 30px;
    text-align: center;
}

.cart-item-remove {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
    align-self: flex-end;
}

.cart-item-remove:hover {
    background: #c82333;
}

/* Offcanvas */
.offcanvas {
    width: 400px !important;
}

.offcanvas-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-bottom: 2px solid #ddd;
    padding: 1.5rem;
}

.offcanvas-header .btn-close {
    filter: brightness(0) invert(1);
}

.offcanvas-body {
    background: #fff;
}

#emptyCart {
    margin: 2rem auto !important;
    padding: 2rem !important;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: #856404;
    background: #fff3cd !important;
    border: 1px solid #ffeeba !important;
}

.offcanvas-footer {
    background: #f8f9fa;
    border-top: 2px solid #ddd;
    padding: 1.5rem;
}

.offcanvas-footer h6 {
    margin: 0;
    font-size: 1rem;
}

#totalPrice {
    font-size: 1.5rem;
}

.offcanvas-footer .btn {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.offcanvas-footer .btn-success {
    background: #28a745;
    border: none;
}

.offcanvas-footer .btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.offcanvas-footer .btn-danger {
    background: #dc3545;
    border: none;
}

.offcanvas-footer .btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

/* Responsive */
@media (max-width: 576px) {
  .product-list {
    grid-template-columns: 1fr;
    /* Hiển thị một sản phẩm trên mỗi hàng */
  }

  .product-card {
    width: 100%;
    margin-bottom: 20px;
  }

  .sidebar {
    grid-column: 1 / span 2;
    /* Trải đều qua cả hai cột */
  }

  /* Chỉnh lại bố cục cho phần footer */
  .footer {
    grid-template-columns: 1fr;
    /* 1 cột xếp chồng lên nhau trên màn hình di động */
  }
}

/* Phần footer */
.footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 20px;
    grid-column: 1 / span 2;
    /* Trải đều qua cả hai cột */
    display: grid;
}

/* Cột trong phần footer */
.footer-item {
    padding: 10px;
}

/* Chỉnh layout cho máy tính */
@media (min-width: 768px) {
  .footer {
    grid-template-columns: repeat(3, 1fr);
    /* 3 cột trên máy tính */
  }
}

.button {
  background-color: #04AA6D;
  border: none;
  color: white;
  padding: 20px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
}

.button1 {
    border-radius: 2px;
}

.button3 {
    border-radius: 8px;
}

.button4 {
    border-radius: 12px;
}

.button5 {
    border-radius: 50%;
}

/* Responsive */
@media (max-width: 1200px) {
    .sidebar {
        position: static;
        top: auto;
    }
}

@media (max-width: 992px) {
    /* Tablet - sidebar dưới sản phẩm */
    #products {
        grid-column: 1 / -1;
    }

    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        position: static;
        margin-top: 2rem;
    }

    .sidebar-box {
        padding: 1.25rem;
    }
}

@media (max-width: 768px) {
    .card-img-top {
        height: 200px;
    }

    /* Mobile - sidebar full width */
    .sidebar {
        grid-template-columns: 1fr;
        margin-top: 2rem;
        gap: 1rem;
    }

    .sidebar-box {
        padding: 1rem;
    }

    .sidebar-box h5 {
        font-size: 1rem;
    }

    .sidebar-section .row {
        gap: 1rem;
    }
    
    .sidebar-section .col-lg-6 {
        flex: 0 0 100%;
    }

    .footer-box {
        border-right: none;
        border-bottom: 1px solid #555;
        padding: 1rem 0;
    }
    
    .footer-box:last-child {
        border-bottom: none;
    }

    .footer-box h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    /* Mobile nhỏ */
    .sidebar-box {
        padding: 0.875rem;
    }

    .sidebar-box h5 {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
    }

    .sidebar-box ul {
        font-size: 0.9rem;
    }

    .sidebar-box li {
        margin-bottom: 0.375rem;
    }
}

@media (max-width: 768px) {
    .offcanvas {
        width: 100% !important;
    }

    .cart-item {
        padding: 1rem;
    }

    .cart-item-qty {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 0.75rem;
    }

    .cart-item-qty span {
        flex-grow: 1;
        text-align: center;
    }

    .cart-item-remove {
        align-self: stretch;
        width: 100%;
    }
}