/* Product Groups Styling */
.product-groups {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-groups li {
    margin-bottom: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.group-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.product-groups li:hover .group-content {
    background: linear-gradient(135deg, #F5EBE0, #E8D5C4);
}

.product-groups li.active .group-content {
    background: linear-gradient(135deg, #A67C52, #8B6F47);
    color: white;
    box-shadow: 0 4px 8px rgba(166, 124, 82, 0.3);
}

.group-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.group-info i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.group-name {
    font-weight: 500;
    font-size: 14px;
}

.group-actions {
    display: none;
    gap: 4px;
}

.product-groups li:hover .group-actions {
    display: flex;
}

.product-groups li.active .group-actions {
    display: flex;
}

.group-action-btn {
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    color: white;
}

.group-action-btn.edit-group {
    background-color: #10b981;
}

.group-action-btn.edit-group:hover {
    background-color: #059669;
    transform: scale(1.15);
}

.group-action-btn.delete-group {
    background-color: #dc3545;
}

.group-action-btn.delete-group:hover {
    background-color: #c82333;
    transform: scale(1.15);
}

.product-groups li.active .group-action-btn.edit-group {
    background-color: #10b981;
}

.product-groups li.active .group-action-btn.delete-group {
    background-color: #dc3545;
}

.product-groups li.active .group-action-btn:hover {
    opacity: 0.9;
}

/* No products message */
.no-products {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #B5927B;
    grid-column: 1 / -1;
}

.no-products i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.4;
    color: #C9A882;
}

.no-products p {
    font-size: 18px;
    margin-bottom: 0;
    color: #8B6F47;
}

/* Product group badge shown on product cards */
.product-group-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(166,124,82,0.12), rgba(166,124,82,0.08));
    color: var(--primary-brown-darker);
    padding: 6px 10px;
    border-radius: 18px;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    width: fit-content;
}
.product-group-badge i {
    font-size: 14px;
}

/* Smaller badge for POS view */
.pos-product-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(166,124,82,0.08), rgba(166,124,82,0.04));
    color: var(--primary-brown-darker);
    padding: 4px 8px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 6px;
}
.pos-product-badge i { font-size: 12px; }

/* Product status */
.product-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-available {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    color: #2E7D32;
    border: 1px solid #81C784;
}

.status-available i {
    color: #4CAF50;
}

.status-unavailable {
    background: linear-gradient(135deg, #FFEBEE, #FFCDD2);
    color: #C62828;
    border: 1px solid #EF9A9A;
}

.status-unavailable i {
    color: #F44336;
}

.status-hidden {
    background: linear-gradient(135deg, #E0E0E0, #BDBDBD);
    color: #424242;
    border: 1px solid #9E9E9E;
}

.status-hidden i {
    color: #757575;
}

/* Modal improvements */
.modal-group-centered {
    max-width: 500px;
    width: 90%;
    margin: 50px auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-group-centered .modal-header {
    background: linear-gradient(135deg, #A67C52, #8B6F47);
    color: white;
    padding: 20px 25px;
    border-radius: 12px 12px 0 0;
}

.modal-group-centered .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 20px;
    color: white;
}

.modal-group-centered .modal-header .close {
    color: white;
    font-size: 28px;
    opacity: 0.9;
}

.modal-group-centered .modal-header .close:hover {
    opacity: 1;
}

.modal-group-centered .modal-body {
    padding: 30px 25px;
}

.modal-group-centered .form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #6B4423;
    font-size: 15px;
}

.modal-group-centered .form-group input,
.modal-group-centered .form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #E8D5C4;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.modal-group-centered .form-group input:focus,
.modal-group-centered .form-group select:focus {
    border-color: #A67C52;
    outline: none;
    box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.1);
}

.modal-group-centered .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.modal-group-centered .save-btn,
.modal-group-centered .cancel-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.modal-group-centered .save-btn {
    background: #28a745 !important;
    color: white !important;
    border: 2px solid #28a745 !important;
}

.modal-group-centered .save-btn i {
    color: white !important;
}

.modal-group-centered .save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    background: #218838 !important;
    border-color: #218838 !important;
}

.modal-group-centered .cancel-btn {
    background: #dc3545 !important;
    color: white !important;
    border: 2px solid #dc3545;
}

