:root {
    --primary-color: #125e3a; /* Xanh lá đậm */
    --primary-hover: #0d462a;
    --accent-color: #fde047; /* Vàng */
    --bg-color: #f0f7f3;
    --text-color: #1f2937;
    --text-light: #4b5563;
    --border-color: #e5e7eb;
    --card-bg: #ffffff;
    --radius: 16px;
    --shadow: 0 4px 15px -3px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Quicksand', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.logo {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    color: var(--accent-color);
}

.mode-switcher {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-radius: 999px;
    padding: 4px;
}

.mode-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.7;
}

.mode-btn.active {
    background: white;
    color: var(--primary-color);
    opacity: 1;
}

.header-contact {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.15);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.95rem;
}

/* Main Layout */
.container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem 3%;
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width: 992px) {
    .container {
        grid-template-columns: 2fr 360px;
    }
}

/* Category Filters */
.category-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.category-filters::-webkit-scrollbar {
    height: 4px;
}
.category-filters::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.filter-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.6rem 1.25rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.95rem;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Sub-filters (Price & Sort) */
.sub-filters select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 28px !important;
}

@media (max-width: 640px) {
    .sub-filters {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }
    .sub-filters > div {
        justify-content: space-between;
    }
    .sub-filters select {
        flex: 1;
    }
}

/* Products Section */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px -5px rgb(0 0 0 / 0.1);
}

.product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 1rem;
    background-color: #f1f5f9;
}

