/* Modal backdrop */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.1) !important;
}

.modal-header-pricing {
    display: flex;
    padding: 10px 20px;
    justify-content: space-between;
    align-items: center;
    align-self: stretch;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0.5;
}

/* Modal container */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

.modal.fade {
    transition: opacity 0.15s linear;
}

.modal.show {
    display: block !important;
}

.modal-dialog {
    position: relative;
    width: auto;
    margin: 1.75rem auto;
    pointer-events: none;
}

.modal-xl {
    width: auto;
    max-width: 95%;
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
    margin: 1.75rem auto;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 12px;
    outline: 0;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, .1);
}

.modal-header {
    display: flex;
    padding: 15px 20px;
    justify-content: space-between;
    align-items: center;
    align-self: stretch;
}

.modal-title {
    color: rgba(0, 0, 0, 0.90);
    font-size: 20px;
    font-weight: 500;
    line-height: 28px;
}

.btn-close {
    padding: 0;
    margin: 0;
    background: none !important;
    border: 0;
    opacity: 0.7;
    cursor: pointer;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #171717;
}

.btn-close:hover {
    opacity: 1;
}

.btn-close svg {
    width: 16px;
    height: 16px;
    display: block;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 0;
    overflow: hidden;
}

.p-0 {
    padding: 0 !important;
}

/* Modal body content layout */
.modal-body-pricing {
    display: flex;
    padding: 0 20px;
    flex-direction: column;
    gap: 12px;
    align-self: stretch;
    height: 600px;
    max-height: 600px;
}

.search-add-item {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.search-container {
    width: 40%;
    height: 100%;
}

.search-bar {
    display: flex;
    align-items: center;
    border: 1px solid #D9D9D9;
    border-radius: 8px;
    background: #fff;
    width: 100%;
    overflow: hidden;
    position: relative;
    height: 32px;
}

.search-input {
    border: none;
    outline: none;
    padding: 4px 12px;
    flex: 1;
    background: transparent;
    border-radius: 8px;
    height: 100%;
    font-size: 14px;
    font-weight: 400;
    line-height: 22px;
}

.search-input::placeholder {
    color: rgba(0, 0, 0, 0.25);
}

.search-btn {
    background: none;
    height: 100%;
    border: none;
    border-left: 1px solid #e2e2e2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    cursor: pointer;
}

.search-btn:hover {
    background-color: #f5f5f5;
}

.content-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-header-left {
    color: #292929;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;

}

.selected-info-label {
    font-weight: 500;
}



.add-btn-header {
    background: #1890ff;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.add-btn-header:hover:not(:disabled) {
    background: #40a9ff;
}

.add-btn-header:disabled {
    background: #d9d9d9;
    cursor: not-allowed;
}

.body-content {
    flex: 1;
    display: flex;
    padding-bottom: 20px;
    gap: 24px;
    overflow: hidden;
}

.sidebar {
    width: 270px;
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 100%;
}



.menu-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    gap: 4px;
    transition: background-color 0.2s;
    color: #000;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    border-radius: 8px;
}

.menu-text {
    color: #292929;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
}

.menu-item:hover {
    background-color: #f5f5f5;
    border-radius: 8px;
}

.menu-item.active {
    background-color: #EDEDED;
    border-radius: 8px;

}

.menu-count {
    color: #000;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
    background: #fff;
}

.services-grid {
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 16px;

}

.service-card {
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border-radius: 12px;
    border: 1px solid #e5e5e5;
    background: #FFF;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.04);
}

.service-card:hover {
    background: #FAFAFA;
    transform: translateY(-2px);
}



.service-head {
    display: flex;
    padding: 8px 16px;
    gap: 10px;
    align-self: stretch;
    box-shadow: 0 -1px 0 0 #F0F0F0 inset;
    min-height: 55.2px;
    flex: 1;
}

.service-checkbox-container {
    display: flex;
    align-items: flex-start;
    align-self: stretch;
}

.service-checkbox {
    margin-top: 6px;
    cursor: pointer;
}

.service-title {
    color: #292929;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
}

.service-content-body {
    display: flex;
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    align-self: stretch;
}

.service-description {
    position: relative;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    max-height: 72px;
    transition: max-height .25s ease;
}

.service-description-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}



.service-description.expanded {
    -webkit-line-clamp: unset;
    max-height: 9999px;
    /* mở rộng không giới hạn */
    overflow: visible;
}


