/* ============================================
   CK SEARCH SYSTEM - CSS
   Chỉnh sửa theo yêu cầu mới
============================================ */

/* Thanh tìm kiếm mới */
.thanh-tim-kiem {
    width: 100%;
    max-width: 700px;
    margin: 20px auto;
    font-family: Arial, Helvetica, sans-serif;
    position: relative;
}

.thanh-tim-kiem__title {
    text-align: center;
    color: #0070c0;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 14px;
}

.thanh-tim-kiem__bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* TĂNG ĐỘ ĐẶC HIỆU CHO DROPDOWN */
.thanh-tim-kiem .thanh-tim-kiem__select,
.thanh-tim-kiem__select {
    width:  36% !important;
    height: 44px !important;
    padding: 0 12px !important;
    border: 2px solid #000 !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    background: #fff !important;
    outline: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 16px !important;
    padding-right: 36px !important;
    box-shadow: none !important; /* Ghi đè box-shadow từ CSS khác */
    box-sizing: border-box !important;
}

/* Wrapper cho input và button */
.thanh-tim-kiem__input-wrapper {
    flex: 1;
    display: flex;
    gap: 10px;
}

/* TĂNG ĐỘ ĐẶC HIỆU CHO INPUT */
.thanh-tim-kiem .thanh-tim-kiem__input,
.thanh-tim-kiem__input {
    flex: 1 !important;
    height: 44px !important; /* Đã bằng với dropdown */
    padding: 0 14px !important;
    border: 2px solid #000 !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    outline: none !important;
    box-sizing: border-box !important;
    box-shadow: none !important; /* Ghi đè box-shadow từ CSS khác */
    background-color: #fff !important;
    color: #333 !important;
    max-width: none !important;
    width: auto !important;
    vertical-align: baseline !important;
    transition: none !important; /* Ghi đè transition từ CSS khác */
}

