/* ========== Dự toán chi phí — Toyota-inspired ========== */
.cost-page {
    background: #fff;
    padding: 40px 0 72px;
}

.cost-page__header {
    text-align: center;
    margin-bottom: 40px;
}

.cost-page__title {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #1a1a1a;
    line-height: 1.25;
}

.cost-page__section-title {
    margin: 0 0 28px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #1a1a1a;
    line-height: 1.3;
}

.cost-page__layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 40px 48px;
    align-items: start;
}

/* ----- Config (left) ----- */
.cost-fields {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cost-field {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    min-height: 56px;
    border-bottom: 1px solid #e5e5e5;
}

.cost-field label {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    line-height: 1.35;
}

.cost-field label em {
    color: #eb0a1e;
    font-style: normal;
    margin-left: 2px;
}

.cost-field__control {
    position: relative;
    min-width: 0;
}

.cost-field__control::after {
    content: "";
    position: absolute;
    right: 4px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid #666;
    border-bottom: 1.5px solid #666;
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.cost-field__control select {
    width: 100%;
    height: 48px;
    border: 0;
    background: transparent;
    padding: 0 28px 0 0;
    font-size: 15px;
    color: #1a1a1a;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.cost-field__control select:disabled {
    color: #aaa;
    cursor: not-allowed;
}

.cost-field__control select:focus {
    color: #eb0a1e;
}

/* Tom Select */
.cost-field__control--tom .ts-wrapper {
    width: 100%;
}

.cost-field__control--tom .ts-control {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 28px 0 0 !important;
    min-height: 48px !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    overflow: hidden;
}

.cost-field__control--tom .ts-control > div,
.cost-field__control--tom .ts-control .item {
    display: flex !important;
    align-items: center !important;
    font-size: 15px;
    line-height: 1.3 !important;
    color: #1a1a1a;
    padding: 0 !important;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    height: 48px;
}

/* Đã chọn: ẩn hẳn input search (tránh con trỏ lệch) */
.cost-field__control--tom .ts-wrapper.single.has-items:not(.dropdown-active) .ts-control input {
    position: absolute !important;
    left: -9999px !important;
    top: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    width: 1px !important;
    min-width: 0 !important;
    height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
}

/* Đang mở: ẩn item, hiện ô gõ */
.cost-field__control--tom .ts-wrapper.single.dropdown-active .ts-control .item {
    display: none !important;
}

.cost-field__control--tom .ts-wrapper.single.dropdown-active .ts-control input {
    position: static !important;
    left: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    width: 100% !important;
    min-width: 4rem !important;
    height: 48px !important;
    line-height: 48px !important;
    font-size: 15px !important;
    flex: 1 1 auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.cost-field__control--tom .ts-wrapper.single:not(.has-items) .ts-control input {
    height: 48px !important;
    line-height: 48px !important;
    font-size: 15px !important;
}

.cost-field__control--tom .ts-wrapper.disabled {
    opacity: 0.55;
}

.cost-field__control--tom .ts-dropdown {
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    z-index: 60;
}

.cost-field__control--tom .ts-dropdown .option {
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
}

.cost-field__control--tom .ts-dropdown .option.active {
    background: #fff5f5;
}

.cost-field__control--tom .ts-wrapper.single .ts-control::after {
    display: none;
}

.cost-ts-item,
.cost-ts-option {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px;
    height: 100%;
    max-width: 100%;
}

.cost-ts-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.cost-ts-item-text,
.cost-ts-name {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cost-ts-price {
    margin-left: auto;
    font-size: 12px;
    color: #eb0a1e;
    font-weight: 700;
    flex-shrink: 0;
}

.cost-preview {
    margin-top: 28px;
}

.cost-preview__image-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cost-preview__image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.25s ease;
}

.cost-preview__image-wrap.is-empty img {
    opacity: 0.15;
}

.cost-preview__placeholder {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #888;
    pointer-events: none;
    padding: 16px;
    text-align: center;
}

.cost-preview__image-wrap.is-empty .cost-preview__placeholder {
    display: flex;
}

.cost-preview__meta {
    padding: 18px 8px 0;
    text-align: center;
}

.cost-preview__name {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cost-preview__color {
    margin: 0 0 8px;
    font-size: 14px;
    color: #666;
}

.cost-preview__price {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #eb0a1e;
}

/* ----- Result card (right) ----- */
.cost-result {
    background: #fff;
    border: 1px solid #ececec;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.06);
    padding: 28px 28px 32px;
    position: sticky;
    top: 88px;
}

.cost-result .cost-page__section-title {
    margin-bottom: 20px;
    font-size: 18px;
}

.cost-table {
    border-top: 1px solid #ececec;
}

.cost-table__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #444;
    line-height: 1.4;
}

.cost-table__row strong {
    font-weight: 700;
    color: #1a1a1a;
    white-space: nowrap;
    font-size: 15px;
}

.cost-total {
    margin-top: 20px;
    padding: 16px 18px;
    background: #fff5f5;
    border-left: 4px solid #eb0a1e;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cost-total__label {
    font-size: 13px;
    font-weight: 600;
    color: #eb0a1e;
}

.cost-total__value {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.cost-page__note {
    margin: 16px 0 0;
    font-size: 12px;
    line-height: 1.55;
    color: #777;
}

.cost-page__actions {
    margin-top: 22px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.cost-page__btn {
    height: 48px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cost-page__btn--primary {
    background: #eb0a1e;
    border: 2px solid #eb0a1e;
    color: #fff;
}

.cost-page__btn--primary:hover {
    background: #c40818;
    border-color: #c40818;
    color: #fff;
}

.cost-page__btn--ghost {
    background: #fff;
    border: 2px solid #eb0a1e;
    color: #eb0a1e;
}

.cost-page__btn--ghost:hover {
    background: #eb0a1e;
    color: #fff;
}

/* Sticky mobile bar */
.cost-sticky {
    display: none;
}

@media (max-width: 1023px) {
    .cost-page {
        padding: 28px 0 96px;
    }

    .cost-page__title {
        font-size: 26px;
    }

    .cost-page__layout {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .cost-field {
        grid-template-columns: 140px minmax(0, 1fr);
        gap: 12px;
    }

    .cost-result {
        position: static;
        padding: 22px 20px 24px;
    }

    .cost-total__value {
        font-size: 24px;
    }
}

@media (max-width: 767px) {
    .cost-field__control--tom .ts-control {
        min-height: 40px;
    }

    .cost-page {
        padding: 20px 0 100px;
    }

    .cost-page__header {
        margin-bottom: 24px;
        text-align: left;
    }

    .cost-page__title {
        font-size: 22px;
        letter-spacing: 0.02em;
    }

    .cost-page__section-title {
        font-size: 16px;
        margin-bottom: 18px;
    }

    .cost-field {
        grid-template-columns: 1fr;
        gap: 2px;
        min-height: 0;
        padding: 12px 0 6px;
        align-items: stretch;
    }

    .cost-field label {
        font-size: 13px;
        font-weight: 600;
        color: #666;
    }

    .cost-field__control select {
        height: 40px;
        font-size: 15px;
        font-weight: 500;
    }

    .cost-preview {
        margin-top: 20px;
    }

    .cost-preview__image-wrap {
        aspect-ratio: 4 / 3;
        border-radius: 0;
    }

    .cost-preview__name {
        font-size: 17px;
    }

    .cost-preview__price {
        font-size: 20px;
    }

    .cost-result {
        padding: 18px 16px 20px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
    }

    .cost-table__row {
        padding: 12px 0;
        font-size: 13px;
        gap: 12px;
    }

    .cost-table__row strong {
        font-size: 14px;
    }

    .cost-total {
        padding: 14px 14px;
    }

    .cost-total__value {
        font-size: 22px;
    }

    .cost-page__actions {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .cost-page__btn {
        height: 46px;
        width: 100%;
    }

    /* Sticky bar */
    .cost-sticky {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        background: #fff;
        border-top: 1px solid #e8e8e8;
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .cost-sticky[hidden] {
        display: none !important;
    }

    .cost-sticky__inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        max-width: 720px;
        margin: 0 auto;
    }

    .cost-sticky__label {
        display: block;
        font-size: 11px;
        color: #777;
        line-height: 1.2;
    }

    .cost-sticky__value {
        display: block;
        font-size: 18px;
        font-weight: 700;
        color: #eb0a1e;
        line-height: 1.2;
    }

    .cost-sticky__btn {
        flex-shrink: 0;
        height: 42px;
        padding: 0 18px;
        background: #eb0a1e;
        color: #fff;
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .cost-page__header {
        text-align: center;
    }

    .cost-field {
        grid-template-columns: 160px minmax(0, 1fr);
    }

    .cost-page__actions {
        grid-template-columns: 1fr 1fr;
    }
}
