/* ============================================================
   1. โครงสร้างหลัก (Container) - จัดตำแหน่งและระยะห่าง
   ============================================================ */
.live-search-container {
    position: relative !important;
    width: 100%;
    /* ปรับให้เลื่อนลง 20px และชิดซ้าย (Margin-left: 0) */
    margin: 20px auto 5px 0 !important; 
    font-family: "kanit", sans-serif;
    z-index: 9999 !important;
}

/* ปรับความกว้างสำหรับ Desktop */
@media screen and (min-width: 768px) {
    .live-search-container {
        width: 100% !important;
        max-width: 600px; /* ปรับขนาดช่องให้แคบลงตามต้องการ */
        /* เลื่อนลงจากขอบบน 25px เพื่อความสวยงาม */
        margin: 15px auto 5px 0 !important; 
    }
}

/* ============================================================
   2. ช่องพิมพ์ค้นหา (Input Field)
   ============================================================ */
.live-search-input-field {
    width: 100% !important;
    padding: 12px 50px 12px 20px !important;
    font-size: 16px;
    color: #06003D;
    font-weight: 400 !important; /* ปรับฟอนต์เป็นตัวธรรมดา */
    background: #ffffff !important;
    border: 2px solid rgba(6, 0, 61, 0.15) !important;
    border-radius: 30px !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05) !important;
    outline: none !important;
    transition: all 0.3s ease;
}

.live-search-input-field:focus {
    border-color: #06003D !important;
    box-shadow: 0 10px 20px rgba(6, 0, 61, 0.1) !important;
}

/* ไอคอนแว่นขยาย */
.search-icon {
    position: absolute;
    right: 20px;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #06003D;
    opacity: 0.5;
    font-size: 18px !important;
    pointer-events: none;
    z-index: 5;
}

/* ============================================================
   3. กล่องแสดงผลลัพธ์ (Dropdown Box)
   ============================================================ */
.live-search-results-box {
    position: absolute !important;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #ffffff !important;
    border-radius: 18px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 15px 45px rgba(0,0,0,0.2) !important;
    display: none;
    z-index: 999999999 !important;
    max-height: 500px;
    overflow-y: auto;
}

/* หัวข้อหมวดหมู่ (สินค้า/บทความ/ประวัติ) */
.res-section-title, .history-header {
    background: #fcfdfe !important;
    padding: 12px 20px !important;
    font-size: 11px;
    font-weight: 400 !important;
    color: #06003D;
    text-transform: uppercase;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* รายการสินค้า/บทความ */
.live-search-results-box ul { list-style: none !important; margin: 0 !important; padding: 0 !important; }

.live-search-results-box li a {
    display: flex;
    align-items: center;
    padding: 10px 20px !important; 
    text-decoration: none !important;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.live-search-results-box li a:hover { background: rgba(6, 0, 61, 0.04); }

/* รูปภาพสินค้า */
.res-thumb { 
    width: 48px; height: 48px; 
    object-fit: cover; 
    border-radius: 10px; 
    margin-right: 15px; 
    flex-shrink: 0; 
}

/* ชื่อสินค้าและตัวหนังสือ */
.res-title { 
    font-size: 14px; 
    font-weight: 400 !important; /* ปรับเป็นตัวธรรมดา */
    color: #06003D; 
    line-height: 1.4; 
}

.res-sku { 
    font-size: 11px; 
    color: #666; 
    background: #f1f1f1; 
    padding: 2px 6px; 
    border-radius: 4px; 
    display: inline-block; 
    margin-top: 3px; 
    font-weight: 400 !important;
}

/* สีเน้นคำค้นหา */
.search-highlight { 
    background: #fff3bf; 
    color: #06003D; 
    font-weight: 400 !important; 
    padding: 0 2px; 
}

/* ============================================================
   4. ส่วนประวัติการค้นหา (History) - ปรับปรุงการแสดงรูป
   ============================================================ */
.history-item {
    font-size: 14px;
    padding: 10px 20px !important; 
    display: flex;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #f8fafc;
    transition: background 0.2s;
}

.history-item:hover { background: #f1f5f9; }

/* จัดการรูปภาพในประวัติ */
.history-item .res-thumb {
    width: 35px !important;
    height: 35px !important;
    border-radius: 6px;
    margin-right: 12px !important;
}

/* กรณีไม่มีรูป ให้ไอคอนนาฬิกาแสดงผลสวยงาม */
.history-item .dashicons-backup {
    margin-right: 15px !important;
    font-size: 18px !important;
    color: #94a3b8;
    width: 35px;
    text-align: center;
}

.history-item span {
    font-weight: 400 !important;
    color: #06003D;
    line-height: 1.3;
}

.clear-history { color: #ef4444; font-size: 11px; cursor: pointer; font-weight: 400 !important; }

/* ============================================================
   5. ส่วน "ไม่พบรายการ" และ "ปุ่มดูทั้งหมด"
   ============================================================ */
.no-res-box { padding: 40px 20px !important; text-align: center; color: #06003D; }
.no-res-box p { font-size: 14px !important; opacity: 0.7; font-weight: 400 !important; }

.view-all-btn {
    display: block;
    padding: 15px;
    text-align: center;
    background: #f8fafc;
    color: #06003D !important;
    font-size: 13px;
    font-weight: 400 !important;
    text-decoration: none !important;
    border-top: 1px solid #eee;
}

/* ============================================================
   6. รองรับมือถือ (Mobile Fix)
   ============================================================ */
@media screen and (max-width: 767px) {
    .live-search-container {
        width: 92% !important;
        margin: 15px auto !important; /* เลื่อนลงเล็กน้อยในมือถือ */
    }

    .live-search-input-field { font-size: 16px !important; }

    .live-search-results-box { width: 100% !important; }
}

/* Loader Animation */
@keyframes shimmer { 0% { background-position: -468px 0; } 100% { background-position: 468px 0; } }
.is-loading { height: 12px; margin: 10px 20px; border-radius: 4px; background: #f6f7f8 linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%); background-size: 800px 104px; animation: shimmer 1.2s linear infinite; }