.desc-actions {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.see-more-btn {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-size: 13px;
    line-height: 20px;
    color: #1890ff;
}

.see-more-btn:hover {
    text-decoration: underline;
}

.see-more-hidden {
    display: none !important;
}

/* HTML content styling inside service description */
.service-description p {
    margin: 0;
    line-height: 20px;
}

.service-description p:last-child {
    margin-bottom: 0;
}

.service-description strong,
.service-description b {
    font-weight: 600;
    color: #333;
}

.service-description em,
.service-description i {
    font-style: italic;
}

.service-description ul,
.service-description ol {
    margin: 0;
    padding-left: 16px;
    font-size: 14px;
}

.service-description li {
    margin-bottom: 2px;
    line-height: 18px;
}

.service-description br {
    display: block;
    content: "";
    margin-top: 4px;
}

.service-price {
    display: inline-block;
    align-items: flex-start;
    align-self: stretch;
    color: #292929;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 20px;
    overflow-wrap: break-word;
    max-width: 100%;
}

.service-price-value {
    margin-left: 4px;
    font-weight: 600;

}

.pagination {
    flex-shrink: 0;
    display: flex;
    justify-content: end;
    background: #fff;
}

.page-btn {
    border: 1px solid transparent;
    background: #fff;
    color: rgba(0, 0, 0, 0.85);
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    padding: 0 8px;
    outline: none;
    text-align: center;
    font-size: 14px;
    font-weight: 400;
    line-height: 22px;
    padding: 1px 8px;
    align-self: stretch;
}

.page-btn.active {
    border-color: #1890ff;
    color: #1890ff;
    background: #fff;
    font-weight: 500;
}

.page-btn:disabled,
.page-btn.disabled {
    color: #D9D9D9 !important;
    border-color: transparent !important;
    background: #fff !important;
    cursor: not-allowed !important;
}

.page-btn svg {
    width: 12px;
    height: 12px;
    display: block;
}

body.modal-open {
    overflow: hidden;
}

/* Responsive - Tailwind CSS Breakpoints */
/* xl: 1280px and up */
@media (max-width: 1280px) {
    .services-grid {
        padding: 0 8px;

    }
}

@media (min-width: 1280px) {
    .services-grid {
        min-height: 486px;
        max-height: 486px;
    }
}

@media (min-width: 1200px) {
    .service-head {
        max-height: 108px;
    }
}

@media (min-width : 1536px) {
    .modal-xl {
        max-width: 1500px;
    }
}

@media (min-width : 769px) {
    .service-description-container {
        height: auto;
    }

    /* Nếu bên trong KHÔNG có .expanded → đặt chiều cao cố định */
    .service-description-container:not(:has(.expanded)) {
        height: 88px;
    }
}

/* md: 768px and down */
@media (max-width: 768px) {

    .modal-dialog {
        margin: 1rem;
        width: calc(100% - 2rem);
        max-width: calc(100% - 2rem);
    }

    .content-header {
        justify-content: space-between;
    }

    .modal-dialog-centered {
        min-height: calc(100% - 2rem);
        margin: 1rem auto;
    }



    .modal-content {
        max-height: calc(100vh - 2rem);
    }

    .modal-body-pricing {
        height: 75vh;
        max-height: 75vh;
        padding: 0 24px;
    }

    .body-content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .services-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .sidebar {
        width: 200px;
        padding-right: 12px;
    }

    .search-add-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .search-container {
        width: 100%;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== ADDITIONAL RESPONSIVE STYLES ===== */

/* lg: 1024px to 1279px - Tablet Portrait */
@media (max-width: 1023px) and (min-width: 769px) {


    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .sidebar {
        width: 170px;
    }

    .modal-body-pricing {
        padding: 0 16px;
    }
}

/* md: 768px and down - Mobile Landscape */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-body-pricing {
        height: 85vh;
        max-height: 85vh;
    }

    .body-content {
        gap: 16px;
    }

    .sidebar {
        width: 180px;
    }
}

/* sm: 640px and down - Mobile Portrait */

/* xs: 480px and down - Very Small Mobile */

/* Scrollbar styling for mobile - md and down */
@media (max-width: 768px) {

    .sidebar::-webkit-scrollbar,
    .services-grid::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    .sidebar::-webkit-scrollbar-track,
    .services-grid::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 2px;
    }

    .sidebar::-webkit-scrollbar-thumb,
    .services-grid::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 2px;
    }

    .sidebar::-webkit-scrollbar-thumb:hover,
    .services-grid::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }
}