.modal-group-centered .cancel-btn i {
    color: white !important;
}

.modal-group-centered .cancel-btn:hover {
    background: #c82333 !important;
    border-color: #c82333;
}

.modal-product .modal-content {
/* Giới hạn chiều rộng tối đa để không bao giờ tràn màn hình */
    max-width: 90vw !important; 
    
    /* Chiều rộng chuẩn cho form nhập liệu trên Desktop */
    width: 900px !important; 
    
    /* Bỏ min-width quá lớn đi */
    min-width: unset !important; 
    
    /* Chiều cao tự động co giãn theo nội dung bên trong, đừng cố định 600px */
    height: auto !important; 
    
    /* Đặt chiều cao tối thiểu để form trông cứng cáp */
    min-height: 550px !important; 

    /* Các phần giữ nguyên */
    margin: 50px auto; /* Tăng lề trên một chút cho thoáng */
    border-radius: 16px;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-product .modal-header {
    background: linear-gradient(135deg, #A67C52, #8B6F47);
    color: white;
    padding: 20px 25px;
    border-radius: 16px 16px 0 0;
}

.modal-product .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    margin: 0;
    font-size: 20px;
}

.modal-product .modal-header .close {
    color: white;
    font-size: 28px;
    opacity: 0.9;
}

.modal-product .modal-header .close:hover {
    opacity: 1;
}

.modal-product .modal-body {
    padding: 20px 40px;
    overflow-x: hidden;
    height: calc(100% - 70px);
    overflow-y: auto;
}

.modal-body .form-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 30px;
    margin-bottom: 15px;
    max-width: 100%;
    height: 100%;
}

.form-group-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.form-group-column > .form-group {
    width: 100%;
    min-width: 0;
}

.modal-body .form-group {
    margin-bottom: 0;
    min-width: 0;
    overflow: hidden;
}

.modal-body .form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #6B4423;
    font-size: 15px;
    white-space: nowrap;
}

.modal-body .form-group label i {
    color: #A67C52;
}

.required {
    color: #d32f2f;
}

.modal-body .form-group input,
.modal-body .form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #E8D5C4;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background-color: white;
    box-sizing: border-box;
    min-width: 0;
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus {
    border-color: #A67C52;
    box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.1);
    outline: none;
    box-shadow: 0 0 0 4px rgba(166, 124, 82, 0.1);
    background-color: white;
}

.form-group-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 12px;
}

.form-group-inline.form-group-three {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 18px;
}

.form-group-inline.form-group-three .form-group {
    min-width: 0;
}

.form-group-inline.form-group-three .form-group label {
    white-space: nowrap;
    font-size: 15px;
}

.form-group-inline.form-group-three .form-group input {
    width: 100%;
    min-width: 0;
    padding: 12px 70px 12px 12px;
}

.input-with-unit {
    position: relative;
}

.input-unit {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #8B6F47;
    font-weight: 600;
    font-size: 13px;
    pointer-events: none;
    white-space: nowrap;
}

.input-with-unit input {
    padding-right: 75px;
}

/* Image Upload Section */
.image-section {
    display: flex;
    flex-direction: column;
}

.image-upload-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.image-preview-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    border: 2px dashed #D5D5D5;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.image-preview-wrapper:hover {
    border-color: #A67C52;
    box-shadow: 0 2px 8px rgba(166, 124, 82, 0.15);
}

.image-preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(107, 68, 35, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    color: white;
}

.image-preview-wrapper:hover .image-overlay {
    opacity: 1;
}

.image-overlay i {
    font-size: 48px;
    margin-bottom: 10px;
}

.image-overlay p {
    font-size: 14px;
    font-weight: 600;
}

.upload-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #A67C52, #8B6F47);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(166, 124, 82, 0.4);
}

.image-note {
    font-size: 12px;
    color: #8B6F47;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background: #F5EBE0;
    border-radius: 8px;
}

.image-note i {
    color: #A67C52;
}

