/* 線上估價單頁樣式 */

.estimate-page {
    max-width: 1740px;
}

.estimate-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
    padding: 0 4px;
}

.estimate-heading h1 {
    margin: 0;
    color: #20364f;
    font-size: 1.65rem;
    font-weight: 800;
}

.estimate-intro {
    max-width: 760px;
    margin: 0;
    color: #657080;
    font-size: 0.92rem;
    text-align: right;
}

/* 選配列：密集估價表、左側分類色塊、寬下拉選單 */
.estimate-list {
    overflow: hidden;
    border: 1px solid #8fa4bb;
    background: #fff;
    box-shadow: 0 2px 8px rgba(22, 42, 64, 0.06);
}

.estimate-list-head {
    display: grid;
    grid-template-columns: 172px minmax(0, 1fr) 208px;
    min-height: 34px;
    border-bottom: 1px solid #8298b0;
    background: #223d5f;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 700;
}

.estimate-list-head span {
    display: flex;
    align-items: center;
    padding: 7px 10px;
}

.estimate-head-type,
.estimate-head-select {
    border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.estimate-head-meta {
    justify-content: flex-end;
}

.estimate-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #c3d0df;
    background: #fff;
}

.estimate-row:last-child {
    border-bottom: 0;
}

.estimate-row:nth-child(odd) {
    background: #f7fafd;
}

.estimate-row-label {
    flex: 0 0 172px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-right: 1px solid #dfc96e;
    background: #fff4be;
    color: #5f4b00;
}

.estimate-row-no {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border: 1px solid #b78900;
    border-radius: 3px;
    background: #d8a700;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 22px;
    text-align: center;
}

.estimate-type-name {
    color: #5f4b00;
    font-size: 0.93rem;
    font-weight: 800;
    line-height: 1.22;
}

.estimate-row-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 8px;
}

.estimate-line {
    margin-bottom: 6px;
}

.estimate-line:last-child {
    margin-bottom: 0;
}

.estimate-line-body {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 92px 54px 94px 34px;
    gap: 6px;
    align-items: center;
}

.estimate-select,
.estimate-qty,
.estimate-filter-panel input {
    border: 1px solid #8398af;
    border-radius: 2px;
    background: #fff;
    color: #153453;
}