/* ========== MOBILE FIXES (≤ 640px) ========== */
@media (max-width: 640px) {
    .body-content {
        padding-left: 0px;
    }

    .services-grid {
        padding: 0px;
    }

    /* Modal width & padding an toàn, tránh tràn chiều ngang */
    .custom-modal-service .modal-dialog.modal-xl {
        margin: 10px;
        /* bớt chật mép */
        max-width: calc(100% - 20px);
    }

    .custom-modal-service .modal-content {
        border-radius: 10px;
    }

    .modal-header-pricing {
        padding: 12px 14px;
    }

    .modal-body-pricing {
        padding: 12px 14px;
    }

    /* Header: cho wrap để không vỡ dòng */
    .search-add-item .content-header {
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: wrap;
        /* 🔧 cho phép xuống dòng */
    }

    .search-add-item .content-header-left {
        min-width: 0;
        flex: 1 1 auto;
    }

    #addServiceBtn {
        flex: 0 0 auto;
    }

    /* Ô tìm kiếm full chiều ngang, không tràn icon */
    .search-container {
        width: 100%;
    }

    .search-bar {
        width: 100%;
    }

    .search-bar .search-input {
        width: 100%;
        min-width: 0;
        /* tránh cố giữ width cũ */
    }

    /* Tabs/Category: cho scroll ngang thay vì ép wrap gây vỡ layout */
    .sidebar {
        display: none;
    }

    /* nếu sidebar là cột trái, ẩn trên mobile */
    .content-area {
        width: 100%;
    }

    .menu-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        /* 🔧 trượt ngang */
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .menu-list .menu-item {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    /* Lưới services: về 1 cột trên mobile */
    .services-grid {
        display: grid;
        grid-template-columns: 1fr !important;
        /* 🔧 override mọi rule 2–3 cột */
        gap: 10px;
    }

    /* Card: giữ hình dáng, cho wrap chữ */
    .service-card {
        word-break: break-word;
        /* 🔧 đề phòng chuỗi dài */
    }

    /* Title: chỉ 2 dòng trên mobile để gọn */
    .service-title {
        -webkit-line-clamp: 2;
    }

    /* Description: clamp 2 dòng trên mobile + thấp hơn để đỡ cao */
    .service-description {
        -webkit-line-clamp: 2;
        max-height: 48px;
    }

    .service-description::after {
        height: 22px;
    }

    /* Khu nút xem thêm: đừng đè lên nội dung */
    .desc-actions {
        justify-content: flex-start;
        /* trái cho dễ chạm tay */
        margin-top: 2px;
    }

    /* Giá/CTA ghim đáy card, vẫn theo thiết kế gốc */
    .service-price {
        margin-top: auto;
    }

    /* Phân trang: tránh bó sát nhau gây tràn */
    .pagination {
        gap: 6px;
        flex-wrap: wrap;
    }
}

@media (min-width : 769px) {
    .service-description-container {
        height: auto;
    }

    /* Nếu bên trong KHÔNG có .expanded → đặt chiều cao cố định */
    .service-description-container:not(:has(.expanded)) {
        height: 88px;
    }
}

@media (min-width : 1200px) {
    .service-head {
        max-height: 108px;
    }
}



/* responsive */
@media (max-width:1023px) {
    .custom-modal-service .services-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: repeat(3, 1fr);
    }
}

/* Card là flex column, nội dung giãn ở giữa */
/* Giữ card equal-height như trước */
.custom-modal-service .services-grid {
    grid-auto-rows: 1fr;
}

/* Header KHÔNG giãn, có chiều cao tối thiểu đủ cho 2 dòng title */
.custom-modal-service .service-head {
    flex: 0 0 auto !important;
    padding: 10px 16px;
    /* 2 dòng * line-height + chút đệm (em-based để responsive) */
    min-height: calc(2 * 1.35em + 0.75rem);
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 8px;
    align-items: start;
}

/* Title đúng 2 dòng + ellipsis, không nhận thêm chiều cao */
.custom-modal-service .service-title {
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    min-width: 0;

    /* đảm bảo bằng nhau tuyệt đối giữa các card */
    max-height: calc(2 * 1.35em);
}

/* Phần thân được phép giãn khi Read more */
.custom-modal-service .service-content-body {
    flex: 1 1 auto !important;
}

.custom-modal-service .service-description-container {
    flex: 1 1 auto;
    min-height: 0;
}

.custom-modal-service .service-description {
    overflow: hidden;
    -webkit-line-clamp: 3;
    max-height: 72px;
    transition: max-height .25s ease;
}

.custom-modal-service .service-description.expanded {
    -webkit-line-clamp: unset;
    max-height: 9999px;
}

/* Chân card bám đáy */
.custom-modal-service .service-foot {
    margin-top: auto;
    flex: 0 0 auto;
}