/* ============================================================== */
/* CSS CHUẨN ĐỒNG BỘ 1280PX & FULL TRÀN VIỀN MOBILE KHÔNG LỖI    */
/* ============================================================== */

body {
    background-color: #f1f5f9 !important;
    overflow-x: hidden !important;
}

/* KHUNG CHUẨN 1280PX THẲNG HÀNG VỚI HEADER VÀ MENU */
.qbuilder-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 16px 0px;
    box-sizing: border-box;
    width: 100%;
    font-size: 16px;
    color: #334155;
    line-height: 1.6;
}

/* KHỐI BANNER TIÊU ĐỀ: NỀN SÁNG NHẸ, ĐỒNG BỘ 100% CHIỀU RỘNG */
.qbuilder-header-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px 28px;
    color: #0f172a;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
    box-sizing: border-box;
    width: 100%;
}

.qbuilder-header-card h1 {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0 0 6px;
    color: #0f172a;
    letter-spacing: -0.3px;
}

.qbuilder-header-card p {
    font-size: 15px;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
}

/* LƯỚI 2 CỘT CHUẨN TỶ LỆ */
.qbuilder-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 20px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

.qbuilder-left-col {
    min-width: 0;
    width: 100%;
}

.qbuilder-card-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px 22px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.02);
    margin-bottom: 20px;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
}

.qbuilder-box-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Ô TÌM KIẾM THEO TỪNG KHỐI */
.qb-search-input-wrap {
    position: relative;
    margin-bottom: 14px;
    width: 100%;
    box-sizing: border-box;
}
.qb-search-box {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14.5px;
    box-sizing: border-box;
    outline: none;
    background: #f8fafc;
    color: #0f172a;
    transition: all 0.15s ease;
}
.qb-search-box:focus {
    border-color: #0284c7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}
.qb-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

/* TAB DANH MỤC LINH KIỆN */
.qb-cat-tabs-strip {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    padding-bottom: 2px;
    width: 100%;
    box-sizing: border-box;
}
.qb-cat-tabs-strip::-webkit-scrollbar {
    display: none;
}
.qb-cat-pill-btn {
    padding: 7px 15px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13.5px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    flex-shrink: 0;
}
.qb-cat-pill-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.qb-cat-pill-btn.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

.qb-subhead-kicker {
    font-size: 13.5px;
    font-weight: 600;
    color: #64748b;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* LƯỚI SẢN PHẨM & CARD CHỐNG VỠ TRÀN */
.qb-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.qb-item-label {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}
.qb-item-label:hover {
    border-color: #0284c7;
    background: #f0f9ff;
}

.qb-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #e60012;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

.qb-thumb-box {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    padding: 3px;
    box-sizing: border-box;
}
.qb-thumb-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.qb-item-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.qb-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.qb-item-price {
    font-size: 13.5px;
    font-weight: 600;
    color: #e60012;
    white-space: nowrap;
}

/* CỘT PHẢI: BẢNG TẠM TÍNH */
.qbuilder-sticky-col {
    position: sticky;
    top: 90px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.invoice-preview-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.invoice-empty-text {
    color: #94a3b8;
    font-size: 14px;
    text-align: center;
    padding: 20px 0;
}
.invoice-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13.5px;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 8px;
    gap: 8px;
}
.invoice-total-strip {
    background: #fffafa;
    border: 1.5px dashed #fecaca;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.invoice-total-strip strong {
    font-size: 1.3rem;
    font-weight: 600;
    color: #e60012;
}

.qb-disclaimer-notice {
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.5;
    background: #f8fafc;
    border-left: 3px solid #0284c7;
    padding: 8px 10px;
    border-radius: 4px;
    margin-bottom: 16px;
}

/* THÔNG TIN KHÁCH HÀNG ĐỒNG BỘ */
.qb-user-synced-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 14px;
}
.qb-user-synced-row {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    margin-bottom: 6px;
    gap: 8px;
}
.qb-user-synced-row:last-child {
    margin-bottom: 0;
}
.qb-user-synced-row span {
    color: #64748b;
    flex-shrink: 0;
}
.qb-user-synced-row strong {
    color: #0f172a;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
    max-width: 65%;
}

.qb-form-group {
    margin-bottom: 12px;
}
.qb-form-label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 5px;
}
.qb-form-input,
.qb-form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    background: #fff;
    color: #0f172a;
}
.qb-form-input:focus,
.qb-form-textarea:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.btn-submit-quotation {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #e60012 0%, #b91c1c 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(230, 0, 18, 0.3);
    transition: all 0.2s;
}
.btn-submit-quotation:hover {
    background: #cc0010;
    transform: translateY(-1px);
}