/* TĂNG ĐỘ ĐẶC HIỆU CHO BUTTON */
.thanh-tim-kiem .thanh-tim-kiem__btn,
.thanh-tim-kiem__btn {
    width: 46px !important;
    height: 44px !important; /* Sửa từ 46px thành 44px để bằng với dropdown */
    background: #0070c0 !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.3s !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.thanh-tim-kiem .thanh-tim-kiem__btn:hover,
.thanh-tim-kiem__btn:hover {
    background: #005a9e !important;
}

/* SỬA: Icon FontAwesome trong button */
.thanh-tim-kiem .thanh-tim-kiem__btn i.fa-search,
.thanh-tim-kiem__btn i.fa-search {
    color: white !important;
    font-size: 17px !important;
}

/* AJAX Suggestions cho thanh tìm kiếm mới */
.thanh-tim-kiem__suggestions {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    top: calc(100% + 5px);
    left: calc(36% + 10px);
    width: calc(64% - 56px);
    display: none;
}

/* Hiển thị khi có dữ liệu */
.thanh-tim-kiem__suggestions.show {
    display: block;
}

.thanh-tim-kiem-ajax-suggestions {
    max-height: 700px;
    overflow-y: auto;
}

.thanh-tim-kiem-ajax-suggestions h4 {
    padding: 15px;
    margin: 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #666;
    font-weight: 600;
    background: #f8f9fa;
}

.thanh-tim-kiem-ajax-suggestions ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.thanh-tim-kiem-ajax-suggestions li {
    border-bottom: 1px solid #f5f5f5;
}

.thanh-tim-kiem-ajax-suggestions li:last-child {
    border-bottom: none;
}

.thanh-tim-kiem-ajax-suggestions li a {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.thanh-tim-kiem-ajax-suggestions li a:hover {
    background: #f8f9fa;
}

.thanh-tim-kiem-ajax-suggestions li a strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    color: #0070c0;
}

.thanh-tim-kiem-ajax-suggestions li a small {
    display: block;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.thanh-tim-kiem-ajax-view-all {
    padding: 15px;
    border-top: 1px solid #eee;
    text-align: center;
    background: #f8f9fa;
}

.thanh-tim-kiem-ajax-view-all a {
    display: inline-block;
    padding: 6px 12px;
    background: #0070c0;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.thanh-tim-kiem-ajax-view-all a:hover {
    background: #005a9e;
    text-decoration: none;
}

.thanh-tim-kiem-ajax-no-results {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Loading animation */
.thanh-tim-kiem-loading {
    padding: 20px;
    text-align: center;
    color: #666;
}

.thanh-tim-kiem-loading:before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0070c0;
    border-radius: 50%;
    animation: ck-spin 1s linear infinite;
}

@keyframes ck-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive for search form - ĐÃ SỬA CHO MOBILE */
@media (max-width: 768px) {
    .thanh-tim-kiem__bar {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Dropdown chiếm 100% chiều ngang */
    .thanh-tim-kiem .thanh-tim-kiem__select,
    .thanh-tim-kiem__select {
        width: 100% !important;
        height: 44px !important; /* Giữ nguyên 44px */
    }
    
    /* Input và button nằm cùng hàng */
    .thanh-tim-kiem__input-wrapper {
        display: flex;
        width: 100%;
        gap: 0;
    }
    
    /* Input chiếm 80% chiều rộng */
    .thanh-tim-kiem .thanh-tim-kiem__input,
    .thanh-tim-kiem__input {
        width: 80% !important;
        height: 44px !important; /* Giữ nguyên 44px */
        border-top-right-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-right: 1px solid #000 !important;
        flex: none !important;
    }
    
    /* Button chiếm 20% chiều rộng */
    .thanh-tim-kiem .thanh-tim-kiem__btn,
    .thanh-tim-kiem__btn {
        width: 20% !important;
        height: 44px !important; /* Giữ nguyên 44px */
        border-top-left-radius: 0 !important;
        border-bottom-left-radius: 0 !important;
        flex: none !important;
    }
    
    /* SỬA: Icon trên mobile */
    .thanh-tim-kiem .thanh-tim-kiem__btn i.fa-search,
    .thanh-tim-kiem__btn i.fa-search {
        font-size: 18px !important;
    }
    
    /* SỬA: Vị trí suggestions trên mobile */
    .thanh-tim-kiem__suggestions {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-top: 2px !important;
        z-index: 9999;
        max-height: 50vh;
        overflow-y: auto;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    .thanh-tim-kiem-ajax-suggestions {
        max-height: calc(50vh - 50px);
    }
}

/* Responsive cho màn hình rất nhỏ */
@media (max-width: 480px) {
    .thanh-tim-kiem {
        padding: 0 10px;
    }
    
    .thanh-tim-kiem__title {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    /* CẢ 3 THÀNH PHẦN CÙNG CHIỀU CAO 42px */
    .thanh-tim-kiem .thanh-tim-kiem__select,
    .thanh-tim-kiem__select {
        height: 42px !important;
        font-size: 14px !important;
    }
    
    .thanh-tim-kiem .thanh-tim-kiem__input,
    .thanh-tim-kiem__input {
        height: 42px !important;
        font-size: 14px !important;
    }
    
    .thanh-tim-kiem .thanh-tim-kiem__btn,
    .thanh-tim-kiem__btn {
        height: 42px !important;
    }
    
    /* SỬA: Icon trên màn hình nhỏ */
    .thanh-tim-kiem .thanh-tim-kiem__btn i.fa-search,
    .thanh-tim-kiem__btn i.fa-search {
        font-size: 16px !important;
    }
    
    /* SỬA: Điều chỉnh thêm cho màn hình nhỏ */
    .thanh-tim-kiem__suggestions {
        margin-top: 1px !important;
        max-height: 45vh;
    }
    
    .thanh-tim-kiem-ajax-suggestions {
        max-height: calc(45vh - 45px);
    }
}