/* ==========================================================================
   tools.css — kiểu riêng cho tiện ích (SPEC mục 2/8). Chỉ nạp ở trang có tiện ích.
   Mọi selector đều có tiền tố .tool- để không đụng main.css; biến màu lấy từ :root của
   main.css, có fallback để partial vẫn đúng màu khi main.css chưa nạp xong.
   Mobile-first, breakpoint 640 / 900.
   ========================================================================== */

/* ---------------------------------------------------------------- trang & khối chung */
.tool-page__head { margin-bottom: 1.5rem; }
.tool-page__intro { margin-top: 2.5rem; }

.tool-note {
    margin-top: 1.25rem;
    font-size: .875rem;
    color: var(--muted, #64748B);
}
.tool-note a { color: var(--brand-blue, #0066AE); }

.tool-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.tool-badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: var(--surface-3, #E9EFF6);
    color: var(--ink-2, #33475B);
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.tool-badge--accent { background: rgba(245, 166, 35, .18); color: var(--brand-accent-dark, #D98C0F); margin-left: .4rem; }

.tool-alert {
    margin: 1rem 0 1.5rem;
    padding: .85rem 1rem;
    border-radius: var(--radius, 10px);
    border: 1px solid var(--line, #E2E8F0);
    background: var(--surface-2, #F4F7FB);
    font-size: .95rem;
}
.tool-alert--error { border-color: rgba(220, 38, 38, .35); background: #FEF2F2; color: #991B1B; }

/* ---------------------------------------------------------------- CTA cuối trang */
.tool-cta {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2.5rem;
    padding: 1.5rem;
    border-radius: var(--radius-lg, 16px);
    background: var(--surface-2, #F4F7FB);
    border: 1px solid var(--line, #E2E8F0);
}
.tool-cta__text { margin: 0; font-weight: 500; color: var(--ink, #0F1F33); }
.tool-cta__actions { display: flex; flex-wrap: wrap; gap: .75rem; }
@media (min-width: 900px) {
    .tool-cta { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ---------------------------------------------------------------- thẻ tiện ích (hub) */
.tool-cards {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}
@media (min-width: 640px) { .tool-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .tool-cards { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; } }

.tool-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    height: 100%;
    padding: 1.25rem;
    border-radius: var(--radius-lg, 16px);
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--line, #E2E8F0);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(11, 37, 69, .06));
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tool-card:hover,
.tool-card:focus-visible {
    transform: translateY(-2px);
    border-color: var(--brand-blue-light, #2E8FD8);
    box-shadow: var(--shadow, 0 4px 16px rgba(11, 37, 69, .08));
    outline: none;
}
.tool-card__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 12px;
    background: rgba(0, 102, 174, .1);
    color: var(--brand-blue, #0066AE);
    font-size: 1.5rem;
}
.tool-card__body { display: flex; flex-direction: column; gap: .3rem; flex: 1 1 auto; min-width: 0; }
.tool-card__title { font-weight: 700; color: var(--ink, #0F1F33); font-size: 1.05rem; }
.tool-card__desc { font-size: .9rem; color: var(--muted, #64748B); line-height: 1.5; }
.tool-card__arrow { align-self: center; color: var(--brand-accent, #F5A623); font-size: 1.1rem; }

/* ---------------------------------------------------------------- khối công cụ JS (container, USD) */
.tool-embed { margin: 1.5rem 0 2rem; }

.tool {
    padding: 1.25rem;
    border-radius: var(--radius-lg, 16px);
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--line, #E2E8F0);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(11, 37, 69, .06));
}
@media (min-width: 640px) { .tool { padding: 1.75rem; } }

.tool__block + .tool__block { margin-top: 2rem; padding-top: 1.75rem; border-top: 1px solid var(--line, #E2E8F0); }
.tool__title { margin: 0 0 .75rem; font-size: 1.2rem; font-weight: 700; color: var(--brand-blue, #0066AE); }
.tool__subtitle { margin: 1.25rem 0 .5rem; font-size: 1rem; font-weight: 700; color: var(--ink, #0F1F33); }
.tool__text { margin: 0 0 .75rem; color: var(--ink-2, #33475B); line-height: 1.6; }
.tool__row { margin-top: 1rem; }
.tool__label { display: block; margin-bottom: .4rem; font-weight: 600; font-size: .925rem; color: var(--ink, #0F1F33); }
.tool__inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.tool__inline .tool__input { flex: 1 1 12rem; margin: 0; }

.tool__input,
.tool-form__input,
.tool-search__input,
.tool-filter__select {
    width: 100%;
    padding: .65rem .85rem;
    border: 1px solid var(--line, #E2E8F0);
    border-radius: var(--radius, 10px);
    background: var(--surface, #FFFFFF);
    color: var(--ink, #0F1F33);
    font: inherit;
    font-size: 1rem;
    line-height: 1.4;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.tool__input:focus,
.tool-form__input:focus,
.tool-search__input:focus,
.tool-filter__select:focus {
    outline: none;
    border-color: var(--brand-blue, #0066AE);
    box-shadow: 0 0 0 3px rgba(245, 166, 35, .35);
}
.tool__input--code { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; max-width: 16rem; }
.tool__input--amount { max-width: 20rem; font-weight: 600; }
.tool__textarea { min-height: 6rem; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-transform: uppercase; }

.tool__fieldset { margin: 1rem 0 0; padding: 0; border: 0; min-width: 0; }
.tool__radios,
.tool-form__radios { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.tool__radio,
.tool-form__radio { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .95rem; }
.tool__radio input,
.tool-form__radio input { accent-color: var(--brand-blue, #0066AE); width: 1rem; height: 1rem; }

/* kết quả kiểm tra 1 số */
.tool__result { margin-top: .75rem; font-size: .95rem; line-height: 1.6; }
.tool__result:empty { display: none; }
.tool__result p { margin: 0; }
.tool__result strong { font-weight: 700; letter-spacing: .04em; }
.tool__result--ok { padding: .75rem 1rem; border-radius: var(--radius, 10px); background: #F0FDF4; border: 1px solid rgba(22, 163, 74, .35); color: #166534; }
.tool__result--error { padding: .75rem 1rem; border-radius: var(--radius, 10px); background: #FEF2F2; border: 1px solid rgba(220, 38, 38, .35); color: #991B1B; }

/* kết quả nhiều số */
.tool__list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.tool__item {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
    padding: .5rem .75rem; border-radius: 8px; font-size: .925rem; line-height: 1.4;
}
.tool__item strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .05em; }
.tool__item--ok { background: #F0FDF4; color: #166534; }
.tool__item--error { background: #FEF2F2; color: #991B1B; }
.tool__item .bi { font-size: 1rem; }

/* USD → chữ */
.tool__words {
    min-height: 3.25rem;
    padding: .85rem 1rem;
    border-radius: var(--radius, 10px);
    background: var(--surface-2, #F4F7FB);
    border: 1px dashed var(--line, #E2E8F0);
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--ink, #0F1F33);
    word-break: break-word;
}
.tool__words-text { font-weight: 600; color: var(--brand-blue-dark, #004E86); }
.tool__placeholder { color: var(--muted, #64748B); font-style: italic; }
.tool--usd [data-role="uw-copy"] { margin-top: .6rem; }

/* ---------------------------------------------------------------- form báo giá */
.tool-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem 1.25rem;
    padding: 1.25rem;
    border-radius: var(--radius-lg, 16px);
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--line, #E2E8F0);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(11, 37, 69, .06));
}
@media (min-width: 640px) { .tool-form { padding: 1.75rem; } }
@media (min-width: 900px) {
    .tool-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tool-form__span { grid-column: 1 / -1; }
}
.tool-form__head { grid-column: 1 / -1; }
.tool-form__title { margin: 0 0 .35rem; font-size: 1.25rem; font-weight: 700; color: var(--brand-blue, #0066AE); }
.tool-form__desc { margin: 0; font-size: .925rem; color: var(--muted, #64748B); line-height: 1.5; }

.tool-form__field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.tool-form__label { display: block; font-weight: 600; font-size: .9rem; color: var(--ink, #0F1F33); }
.tool-form__req { color: var(--danger, #DC2626); }
.tool-form__fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: .5rem; }

.tool-form__containers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }

/* honeypot: đẩy khỏi màn hình thay vì display:none để bot vẫn thấy input "bình thường" */
.tool-form__hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.tool-form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.tool-form__hotline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--brand-blue, #0066AE); text-decoration: none; }
.tool-form__hotline:hover { text-decoration: underline; }
.tool-form__submit.is-busy { opacity: .7; cursor: progress; }

.tool-form__feedback {
    display: flex; align-items: flex-start; gap: .5rem; flex-wrap: wrap;
    padding: .75rem 1rem; border-radius: var(--radius, 10px); font-size: .95rem; line-height: 1.5;
}
.tool-form__feedback[hidden] { display: none; }
.tool-form__feedback--ok { background: #F0FDF4; border: 1px solid rgba(22, 163, 74, .35); color: #166534; }
.tool-form__feedback--error { background: #FEF2F2; border: 1px solid rgba(220, 38, 38, .35); color: #991B1B; }
.tool-form__feedback .bi { font-size: 1.1rem; line-height: 1.4; }
.tool-form__errors { flex-basis: 100%; margin: .25rem 0 0; padding-left: 1.5rem; }

/* ---------------------------------------------------------------- autocomplete cảng */
.tool-form__combo { position: relative; }
.tool-suggest {
    position: absolute;
    z-index: 30;
    left: 0; right: 0; top: 100%;
    margin: .25rem 0 0;
    padding: .25rem 0;
    list-style: none;
    max-height: 18rem;
    overflow-y: auto;
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--line, #E2E8F0);
    border-radius: var(--radius, 10px);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(11, 37, 69, .14));
}
.tool-suggest[hidden] { display: none; }
.tool-suggest__item {
    display: flex; flex-direction: column; gap: .1rem;
    padding: .55rem .85rem; cursor: pointer; font-size: .925rem; line-height: 1.4;
}
.tool-suggest__item:hover,
.tool-suggest__item.is-active { background: rgba(0, 102, 174, .08); }
.tool-suggest__item[aria-selected="true"] { background: rgba(0, 102, 174, .12); }
.tool-suggest__name { font-weight: 600; color: var(--ink, #0F1F33); }
.tool-suggest__meta { display: flex; gap: .5rem; font-size: .8rem; color: var(--muted, #64748B); }
.tool-suggest__kind { padding: 0 .4rem; border-radius: 999px; background: var(--surface-3, #E9EFF6); }
.tool-suggest__empty { padding: .6rem .85rem; font-size: .875rem; color: var(--muted, #64748B); font-style: italic; }

/* ---------------------------------------------------------------- tab báo giá (trang chủ) */
.qtabs__nav { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.qtabs__tab {
    padding: .6rem 1.1rem; border-radius: 999px; border: 1px solid var(--line, #E2E8F0);
    background: var(--surface, #FFFFFF); color: var(--ink-2, #33475B); font: inherit; font-weight: 600; cursor: pointer;
}
.qtabs__tab.is-active { background: var(--brand-blue, #0066AE); border-color: var(--brand-blue, #0066AE); color: #fff; }
.qtabs__tab:focus-visible { outline: 3px solid rgba(245, 166, 35, .5); outline-offset: 2px; }
.qtabs__panel[hidden] { display: none; }

/* ---------------------------------------------------------------- bộ lọc tỉnh + tra cứu MST */
.tool-filter {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
    margin-bottom: 1rem; padding: .9rem 1rem;
    border-radius: var(--radius, 10px); background: var(--surface-2, #F4F7FB); border: 1px solid var(--line, #E2E8F0);
}
.tool-filter__label { font-weight: 600; font-size: .925rem; }
.tool-filter__select { width: auto; min-width: 14rem; flex: 1 1 14rem; max-width: 22rem; }
.tool-filter__count { font-size: .875rem; color: var(--muted, #64748B); margin-left: auto; }

.tool-search { margin-bottom: 1.25rem; }
.tool-search__label { display: block; margin-bottom: .4rem; font-weight: 600; font-size: .925rem; }
.tool-search__row { display: flex; flex-wrap: wrap; gap: .5rem; }
.tool-search__input { flex: 1 1 16rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .05em; }

/* ---------------------------------------------------------------- bảng doanh nghiệp */
.tool-table__wrap {
    border: 1px solid var(--line, #E2E8F0);
    border-radius: var(--radius, 10px);
    background: var(--surface, #FFFFFF);
    overflow: hidden;
}
.tool-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tool-table th,
.tool-table td { padding: .7rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line, #E2E8F0); }
/* nowrap: cột SĐT/Email hay rỗng nên cột co rất hẹp, tiêu đề bị bẻ từng chữ cái */
.tool-table thead th { background: var(--surface-2, #F4F7FB); font-weight: 700; color: var(--ink, #0F1F33); font-size: .825rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.tool-table tbody tr:last-child td { border-bottom: 0; }
.tool-table tbody tr:hover td { background: rgba(0, 102, 174, .035); }
.tool-table__name { display: block; font-weight: 700; color: var(--brand-blue, #0066AE); text-decoration: none; }
.tool-table__name:hover { text-decoration: underline; }
.tool-table__addr { display: block; margin-top: .25rem; font-size: .825rem; color: var(--muted, #64748B); line-height: 1.45; }
.tool-table__company .tool-badge { margin-top: .3rem; }
.tool-table__date { white-space: nowrap; }
.tool-table__phone,
.tool-table__email { word-break: break-all; }
.tool-table__act { text-align: right; white-space: nowrap; }
.tool-table__empty { text-align: center; padding: 2rem 1rem; color: var(--muted, #64748B); }
.tool-table__code { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tool-table--industries tr.is-main td { background: rgba(245, 166, 35, .08); }

/* mobile: mỗi dòng thành một thẻ, ô có nhãn từ data-label */
@media (max-width: 899px) {
    .tool-table thead { display: none; }
    .tool-table,
    .tool-table tbody,
    .tool-table tr,
    .tool-table td { display: block; width: 100%; }
    .tool-table tr { padding: .5rem 0; border-bottom: 1px solid var(--line, #E2E8F0); }
    .tool-table tr:last-child { border-bottom: 0; }
    .tool-table td { border: 0; padding: .3rem .9rem; }
    .tool-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--muted, #64748B);
        font-size: .8rem;
    }
    .tool-table td.tool-table__company::before { content: none; }
    .tool-table td.tool-table__act { text-align: left; padding-bottom: .6rem; }
    .tool-table td:empty { display: none; }
}

/* ---------------------------------------------------------------- pager */
.tool-pager { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; margin-top: 1.5rem; }
.tool-pager__link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2.4rem; height: 2.4rem; padding: 0 .6rem;
    border: 1px solid var(--line, #E2E8F0); border-radius: 8px;
    background: var(--surface, #FFFFFF); color: var(--ink-2, #33475B);
    font-weight: 600; font-size: .925rem; text-decoration: none;
}
.tool-pager__link:hover { border-color: var(--brand-blue, #0066AE); color: var(--brand-blue, #0066AE); }
.tool-pager__link.is-current { background: var(--brand-blue, #0066AE); border-color: var(--brand-blue, #0066AE); color: #fff; }
.tool-pager__dots { display: inline-flex; align-items: center; padding: 0 .3rem; color: var(--muted, #64748B); }

/* ---------------------------------------------------------------- chi tiết doanh nghiệp */
.tool-company { margin-top: 1.5rem; }
.tool-company__title { margin: 1.5rem 0 .75rem; font-size: 1.15rem; font-weight: 700; color: var(--brand-blue, #0066AE); }
.tool-company__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin: 0;
    border: 1px solid var(--line, #E2E8F0);
    border-radius: var(--radius, 10px);
    overflow: hidden;
    background: var(--surface, #FFFFFF);
}
.tool-company__grid dt,
.tool-company__grid dd { margin: 0; padding: .65rem .9rem; border-bottom: 1px solid var(--line, #E2E8F0); }
.tool-company__grid dt { background: var(--surface-2, #F4F7FB); font-weight: 600; font-size: .85rem; color: var(--ink-2, #33475B); padding-bottom: .2rem; border-bottom: 0; }
.tool-company__grid dd { font-size: .975rem; color: var(--ink, #0F1F33); word-break: break-word; }
.tool-company__grid dd:last-child { border-bottom: 0; }
@media (min-width: 640px) {
    .tool-company__grid { grid-template-columns: 14rem 1fr; }
    .tool-company__grid dt { padding: .7rem .9rem; border-bottom: 1px solid var(--line, #E2E8F0); }
    .tool-company__grid dt:nth-last-of-type(1) { border-bottom: 0; }
}

/* ---------------------------------------------------------------- TOP SHIPPING: biến thể form */
.tool-form__title { color: var(--brand-navy, #1F425D); }
.tool-form__privacy { margin: -.25rem 0 0; font-size: .8rem; color: var(--muted, #66788A); line-height: 1.45; }
.tool-form__privacy a { color: inherit; text-decoration: underline; }
.tool-form__radios { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.tool-form__radio { display: inline-flex; align-items: center; gap: .45rem; font-size: .93rem; cursor: pointer; }
.tool-form__radio input { width: 18px; height: 18px; accent-color: var(--brand-blue, #0A7FA8); }

/* Bản gọn (hero landing, modal): một cột, nút gửi rộng hết, ô nhập cao hơn để chạm dễ trên mobile. */
.tool-form--compact { grid-template-columns: 1fr !important; gap: .8rem; }
.tool-form--compact .tool-form__span { grid-column: auto; }
.tool-form--compact .tool-form__actions { flex-direction: column; align-items: stretch; gap: .6rem; }
.tool-form--compact .tool-form__submit { width: 100%; }
.tool-form--compact .tool-form__hotline { justify-content: center; }
.tool-form--compact .tool-form__input { min-height: 46px; }
.qtabs--modal { box-shadow: none; border: 0; }
.qtabs--modal .qtabs__panel { padding: .75rem 0 0; }
.qtabs--modal .tool-form { border: 0; box-shadow: none; padding: 0; }
