/* =========================
 * Hero 搜尋表單主體
 * ========================= */
.hero-form {
    display: grid;
    grid-template-columns: max-content 1fr 1fr 1fr 1fr 160px;
    grid-template-rows: auto auto;
    gap: 16px;
    align-items: start;
}

/* =========================
 * 欄位通用
 * ========================= */
.hero-form .field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 類型（左上） */
.hero-form .type-select {
    grid-column: 1;
    grid-row: 1;
}

/* =========================
 * 中間四欄（縣市 / 坪數 / 房數 / 租金）
 * ========================= */
.hero-form .field-group-row {
    grid-column: 2 / span 4;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* =========================
 * 地址（第二排，對齊縣市）
 * ========================= */
.hero-form .address-group {
    grid-column: 2 / span 4;
    grid-row: 2;
}

/* =========================
 * 搜尋按鈕（右上）
 * ========================= */
.hero-form .btn-group {
    grid-column: 6;
    grid-row: 1;
    align-self: start;
}

.hero-form .btn-search {
    height: 44px;
    border-radius: 6px;
    background: #0a6ea8;
    color: #fff;
    border: none;
    cursor: pointer;
}

/* =========================
 * input / select
 * ========================= */
.hero-form input,
.hero-form select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

/* disabled 區域 */
.hero-form select[disabled] {
    background: #e5e7eb;
    color: #9ca3af;
}

/* =========================
 * RWD（手機直接直排）
 * ========================= */
@media (max-width: 768px) {
    /* 1) 主表單：改單欄 grid */
    .hero-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
        align-items: stretch;
    }

    /* 2) ⭐ 關鍵：把桌機可能寫過的定位全部重置，不然會重疊 */
    .hero-form > .type-select,
    .hero-form > .field-group-row,
    .hero-form > .address-group,
    .hero-form > .btn-group {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        align-self: stretch !important;
        justify-self: stretch !important;
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        bottom: auto !important;
        margin: 0 !important;
    }

    /* 3) 四個主要欄位的容器：也改成單欄 grid */
    .hero-form .field-group-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* 4) field-group 自己也吃滿 */
    .hero-form .field-group-row .field-group {
        grid-column: 1 / -1;
    }

    /* 5) Input / Select 全寬 */
    .hero-form input,
    .hero-form select {
        width: 100%;
        box-sizing: border-box;
    }

    /* 6) 搜尋按鈕：放最下面全寬（不靠右上） */
    .hero-form .btn-group .btn-search {
        width: 100%;
        padding: 14px 0;
        border-radius: 8px;
        font-size: 16px;
    }
}

/* ===============================
 * 手機版：僅修正「類型選擇」
 * 不影響其他區塊
 * =============================== */
@media (max-width: 768px) {

    /* 整個類型區塊維持桌機結構 */
    .hero-form .type-select {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* 標題 */
    .hero-form .type-select > label:first-child {
        display: block;
        margin: 0;
        width: auto;
    }

    /* 住宅 / 辦公 */
    .hero-form .type-select > label:not(:first-child) {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 1px;
        white-space: nowrap;
        margin: 0;
        width: auto;
        text-align: left;
    }

    /* radio 本體：禁止被置中 */
    .hero-form .type-select input[type="radio"] {
        margin: 0;
        flex: 0 0 auto;
    }
}

/* =========================
 * RWD（平板）
 * 769px ~ 1024px
 * ========================= */
@media (min-width: 769px) and (max-width: 1024px) {

    /* 主表單：第一欄固定，避免 type-select 撐爆 */
    .hero-form {
        grid-template-columns: 100px repeat(4, minmax(0, 1fr));
        grid-template-rows: auto auto auto;
        gap: 16px;
        align-items: start;
    }

    /* 類型：左上 */
    .hero-form .type-select {
        grid-column: 1;
        grid-row: 1;
    }

    /* ⭐ 中間四欄：一定要 4 欄完整排進去 */
    .hero-form .field-group-row {
        grid-column: 2 / span 4;
        grid-row: 1;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr)); /* ✅ 關鍵：避免第 4 欄被擠掉 */
        gap: 16px;
        width: 100%;
        min-width: 0;
    }

    /* 每一欄都不能把自己撐爆 */
    .hero-form .field-group-row > .field-group {
        min-width: 0;
        width: 100%;
        display: flex; /* 確保沒被其他規則改掉 */
    }

    /* 地址：第二排 */
    .hero-form .address-group {
        grid-column: 2 / span 4;
        grid-row: 2;
        min-width: 0;
    }

    /* 搜尋按鈕：最下面一整排 */
    .hero-form .btn-group {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .hero-form .btn-group .btn-search {
        width: 100%;
        height: 48px;
        font-size: 16px;
        border-radius: 8px;
    }
}


@media (max-width: 768px) {
  body.page-id-9 .has-global-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}