.estimate-select {
    width: 100%;
    min-width: 0;
    height: 36px;
    padding: 4px 38px 4px 12px;
    font-family: "Consolas", "Menlo", "Courier New", "Noto Sans Mono CJK TC", monospace;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
    appearance: none;
    background:
        linear-gradient(45deg, transparent 50%, #20364f 50%),
        linear-gradient(135deg, #20364f 50%, transparent 50%),
        linear-gradient(135deg, #f8fbff 0%, #fff 100%);
    background-position:
        calc(100% - 19px) 50%,
        calc(100% - 13px) 50%,
        0 0;
    background-size:
        6px 6px,
        6px 6px,
        100% 100%;
    background-repeat: no-repeat;
    border-color: #6f89a5;
    border-radius: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(22, 42, 64, 0.06);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.estimate-select:hover {
    border-color: #315f8f;
    background-color: #f8fbff;
}

.estimate-select:focus,
.estimate-qty:focus,
.estimate-filter-panel input:focus {
    outline: none;
    border-color: #275c94;
    box-shadow: 0 0 0 2px rgba(39, 92, 148, 0.16);
}

.estimate-select option {
    min-height: 34px;
    padding: 9px 12px;
    color: #24384f;
    background: #fff;
    font-family: "Noto Sans TC", "Microsoft JhengHei", "Consolas", "Menlo", sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.7;
}

.estimate-select option[value=""] {
    color: #728096;
    background: #f4f7fb;
    font-weight: 800;
}

.estimate-select option:checked {
    color: #fff;
    background: linear-gradient(135deg, #20364f, #315f8f);
    font-weight: 800;
}

.estimate-select option:hover {
    color: #13283d;
    background: #eef4fa;
}

.estimate-select optgroup {
    color: #fff;
    background: #20364f;
    font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 2;
}

.estimate-select optgroup option {
    color: #24384f;
    background: #fff;
    font-weight: 600;
}

/* ===== 自訂下拉：保留原生 select 為資料來源（隱藏），另建可自訂樣式的視覺下拉， */
/*        以解決 Chrome 無法變更原生 optgroup 分類標題顏色的限制 ===== */
.estimate-select.is-enhanced {
    display: none;
}

.estimate-dd {
    position: relative;
    width: 100%;
    min-width: 0;
}

.estimate-dd-toggle {
    display: block;
    width: 100%;
    height: 36px;
    padding: 4px 38px 4px 12px;
    text-align: left;
    color: #153453;
    font-family: "Consolas", "Menlo", "Courier New", "Noto Sans Mono CJK TC", monospace;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
    border: 1px solid #6f89a5;
    border-radius: 4px;
    background:
        linear-gradient(45deg, transparent 50%, #20364f 50%),
        linear-gradient(135deg, #20364f 50%, transparent 50%),
        linear-gradient(135deg, #f8fbff 0%, #fff 100%);
    background-position:
        calc(100% - 19px) 50%,
        calc(100% - 13px) 50%,
        0 0;
    background-size: 6px 6px, 6px 6px, 100% 100%;
    background-repeat: no-repeat;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(22, 42, 64, 0.06);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.estimate-dd-toggle:hover {
    border-color: #315f8f;
    background-color: #f8fbff;
}

.estimate-dd.is-open .estimate-dd-toggle {
    border-color: #275c94;
    box-shadow: 0 0 0 2px rgba(39, 92, 148, 0.16);
}

.estimate-dd-toggle.is-placeholder {
    color: #728096;
    font-weight: 800;
}

.estimate-dd-menu {
    position: fixed;
    z-index: 1050;
    min-width: 260px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 0;
    background: #f8f8f8;
    border: 1px solid #6f89a5;
    border-radius: 6px;
    box-shadow: 0 12px 32px rgba(22, 42, 64, 0.32);
}

.estimate-dd-group {
    padding: 5px 12px;
    color: #000;
    background: #d3dae3;
    font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.4;
}

.estimate-dd-item {
    padding: 4px 12px;
    color: #595959;
    background: transparent;
    font-family: "Noto Sans TC", "Microsoft JhengHei", "Consolas", "Menlo", sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.5;
    cursor: pointer;
    white-space: normal;
    word-break: break-word;
}

.estimate-dd-item:hover {
    color: #13283d;
    background: #eef4fa;
}

.estimate-dd-item.is-active {
    color: #fff;
    background: linear-gradient(135deg, #20364f, #315f8f);
    font-weight: 800;
}

.estimate-dd-item.estimate-dd-placeholder {
    color: #728096;
    background: #f4f7fb;
    font-weight: 800;
}

.estimate-filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 92px;
    height: 32px;
    border: 1px solid #8a7a3d;
    border-radius: 2px;
    background: #fff9dc;
    color: #634f00;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.estimate-filter-toggle:hover {
    background: #ffef9a;
}

.estimate-qty {
    width: 54px;
    height: 32px;
    padding: 4px 5px;
    font-size: 0.88rem;
    text-align: center;
}

.estimate-line-subtotal {
    min-width: 0;
    color: #c21f32;
    font-family: "Consolas", "Menlo", "Courier New", monospace;
    font-size: 0.9rem;
    font-weight: 800;
    text-align: right;
    white-space: nowrap;
}

.estimate-line-action {
    display: block;
    width: 34px;
}

.estimate-line-action button {
    width: 34px;
    height: 32px;
    padding: 0;
    border-radius: 2px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.estimate-line-add {
    border: 1px solid #3e638c;
    background: #eaf1f8;
    color: #284d76;
    font-size: 1.05rem;
}

.estimate-line-add:hover {
    background: #dce9f5;
}

.estimate-line-remove {
    border: 1px solid #d59696;
    background: #fff1f1;
    color: #bd2424;
    font-size: 1rem;
}

.estimate-line-remove:hover {
    background: #ffe2e2;
}

.estimate-line:first-child .estimate-line-remove {
    display: none;
}

.estimate-line:not(:first-child) .estimate-line-add {
    display: none;
}

.estimate-filter-panel {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
    padding: 6px 8px;
    border: 1px solid #e0ca70;
    background: #fffbea;
    color: #594900;
    font-size: 0.82rem;
}

.estimate-filter-panel.is-open {
    display: flex;
}

.estimate-filter-title {
    font-weight: 800;
}

.estimate-filter-panel label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    white-space: nowrap;
}

.estimate-filter-panel input {
    height: 28px;
    padding: 3px 6px;
    font-size: 0.82rem;
}

.estimate-filter-keyword {
    width: 170px;
}

.estimate-filter-min,
.estimate-filter-max {
    width: 86px;
}

.estimate-filter-wave {
    margin-left: -4px;
    margin-right: -4px;
}

.estimate-filter-clear {
    height: 28px;
    padding: 0 10px;
    border: 1px solid #9e8b43;
    border-radius: 2px;
    background: #fff;
    color: #5f4b00;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.estimate-filter-clear:hover {
    background: #fff1b8;
}

.estimate-filter-count {
    margin-left: auto;
    color: #536276;
}

.estimate-spec-detail {
    margin-top: 6px;
}

.estimate-spec-ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 18px;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #dde5ee;
    background: #f8fafc;
    color: #45515f;
    font-size: 0.86rem;
    list-style: none;
}

.estimate-spec-ul li span {
    color: #273748;
    font-weight: 700;
}

/* 右側摘要 */
.estimate-summary {
    position: sticky;
    top: 88px;
    border: 1px solid #ccd6e2;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(22, 42, 64, 0.07);
}

.estimate-summary-title {
    margin: 0;
    padding: 11px 14px;
    border-bottom: 1px solid #ccd6e2;
    background: #f0f4f8;
    color: #24384f;
    font-size: 1.04rem;
    font-weight: 800;
}

.estimate-conflict-box,
.estimate-power-box,
.estimate-selected-list,
.estimate-total-row,
.estimate-summary .btn {
    margin-left: 14px;
    margin-right: 14px;
}

.estimate-power-box {
    margin-top: 14px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #cdd9e6;
    border-radius: 3px;
    background: #f5f9fd;
}

.estimate-power-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    color: #2c3e50;
    font-size: 0.92rem;
    font-weight: 700;
}

.estimate-power-row .estimate-total-power,
.estimate-power-row .estimate-psu-watt {
    color: #1f6fb2;
    font-weight: 800;
    white-space: nowrap;
}

.estimate-power-hint {
    margin-top: 4px;
    font-size: 0.84rem;
}

.estimate-conflict-box {
    margin-top: 14px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #f0b6b6;
    border-radius: 3px;
    background: #fff4f4;
}

.estimate-conflict-title {
    margin-bottom: 7px;
    color: #d52b2b;
    font-weight: 800;
}

.estimate-conflict-list {
    margin: 0;
    padding-left: 18px;
    color: #b82020;
    font-size: 0.88rem;
}

.estimate-conflict-list li {
    margin-bottom: 4px;
}

.estimate-selected-list {
    max-height: 330px;
    margin-top: 0;
    margin-bottom: 12px;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.estimate-selected-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px dotted #d6dee8;
    font-size: 0.88rem;
}

.estimate-selected-list .esl-name {
    min-width: 0;
    color: #465464;
}

.estimate-selected-list .esl-price {
    color: #465464;
    font-weight: 800;
    white-space: nowrap;
}

/* 補貨中商品：估價明細以灰色字體標示 */
.estimate-selected-list li.esl-restock .esl-name,
.estimate-selected-list li.esl-restock .esl-price {
    color: #a7afba;
}

.estimate-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    padding: 12px 0;
    color: #1f2d3d;
    font-size: 1.08rem;
    font-weight: 800;
}

.estimate-total-amount {
    color: #c21f32;
    white-space: nowrap;
}

/* 分期付款試算 */
.estimate-installment-box {
    margin-left: 14px;
    margin-right: 14px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #d7e0ea;
    border-radius: 3px;
    background: #f8fafc;
}

.estimate-installment-title {
    margin-bottom: 8px;
    color: #24384f;
    font-size: 0.92rem;
    font-weight: 800;
}

.estimate-installment-title i {
    margin-right: 4px;
    color: #2f70b5;
}

.estimate-installment-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.estimate-installment-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px dotted #d6dee8;
    font-size: 0.86rem;
}

.estimate-installment-list li:last-child {
    border-bottom: 0;
}

.estimate-installment-list .esi-months {
    flex: 0 0 auto;
    color: #1f2d3d;
    font-weight: 800;
}

.estimate-installment-list .esi-amount {
    flex: 0 0 auto;
    color: #c21f32;
    font-weight: 800;
    white-space: nowrap;
}

.estimate-installment-note {
    margin-top: 8px;
    color: #8593a3;
    font-size: 0.78rem;
    line-height: 1.45;
}

.estimate-summary .btn {
    display: block;
    width: calc(100% - 28px);
    margin-bottom: 10px;
    border-radius: 3px;
}

.estimate-gocart-btn {
    margin-bottom: 14px !important;
}

@media (max-width: 1199px) {
    .estimate-line-body {
        grid-template-columns: minmax(220px, 1fr) 86px 54px 88px 34px;
    }

    .estimate-filter-toggle {
        width: 86px;
    }
}

@media (max-width: 991px) {
    .estimate-heading {
        display: block;
    }

    .estimate-intro {
        margin-top: 8px;
        text-align: left;
    }

    .estimate-summary {
        position: static;
        margin-top: 18px;
    }

    .estimate-spec-ul {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .estimate-list-head {
        display: none;
    }

    .estimate-row {
        display: block;
    }

    .estimate-row-label {
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid #dfc96e;
    }

    .estimate-line-body {
        grid-template-columns: minmax(0, 1fr) 86px 54px;
    }

    .estimate-select,
    .estimate-dd {
        grid-column: 1 / -1;
    }

    .estimate-line-subtotal {
        text-align: left;
    }

    .estimate-line-action {
        grid-column: 3;
        grid-row: 2;
        justify-self: end;
    }

    .estimate-filter-panel {
        flex-wrap: wrap;
    }

    .estimate-filter-count {
        width: 100%;
        margin-left: 0;
    }
}

@media (max-width: 575px) {
    .estimate-page {
        padding-left: 10px;
        padding-right: 10px;
    }

    .estimate-line-body {
        grid-template-columns: minmax(0, 1fr) 50px 34px;
    }

    .estimate-filter-toggle {
        width: 32px;
        padding: 0;
        justify-self: start;
    }

    .estimate-filter-toggle span {
        display: none;
    }

    .estimate-line-subtotal {
        grid-column: 1 / -1;
    }

    .estimate-filter-keyword,
    .estimate-filter-min,
    .estimate-filter-max {
        width: 100%;
    }

    .estimate-filter-panel label {
        width: 100%;
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .estimate-filter-wave {
        display: none;
    }
}
