/* ====================================== */
/* --- SEARCH PAGE - Layout & Filters (START) --- */
/* ====================================== */
.search-layout-container { padding: 30px 0; }
.search-layout { max-width: 1600px; margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: 260px 1fr; gap: 30px; }

/* --- Filter Sidebar --- */
.filter-sidebar { background: var(--bg-white); border-radius: 12px; padding: 20px; border: 1px solid var(--border-color); align-self: start; position: sticky; top: 85px; }
.filter-sidebar h4 { font-size: 1.375rem; font-weight: 700; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #eee; }
.filter-group { margin-bottom: 25px; }
.filter-group h5 { font-size: 1.375rem; font-weight: 600; margin-bottom: 12px; }
.filter-option { margin-bottom: 8px; display: flex; align-items: center; padding: 8px 12px; border-radius: 8px; transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease; cursor: pointer; border: 1px solid transparent; }
.filter-option label { font-size: 1.375rem; cursor: pointer; flex-grow: 1; margin-left: 10px; font-weight: 500; -webkit-user-select: none; -ms-user-select: none; user-select: none; }
.filter-option input[type="radio"], .filter-option input[type="checkbox"] { flex-shrink: 0; cursor: pointer; transform: scale(1.1); accent-color: var(--primary-color); margin: 0; }
.filter-option.selected { background-color: #dbeafe; border-color: #bfdbfe; }
.filter-option.selected label { color: var(--primary-color); font-weight: 600; }
.filter-option:hover:not(.selected) { background-color: #f1f3f5; }
.filter-option input[type="checkbox"] { border-radius: 4px; }
.btn-apply-filters, .btn-clear-filters { width: 100%; padding: 10px; margin-top: 10px; font-size: 1.375rem; letter-spacing: 1.0px; font-weight: 600; border-radius: 8px; text-align: center; display: inline-block; }
.btn-clear-filters { background-color: #ff8e25; color: #ffffff; border: 1px solid var(--border-color); }
.btn-clear-filters:hover { background-color: #e9ecef; }
.sort-by-select { padding: 8px 12px; border: 1px solid #ced4da; border-radius: 6px; font-family: 'Sarabun', sans-serif; font-size: 0.9375rem; background-color: var(--bg-white); cursor: pointer; width: 100%; margin-top: 5px; }
.price-range-inputs { display: flex; align-items: center; gap: 8px; }
.price-range-inputs .price-input { width: 100%; padding: 8px 10px; border: 1px solid #ced4da; border-radius: 6px; font-family: 'Sarabun', sans-serif; font-size: 0.875rem; -moz-appearance: textfield; }
.price-range-inputs .price-input::-webkit-outer-spin-button, .price-range-inputs .price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.price-range-inputs span { color: var(--text-muted); }
.category-filter-list { max-height: 250px; overflow-y: auto; padding-right: 5px; margin-bottom: 0; }

/* --- Search Results Area --- */
.search-results .results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; flex-wrap: wrap; gap: 15px; }
.search-results .results-header h2 { font-size: 1.875rem; font-weight: 700; margin: 0; }
.sort-and-count { display: flex; align-items: center; gap: 20px; color: var(--text-muted); }
.no-results { text-align: center; padding: 60px 20px; background: var(--bg-white); border-radius: 12px; border: 1px solid var(--border-color); }
.no-results h3 { margin-bottom: 10px; }
.no-results a { color: var(--primary-color); font-weight: 600; }

/* Voice Search Button (Consolidated) */
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}
.results-title-group { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.btn-voice-search { background-color: var(--primary-color); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 0.9375rem; font-weight: 600; display: flex; align-items: center; gap: 8px; transition: all 0.2s ease; white-space: nowrap; }
.btn-voice-search:hover { background-color: #1d4ed8; }
.btn-voice-search.is-listening { background-color: #c82333; animation: pulse-red 1.5s infinite; }
.btn-voice-search .voice-status-text { display: none; }
.btn-voice-search.is-listening .voice-button-text { display: none; }
.btn-voice-search.is-listening .voice-status-text { display: block; font-weight: 500; }
@media (max-width: 768px) {
    .results-title-group { width: 100%; justify-content: space-between; }
    .search-results .results-header h2 { font-size: 1.125rem; }
    .btn-voice-search { padding: 6px 12px; font-size: 0.875rem; }
    .btn-voice-search .voice-button-text { display: none; }
    .btn-voice-search.is-listening .voice-status-text { font-size: 0.8125rem; }
    .filter-sidebar h4, .filter-group h5, .filter-option label, .btn-apply-filters, .btn-clear-filters { 
        /* Adjusting filter sidebar to follow a slightly smaller scale on mobile */
        font-size: 1.8rem; 
    }
}
@media (max-width: 400px) {
     .btn-voice-search.is-listening i { display: none; }
}

/* Search Layout Responsive */
@media (max-width: 992px) { .search-layout { grid-template-columns: 1fr; } .filter-sidebar { position: static; margin-bottom: 30px; } }
@media (max-width: 768px) { .search-layout-container { padding: 20px 0; } .search-layout { padding: 0 15px; gap: 20px; } .search-results .results-header { flex-direction: column; align-items: flex-start; } .search-results .results-header h2 { font-size: 1.8rem; } }
/* ====================================== */
/* --- SEARCH PAGE - Layout & Filters (END) --- */
/* ====================================== */

/* ===================================================== */
/* --- (*** START: V2 - Search Filter Redesign ***) --- */
/* ===================================================== */

/* --- V2: Header ของ Sidebar --- */
.filter-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 20px; /* (V2: ย้าย Padding จาก .filter-sidebar มาไว้ที่นี่) */
    padding-top: 20px;
    border-bottom: 1px solid #eee;
}
.filter-sidebar-header h4 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-clear-all {
    font-size: 1.6rem; /* (V2: ปรับขนาด) */
    font-weight: 500;
    color: #da6900;
    text-decoration: none;
    transition: color 0.2s;
}
.filter-clear-all:hover {
    color: var(--danger-color);
}
.btn-close-filters {
    display: none; /* (ซ่อนบน Desktop) */
    font-size: 2.3rem;
  color: #c82333;
    font-weight: 600;
}

/* --- V2: ย้าย Padding หลักมาไว้ที่ Form --- */
.filter-sidebar {
    padding: 0; /* (V2: เอา Padding เดิมออก) */
    display: flex; /* (V2: เพิ่ม) */
    flex-direction: column; /* (V2: เพิ่ม) */
    max-height: calc(100vh - 100px); /* (V2: จำกัดความสูง) */
}
#filter-form {
    padding: 20px;
    flex-grow: 1; /* (V2: ให้ Form ยืด) */
    overflow-y: auto; /* (V2: ให้ Form เลื่อนได้) */
}

/* --- V2: Accordion (<details>) Styles --- */
.filter-group {
    border-bottom: 1px solid #f1f3f5;
    padding-bottom: 15px;
    margin-bottom: 15px;
}
.filter-group:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}
details.filter-group > summary {
    list-style: none; /* (ซ่อนลูกศร default) */
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
details.filter-group > summary::-webkit-details-marker {
    display: none; /* (ซ่อนลูกศร default - Safari) */
}
details.filter-group > summary h5 {
    margin-bottom: 0;
    display: inline-block;
}
/* (V2: ลูกศร FontAwesome) */
details.filter-group > summary::after {
    content: '\f078'; /* (chevron-down) */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.8em;
    color: var(--text-muted);
    transition: transform 0.2s ease-out;
}
details.filter-group[open] > summary::after {
    transform: rotate(180deg);
}
.filter-group-content {
    padding-top: 15px;
}

/* --- V2: Price Pills (ปุ่มแคปซูล) --- */
.filter-pills-group {
    display: flex;
    width: 100%;
}
.filter-pills-group input[type="radio"] {
    display: none; /* (ซ่อน Radio Button จริง) */
}
.filter-pills-group .filter-pill {
    flex: 1;
    text-align: center;
    padding: 8px 5px;
    font-size: 1.375rem; /* (V2: ปรับขนาด) */
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: #fdfdfd;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
.filter-pills-group .filter-pill:first-of-type {
    border-radius: 6px 0 0 6px;
    border-right-width: 0.5px;
}
.filter-pills-group .filter-pill:last-of-type {
    border-radius: 0 6px 6px 0;
    border-left-width: 0.5px;
}
/* (V2: สถานะตอนเลือก) */
.filter-pills-group input[type="radio"]:checked + .filter-pill {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    z-index: 1;
}
.filter-pills-group .filter-pill:hover:not(:checked) {
     background-color: var(--bg-light);
}

/* --- V2: ปรับปุ่มล้าง Filter (ปุ่มส้ม) --- */
.btn-clear-filters {
     display: none; /* (V2: ไม่ใช้ปุ่มส้มนี้แล้ว) */
}
/* (V2: ปรับปุ่ม "ใช้ช่วงราคา") */
.btn-apply-filters {
    font-size: 1.5rem; /* (V2: ปรับขนาด) */
}

/* --- V2: Mobile Filter Toolbar --- */
.mobile-filter-toolbar {
    display: none; /* (ซ่อนบน Desktop) */
    margin-bottom: 20px;
}
.btn-open-filters {
    width: 100%;
    padding: 12px;
    font-size: 1.8rem; /* (V2: ปรับขนาด) */
    font-weight: 600;
    background: var(--bg-white);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.btn-open-filters i {
    margin-right: 8px;
}

/* --- V2: Mobile Off-Canvas Sidebar --- */
.filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}
.filter-overlay.open {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.filter-sidebar-footer {
    display: none; /* (ซ่อนบน Desktop) */
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
}
.filter-sidebar-footer .btn-primary {
    font-size: 1.375rem; /* (V2: ปรับขนาด) */
}

/* --- V2: Responsive Breakpoint (992px) --- */
@media (max-width: 992px) {
    /* (V2: ซ่อน Sidebar ของ Desktop) */
    .search-layout {
        /* (V2: ไม่ใช้ grid-template-columns: 1fr; แล้ว) */
        /* (เราจะซ่อน sidebar และแสดงผลลัพธ์เต็มจอ) */
    }
    
    .filter-sidebar {
        /* (V2: เปลี่ยนจาก Sticky เป็น Fixed Off-Canvas) */
        position: fixed;
        top: 0;
        left: 0;
        width: 300px; /* (ความกว้างเมนูมือถือ) */
        max-width: 85%;
        height: 100vh;
        max-height: 100vh; /* (V2: Override) */
        z-index: 2000;
        transform: translateX(-100%);
        transition: transform 0.3s ease-out;
        box-shadow: 0 0 20px rgba(0,0,0,0.1);
    }
    .filter-sidebar.open {
        transform: translateX(0);
    }

    /* (V2: แสดงปุ่มเปิด Filter) */
    .mobile-filter-toolbar {
        display: block;
    }

    /* (V2: แสดงปุ่มปิดและ Footer ใน Sidebar) */
    .filter-sidebar-header .btn-close-filters {
        display: block;
    }
    .filter-sidebar-footer {
        display: block;
    }
}
/* =================================================== */
/* --- (*** END: V2 - Search Filter Redesign ***) --- */
/* =================================================== */