/**
 * Custom Search Styles for Astra Child Theme - Always Visible
 */

/* Container chính */
.t-search-container {
    position: relative;
    display: flex;
    /* Giữ lại flex để align-items nếu cần */
    align-items: center;
    z-index: auto;
    /* Giữ lại z-index cho phần kết quả tìm kiếm */
    width: 25vw;
    max-width: 100%;
}

/* Wrapper form tìm kiếm - LUÔN HIỂN THỊ */
.t-search-form-wrapper {
    position: relative;
    /* Không còn fixed hay absolute cho mobile popup */
    width: 100%;
    display: block;
    /* Hoặc flex, tùy theo cấu trúc bên trong */
}

/* Form tìm kiếm */
.t-search-form {
    position: relative;
    width: 100%;
}

/* Wrapper cho input và nút submit */
.t-search-input-wrapper {
    display: flex;
    position: relative;
    /*border-radius: var(--border-radius);*/
    /*box-shadow: var(--box-shadow);*/
    overflow: hidden;
    background-color: var(--t-light-color);
    border: 1px solid var(--t-grey-color);
    transition: var(--transition);
    width: 100%;
}

.t-search-input-wrapper:focus-within {
    border-color: var(--t-primary-color);
    /*box-shadow: 0 0 0 2px var(--t-primary-light);*/
}

/* Input tìm kiếm */
.t-search-input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--t-text-color);
    font-size: 16px;
    width: 100%;
    /* Đảm bảo input chiếm đủ không gian */
}

/* Nút submit */
.t-search-submit {
    background-color: var(--t-primary-color);
    color: var(--t-light-color);
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.t-search-submit:hover {
    background-color: var(--t-primary-dark);
}

.t-search-submit i {
    font-size: 18px;
}

/* Toggle icon - LUÔN ẨN */
.t-search-icon-toggle {
    display: none !important;
    /* Quan trọng: Luôn ẩn icon này */
}

/* Container kết quả tìm kiếm (giữ nguyên logic hiển thị khi có kết quả) */
.t-search-results-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--t-light-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--box-shadow);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    /* Cao hơn form một chút */
    display: none;
    /* Sẽ được JS điều khiển */
    margin-top: 5px;
    width: 100%;
}

.t-search-results-content {
    padding: 15px;
}

/* --- Các style cho kết quả tìm kiếm (t-search-results-heading, list, item, v.v.) giữ nguyên như cũ --- */
/* Tiêu đề kết quả */
.t-search-results-heading {
    font-size: 14px;
    color: var(--t-secondary-color);
    font-weight: bold;
    margin: 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--t-grey-color);
}

/* Danh sách kết quả */
.t-search-results-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Mục kết quả */
.t-search-result-item {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--t-grey-color);
    transition: var(--transition);
}

.t-search-result-item:last-child {
    border-bottom: none;
}

.t-search-result-item:hover {
    background-color: var(--t-grey-color);
}

/* Link kết quả */
.t-search-result-link {
    display: flex;
    width: 100%;
    text-decoration: none;
    color: var(--t-text-color);
}

/* Hình ảnh kết quả */
.t-search-result-image {
    width: 60px;
    height: 60px;
    margin-right: 10px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

/* Thông tin kết quả */
.t-search-result-info {
    flex: 1;
}

/* Tiêu đề kết quả */
.t-search-result-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 5px 0;
    color: var(--t-secondary-color);
}

/* Giá sản phẩm */
.t-search-result-price {
    font-weight: bold;
    color: var(--t-primary-color);
    margin: 0 0 5px 0;
}

/* Danh mục sản phẩm */
.t-search-result-category {
    font-size: 12px;
    color: var(--t-secondary-color);
    margin: 0;
}

/* Tóm tắt bài viết */
.t-search-result-excerpt {
    font-size: 14px;
    color: var(--t-text-color);
    margin: 5px 0 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Nút xem tất cả kết quả */
.t-search-view-all {
    display: block;
    text-align: center;
    padding: 10px;
    background-color: var(--t-grey-color);
    color: var(--t-secondary-color);
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    transition: var(--transition);
}

.t-search-view-all:hover {
    background-color: var(--t-grey-dark);
    color: var(--t-secondary-color);
}

/* Thông báo không có kết quả */
.t-search-no-results {
    padding: 15px;
    text-align: center;
    color: var(--t-secondary-color);
}

/* Loader cho Ajax */
.t-search-loader {
    display: none;
    justify-content: center;
    padding: 20px;
}

.t-search-loader-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--t-grey-color);
    border-top: 3px solid var(--t-primary-color);
    border-radius: 50%;
    animation: t-search-spin 1s linear infinite;
}

@keyframes t-search-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/* Cải thiện hiển thị trên các màn hình lớn */
@media (min-width: 1200px) {
    .t-search-container {
        width: 30vw;
    }
}

/* Thiết lập đặc biệt cho tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .t-search-container {
        width: 28vw;
    }

    /* Gợi ý trên tablet - giữ nguyên nếu bạn vẫn muốn nó là dropdown */
    .t-search-results-container {
        width: 50vw;
        left: auto;
        right: 0;
        /* position: absolute; đã có ở trên */
    }

    .t-search-result-image {
        width: 70px;
        height: 70px;
    }

    .t-search-result-title {
        font-size: 17px;
    }

    .t-search-result-excerpt {
        font-size: 15px;
    }

    .t-search-result-price {
        font-size: 16px;
    }
}

/* Cho màn hình từ 1025px đến 1199px */
@media (min-width: 1025px) and (max-width: 1199px) {
    .t-search-container {
        width: 28vw;
    }
}

/* Media queries cho mobile - ĐƠN GIẢN HÓA */
@media (max-width: 768px) {
    /* Lớp phủ mờ không cần nữa */
    /* .t-search-container.active::before { display: none; } */

    .t-search-container {
        width: 100%;
        /* Cho phép chiếm toàn bộ chiều rộng của container cha (ví dụ trong mobile menu) */
        /* position: static; đã có ở trên hoặc không cần thiết nếu cha đã định vị đúng */
    }

    .t-search-form-wrapper {
        /* Đảm bảo nó hiển thị bình thường, không phải là popup */
        /* Các style như position: fixed, left, transform, animation slideDown không cần nữa */
    }

    /* Các style liên quan đến .t-search-container.active để mở/đóng icon và form có thể xóa đi */
    /* .t-search-container.active .t-search-open-icon { display: none; } */
    /* .t-search-container.active .t-search-close-icon { display: block; } */

    /* Kết quả tìm kiếm trên mobile vẫn có thể là dropdown từ form */
    .t-search-results-container {
        /* width: 100%; đã có ở trên */
        /* max-width: 100%; đã có ở trên */
        /* position: absolute; đã có ở trên, sẽ neo theo .t-search-form-wrapper */
    }
}