/* Status Toggle */
.status-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.status-toggle input[type="checkbox"] {
    display: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    background: white;
    border-radius: 50px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 18px;
    background: #ccc;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.status-toggle input[type="checkbox"]:checked + .toggle-label .toggle-switch {
    background: linear-gradient(135deg, #7FB069, #6A994E);
}

.status-toggle input[type="checkbox"]:checked + .toggle-label .toggle-switch::before {
    transform: translateX(18px);
}

.toggle-text {
    font-weight: 600;
    color: #6B4423;
    font-size: 12px;
}

.status-toggle input[type="checkbox"]:checked + .toggle-label {
    background: linear-gradient(135deg, rgba(127, 176, 105, 0.1), rgba(106, 153, 78, 0.1));
}

/* Stock and Status Row */
.form-group-inline.form-group-stock-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: end;
}

.form-group-inline.form-group-stock-status .form-group label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-group-inline.form-group-stock-status .status-group {
    display: flex;
    align-items: flex-end;
    padding-top: 32px;
}

.form-group-inline.form-group-stock-status .status-toggle {
    margin-top: 0;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid #F5EBE0;
    grid-column: 1 / -1;
}

.form-actions.form-actions-stacked {
    flex-direction: row;
    gap: 20px;
    justify-content: center;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.form-actions-stacked .save-btn,
.form-actions-stacked .cancel-btn {
    flex: 1;
    max-width: 500px;
    padding: 16px 50px;
    font-size: 16px;
}

.save-btn,
.cancel-btn {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    flex: 0 0 auto;
    min-width: 140px;
}

.save-btn {
    background: #28a745 !important;
    color: white !important;
    border: 2px solid #28a745 !important;
}

.save-btn i {
    color: white !important;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    background: #218838 !important;
    border-color: #218838 !important;
}

.cancel-btn {
    background: #dc3545 !important;
    color: white !important;
    border: 2px solid #dc3545;
}

.cancel-btn i {
    color: white !important;
}

.cancel-btn:hover {
    background: #c82333 !important;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    border-color: #c82333;
}

/* Menu grid improvements */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    padding: 24px;
}

.product-card {
    background: linear-gradient(135deg, #FFFFFF, #FFF8E7);
    border: 2px solid #E8D5C4;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(166, 124, 82, 0.1);
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(166, 124, 82, 0.25);
    border-color: #D7C4B0;
}

.product-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #F5EBE0;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.1);
}

.product-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card:hover .product-actions {
    opacity: 1;
}

.edit-btn,
.visibility-btn,
.delete-btn {
    padding: 10px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-size: 14px;
}

.edit-btn {
    background: #10b981;
    color: white;
}

.edit-btn:hover {
    background: #059669;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(5,150,105,0.2);
}

.visibility-btn {
    background: rgba(139, 111, 71, 0.95);
    color: white;
}

.visibility-btn:hover {
    background: linear-gradient(135deg, #8B6F47, #6B4423);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(139, 111, 71, 0.4);
}

.delete-btn {
    background: rgba(185, 94, 94, 0.95);
    color: white;
}

.delete-btn:hover {
    background: linear-gradient(135deg, #B95E5E, #A04848);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(185, 94, 94, 0.4);
}

/* Hidden product style */
.product-card.product-hidden {
    opacity: 0.5;
    position: relative;
}

.product-card.product-hidden::after {
    content: 'ẨN';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(107, 68, 35, 0.9);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
    z-index: 10;
    pointer-events: none;
}

.product-info {
    padding: 16px;
    background: white;
}

.product-info h4 {
    margin: 0 0 12px 0;
    font-size: 17px;
    font-weight: 700;
    color: #6B4423;
    line-height: 1.3;
}

.product-meta {
    margin-bottom: 12px;
}

.product-price {
    font-size: 20px;
    font-weight: 700;
    color: #A67C52;
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, #FFF8E7, #F5EBE0);
    border-radius: 8px;
    border: 1px solid #E8D5C4;
}

.product-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding-top: 12px;
    border-top: 1px solid #F5EBE0;
}

.product-stock,
.product-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.product-stock {
    color: #8B6F47;
}

.product-stock i {
    color: #A67C52;
}

/* Responsive */
@media (max-width: 768px) {
    .menu-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .product-image {
        height: 150px;
    }
    
    .modal-product .modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-body .form-row {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .form-group-inline {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .save-btn,
    .cancel-btn {
        width: 100%;
        justify-content: center;
    }
}