/* POPUP THÀNH CÔNG */
.qb-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2600;
    padding: 16px;
    box-sizing: border-box;
}
.qb-modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: 18px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
}
.qb-modal-icon {
    width: 60px;
    height: 60px;
    background: #ecfdf5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: #059669;
}
.qb-modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 4px;
}
.qb-modal-desc {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 18px;
}
.qb-btn-zalo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px;
    background: #0068ff;
    color: #fff;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 10px;
    box-sizing: border-box;
    font-size: 14.5px;
}
.qb-btn-orders {
    width: 100%;
    padding: 11px;
    background: #0f172a;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

/* ============================================================== */
/* TỐI ƯU TOÀN DIỆN CHO DI ĐỘNG: TRÀN VIỀN 100%, 2 CỘT CHUẨN XÁC   */
/* ============================================================== */
@media (max-width: 860px) {
    .qbuilder-wrapper {
        padding: 0 0 0px 0 !important;
        font-size: 14px !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .qbuilder-header-card,
    .qbuilder-card-box {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        margin-bottom: 12px !important;
        padding: 16px 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .qbuilder-header-card h1 {
        font-size: 1.35rem !important;
    }

    .qbuilder-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        width: 100% !important;
    }

    .qbuilder-sticky-col {
        position: static !important;
        width: 100% !important;
    }

    /* BẮT BUỘC 2 CỘT GỌN GÀNG TRÊN MOBILE */
    .qb-items-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .qb-item-label {
        padding: 8px 6px !important;
        gap: 6px !important;
        border-radius: 8px !important;
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .qb-thumb-box {
        width: 36px !important;
        height: 36px !important;
        border-radius: 6px !important;
        padding: 2px !important;
    }

    .qb-item-name {
        font-size: 12.5px !important;
        line-height: 1.3 !important;
    }

    .qb-item-price {
        font-size: 12px !important;
    }

    .qb-checkbox {
        width: 16px !important;
        height: 16px !important;
    }

    .qb-user-synced-row strong {
        max-width: 60% !important;
        font-size: 13px !important;
    }
}
/* ============================================================== */
/* NÚT XUẤT FILE & MẪU PHIẾU BÁO GIÁ MINH HOÀNG (HÌNH 2)        */
/* ============================================================== */

/* NÚT XUẤT FILE BÁO GIÁ TRÊN GIAO DIỆN */
.btn-export-quote-trigger {
    width: 100%;
    padding: 12px;
    background: #ffffff;
    border: 1.5px solid #0284c7;
    color: #0284c7;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    transition: all 0.2s ease;
}
.btn-export-quote-trigger:hover {
    background: #eff6ff;
}

/* KHUNG PHIẾU BÁO GIÁ KHI IN HOẶC XUẤT ẢNH / PDF (A4 CHUẨN ĐỒNG BỘ HÌNH 2) */
#quotePrintTemplate {
    background: #ffffff;
    width: 800px;
    padding: 32px 36px;
    margin: 0 auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #0f172a;
    box-sizing: border-box;
    display: none; /* Chỉ hiện trong DOM tạm thời để render */
}

.qp-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 2px solid #e60012;
}
.qp-brand-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.qp-logo-img {
    height: 52px;
    width: auto;
    object-fit: contain;
}
.qp-brand-text h3 {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    color: #e60012;
    text-transform: uppercase;
}
.qp-brand-text p {
    margin: 0;
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
}
.qp-meta-right {
    text-align: right;
}
.qp-meta-right h2 {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 600;
    color: #0f172a;
    text-transform: uppercase;
}
.qp-meta-code {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 2px;
}
.qp-meta-code strong {
    color: #0284c7;
    font-weight: 600;
}
.qp-meta-date {
    font-size: 13px;
    color: #64748b;
}

/* THÔNG TIN KHÁCH HÀNG */
.qp-customer-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 18px;
    margin: 18px 0;
    font-size: 14px;
}
.qp-cust-row {
    display: flex;
    margin-bottom: 6px;
}
.qp-cust-row:last-child {
    margin-bottom: 0;
}
.qp-cust-lbl {
    width: 140px;
    color: #64748b;
    flex-shrink: 0;
}
.qp-cust-val {
    color: #0f172a;
    font-weight: 600;
    flex: 1;
}

/* BẢNG HẠNG MỤC BÁO GIÁ */
.qp-table-wrap {
    width: 100%;
    margin-bottom: 16px;
}
.qp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.qp-table th {
    background: #f1f5f9;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    font-weight: 600;
    text-align: left;
}
.qp-table td {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    color: #334155;
}
.qp-table td.col-center {
    text-align: center;
}
.qp-table td.col-right {
    text-align: right;
}

/* TỔNG TIỀN */
.qp-total-box {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}
.qp-total-card {
    width: 320px;
    background: #fffafa;
    border: 1.5px dashed #fecaca;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.qp-total-card span {
    font-weight: 600;
    color: #475569;
    font-size: 14.5px;
}
.qp-total-card strong {
    font-size: 17px;
    color: #e60012;
    font-weight: 600;
}

/* LƯU Ý & CHỮ KÝ */
.qp-notes-box {
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.5;
    background: #f8fafc;
    border-left: 3px solid #0284c7;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 30px;
}
.qp-signatures-row {
    display: flex;
    justify-content: space-between;
    text-align: center;
    padding: 0 40px;
}
.qp-sign-col strong {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    display: block;
    margin-bottom: 4px;
}
.qp-sign-col span {
    font-size: 12.5px;
    color: #94a3b8;
    display: block;
    margin-bottom: 60px;
}

/* POPUP LỰA CHỌN ĐỊNH DẠNG XUẤT FILE */
.modal-export-choice-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0 10px;
}
.btn-export-option-card {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-export-option-card:hover {
    border-color: #0284c7;
    background: #eff6ff;
    transform: translateY(-2px);
}
.btn-export-option-card svg {
    color: #0284c7;
}
.btn-export-option-card strong {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}
.btn-export-option-card span {
    font-size: 12px;
    color: #64748b;
}

/* NÚT VÀ CẢNH BÁO BỔ SUNG ĐỊA CHỈ TRONG KHUNG KHÁCH HÀNG */
.qb-addr-missing-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #fffbeb;
    border: 1px dashed #f59e0b;
    border-radius: 8px;
    padding: 6px 10px;
    margin-top: 4px;
}
.qb-addr-missing-notice span {
    font-size: 12.5px;
    color: #b45309;
    font-weight: 500;
}
.btn-quick-add-addr {
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.btn-quick-add-addr:hover {
    background: #0369a1;
}

/* POPUP THÊM ĐỊA CHỈ */
.qb-addr-modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    text-align: left;
}
.qb-addr-modal-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}
.qb-addr-modal-card p {
    margin: 0 0 16px;
    font-size: 13.5px;
    color: #64748b;
    line-height: 1.4;
}