.product-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.product-price {
    font-weight: 700;
    color: #ef4444; /* Màu đỏ cho giá */
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.add-to-cart {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    transition: background-color 0.2s;
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.add-to-cart:hover {
    background-color: var(--primary-hover);
}

/* Nút chọn Size đồ uống */
.product-size-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: auto;
}
.btn-size-add {
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 4px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}
.btn-size-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.btn-size-s {
    color: #0284c7;
    border-color: #bae6fd;
    background: #f0f9ff;
}
.btn-size-s:hover {
    background: #0284c7;
    color: white;
    border-color: #0284c7;
}
.btn-size-s:hover .size-tag {
    background: white;
    color: #0284c7;
}
.btn-size-m {
    color: #ea580c;
    border-color: #fed7aa;
    background: #fff7ed;
}
.btn-size-m:hover {
    background: #ea580c;
    color: white;
    border-color: #ea580c;
}
.btn-size-m:hover .size-tag {
    background: white;
    color: #ea580c;
}
.size-tag {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
    transition: all 0.2s ease;
}
.btn-size-s .size-tag { background: #e0f2fe; color: #0284c7; }
.btn-size-m .size-tag { background: #ffedd5; color: #ea580c; }

/* Huy hiệu Size trong Giỏ hàng */
.cart-size-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
    white-space: nowrap;
}
.cart-size-badge.size-s { background: #e0f2fe; color: #0284c7; }
.cart-size-badge.size-m { background: #ffedd5; color: #ea580c; }

/* Cart Section */
.cart-section {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px); height: calc(100dvh - 100px);
    position: sticky;
    top: 80px;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
}

.cart-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-count {
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem;
}

/* Custom Scrollbar for cart items */
.cart-items::-webkit-scrollbar {
    width: 5px;
}
.cart-items::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.empty-cart {
    text-align: center;
    color: var(--text-light);
    margin-top: 2rem;
    font-weight: 500;
}

.cart-item {
    display: flex;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-img {
    width: 65px;
    height: 65px;
    object-fit: cover;
    border-radius: 10px;
}

.cart-item-details {
    flex-grow: 1;
}

.cart-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.cart-item-price {
    color: #ef4444;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qty-btn {
    background: var(--bg-color);
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-color);
    transition: background 0.2s;
}

.qty-btn:hover {
    background: var(--border-color);
}

.remove-btn {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: auto;
}

.remove-btn:hover {
    text-decoration: underline;
}

/* Checkout Forms */
.cart-summary {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
}

.summary-row.total {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.25rem;
    margin-top: 0.5rem;
}

.mode-form {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-control {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    background-color: var(--bg-color);
}

.form-control:focus {
    border-color: var(--primary-color);
    background-color: white;
}

.radio-group {
    display: flex;
    gap: 1rem;
    padding: 0.25rem 0;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
}

.change-row {
    background-color: #fef2f2;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.25rem;
    border: 1px dashed #fca5a5;
    margin-bottom: 0;
}

.checkout-btn {
    width: 100%;
    background-color: #ef4444; 
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1.05rem;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkout-btn:hover {
    background-color: #dc2626;
}

.checkout-btn.pos-btn {
    background-color: var(--primary-color);
}

.checkout-btn.pos-btn:hover {
    background-color: var(--primary-hover);
}

/* --- POS MODE OPTIMIZATIONS --- */
.pos-mode .container { padding: 1.5rem 2%; max-width: 100%; gap: 1.5rem; }
.pos-mode .products-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
.pos-mode .product-card { padding: 8px; border-radius: 8px; }
.pos-mode .product-img { border-radius: 6px; margin-bottom: 8px; aspect-ratio: 1; }
.pos-mode .product-info { display: flex; flex-direction: column; gap: 4px; }
.pos-mode .product-name { font-size: 13px; line-height: 1.3; font-weight: 600; margin-bottom: 0; }
.pos-mode .product-price { font-size: 14px; font-weight: 700; color: var(--primary-color); }
.pos-mode .filter-btn { padding: 6px 12px; font-size: 13px; }
.pos-mode .search-input { width: 180px !important; padding: 6px 15px !important; font-size: 13px; }

/* --- SUB-FILTERS (SẮP XẾP & KHOẢNG GIÁ) --- */
.sub-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
    max-width: 100%;
}

.sub-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}

.sub-filter-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.sub-filter-select {
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    color: #1e293b;
    outline: none;
    cursor: pointer;
    box-sizing: border-box;
}

.sub-filter-select:focus,
.price-input:focus {
    border-color: #ea580c;
}

.price-range-box {
    display: flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    max-width: 100%;
}

.price-separator {
    color: #64748b;
    font-weight: 500;
    flex-shrink: 0;
}

.price-input {
    width: 85px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: white;
    box-sizing: border-box;
}

.btn-filter-price {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    background: #ea580c;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.btn-filter-price:hover {
    background: #c2410c;
}

.btn-reset-price {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    background: #e2e8f0;
    color: #475569;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.btn-reset-price:hover {
    background: #cbd5e1;
}

/* --- RESPONSIVE OPTIMIZATIONS (Tablet & Mobile) --- */
@media (max-width: 991px) {
    .container { grid-template-columns: 1fr; padding: 1rem; gap: 1.5rem; }
    .pos-mode .container { padding: 1rem; }
    .cart-section { max-height: none; }
}

@media (max-width: 768px) {
    body { overflow-x: hidden; width: 100%; }
    header { flex-direction: row; justify-content: space-between; align-items: center; width: 100%; padding: 10px; box-sizing: border-box; }
    .logo { width: auto; justify-content: flex-start; }
    .header-contact { display: none !important; }
    .mobile-cart-toggle { display: flex !important; }
    .mode-switcher { margin-top: 10px; width: 100%; justify-content: center; flex-wrap: wrap; border-radius: 12px; gap: 5px; }
    .mode-btn { padding: 0.5rem; flex: 1; text-align: center; justify-content: center; display: flex; align-items: center; gap: 5px; font-size: 0.85rem; white-space: normal; line-height: 1.2; }
    .search-bar { width: 100%; margin: 0; box-sizing: border-box; }
    .container > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
    
    /* Sub-filters trên điện thoại không bị tràn */
    .sub-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }
    .sub-filter-group {
        width: 100%;
    }
    .sub-filter-group.sort-group {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .sub-filter-group.sort-group .sub-filter-select {
        flex: 1;
        min-width: 0;
        width: 100%;
    }
    .sub-filter-group.price-group {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .price-range-box {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .price-input {
        flex: 1;
        min-width: 0;
        width: 100% !important;
    }
    
    .products-grid, .pos-mode .products-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px; 
    }
    
    .product-card { padding: 0.75rem; }
    .product-img-wrapper { height: auto; aspect-ratio: 1; }
    .product-title { font-size: 0.95rem; }
    .product-price { font-size: 1rem; }
    
    .category-filters { flex-direction: column; align-items: stretch !important; gap: 10px !important; flex-wrap: nowrap !important; min-width: 0; }
    .category-filters > div { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 5px; gap: 10px; width: 100%; box-sizing: border-box; flex-wrap: nowrap !important; min-width: 0; }
    .category-filters > div::-webkit-scrollbar { display: none; }
    .category-filters .filter-btn { white-space: nowrap; flex-shrink: 0; }
    .category-filters .search-input { width: 100% !important; margin: 0; box-sizing: border-box; }
    
    /* Make cart section a sliding drawer on mobile */
    .cart-section { 
        position: fixed; 
        top: 0; 
        right: -100%;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 400px;
        z-index: 1000; 
        border-radius: 0; 
        box-shadow: -10px 0 25px rgba(0,0,0,0.15); 
        max-height: none; 
        display: flex;
        flex-direction: column;
        margin: 0; 
        padding: 0;
        background: #ffffff;
        border: none;
        box-sizing: border-box;
        transition: right 0.3s ease;
    }
    .cart-section.open {
        right: 0;
    }
    .cart-header { padding: 15px; border-bottom: 1px solid #e2e8f0; margin-bottom: 0; }
    .cart-items { padding: 15px; flex-grow: 1; overflow-y: auto; }
    .cart-summary { padding: 15px; background: white; border-top: 1px solid #e2e8f0; }
    .mobile-cart-close { display: block !important; }
    .container { padding: 10px 4% 4% 4%; box-sizing: border-box; }
    .pos-mode .container { padding: 10px 4% 4% 4%; box-sizing: border-box; }
}

/* --- EXTRA SMALL MOBILE (< 480px) --- */
@media (max-width: 480px) {
    /* Khoảng giá: input và nút xuống 2 hàng riêng biệt */
    .sub-filter-group.price-group {
        gap: 8px;
    }
    .price-range-box {
        flex-wrap: wrap;
        gap: 6px;
    }
    .price-input {
        min-width: 90px;
        flex: 1 1 90px;
    }
    .btn-filter-price,
    .btn-reset-price {
        flex: 1;
        justify-content: center;
    }
    .sub-filter-group.sort-group .sub-filter-select {
        font-size: 12px;
        padding: 5px 8px;
    }
}
