/* smart-hz-search.css - Final Apple Style & Mobile Fullscreen */

/* --- 1. CẤU TRÚC CHUNG (DESKTOP DEFAULT) --- */
.smart-search-wrapper, .ega-smartsearch-wrapper, .ajaxSearchResults, .search-results { display: none !important; }

/* Ẩn input mobile trên giao diện Desktop */
.hz-mobile-input-wrapper { display: none; }
.desktop-hidden { display: none !important; }

/* Khung kết quả chính */
.custom-smart-search-results { 
    position: absolute; top: 100%; left: 0; right: 0; width: 100%; 
    background: rgba(255, 255, 255, 0.98); 
    backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border-radius: 24px; 
    box-shadow: 0 25px 60px -12px rgba(0,0,0,0.18), 0 0 1px rgba(0,0,0,0.1); 
    z-index: 99999; margin-top: 14px; overflow: hidden; 
    border: 1px solid rgba(255,255,255,0.6);
    animation: hzSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top center;
    /* Mặc định display do JS điều khiển (block/none) */
}

@keyframes hzSlideDown { 
    from { opacity: 0; transform: translateY(-15px) scale(0.96); } 
    to { opacity: 1; transform: translateY(0) scale(1); } 
}

/* --- 2. HEADER --- */
.hz-search-header-apple { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 16px 24px; 
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(249,249,249,0.8));
    border-bottom: 1px solid rgba(0,0,0,0.06); 
    flex-shrink: 0; /* Không bị co lại trên mobile */
}

.hz-header-title { font-weight: 700; font-size: 13px; color: #86868b; letter-spacing: 0.8px; text-transform: uppercase; }

.hz-close-search { 
    cursor: pointer; width: 30px; height: 30px; border-radius: 50%; 
    background: #f2f2f7; color: #86868b; display: flex; align-items: center; justify-content: center; 
    font-size: 14px; transition: all 0.2s ease; 
}
.hz-close-search:hover { background: #e5e5ea; color: #1d1d1f; transform: rotate(90deg); }

/* --- 3. NỘI DUNG BÊN TRONG --- */
.hz-initial-view { padding: 24px; max-height: 75vh; overflow-y: auto; }
.hz-stats-grid { display: flex; gap: 30px; }
.hz-stats-col { flex: 1; display: flex; flex-direction: column; gap: 15px; }

/* Box tiêu đề nhỏ */
.hz-section-box {
    display: flex; align-items: center; gap: 10px; background: #f5f5f7; 
    padding: 10px 16px; border-radius: 12px; margin-bottom: 5px; border: 1px solid rgba(0,0,0,0.03);
}
.hz-section-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.hz-section-text { font-size: 14px; font-weight: 700; color: #1d1d1f; letter-spacing: -0.3px; }

/* Tags (Từ khóa) */
.hz-tags-list { display: flex; flex-wrap: wrap; gap: 10px; }
.hz-tag-pill { 
    display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; 
    background: #fff; color: #1d1d1f; border-radius: 20px; font-size: 13px; font-weight: 500; 
    text-decoration: none; transition: all 0.2s; border: 1px solid #e5e5ea; box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.hz-tag-pill:hover { 
    background: #eafbe7; color: #388d45; border-color: #388d45; 
    transform: translateY(-2px); box-shadow: 0 4px 12px rgba(56, 141, 69, 0.2); 
}
.hz-tag-pill svg { width: 14px; height: 14px; color: #ff9500; fill: currentColor; }

/* List Sản phẩm (Top view) */
.hz-top-products-list { display: flex; flex-direction: column; gap: 10px; }
.hz-mini-prod { 
    display: flex; align-items: center; gap: 15px; text-decoration: none !important; 
    padding: 10px; border-radius: 16px; transition: all 0.2s; background: transparent;
}
.hz-mini-prod:hover { background: #f5f5f7; transform: scale(1.01); }
.hz-mini-prod img { width: 50px; height: 50px; border-radius: 10px; border: 1px solid rgba(0,0,0,0.05); object-fit: contain; background: #fff; box-shadow: 0 4px 8px rgba(0,0,0,0.05); }
.hz-mini-info { flex: 1; min-width: 0; }
.hz-mini-title { font-size: 13px; font-weight: 600; color: #1d1d1f; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* Rank Badges */
.hz-mini-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.hz-rank-badge {
    font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
    display: inline-flex; align-items: center; gap: 3px;
    text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; height: 20px;
}
.hz-rank-1 { background: linear-gradient(135deg, #FFD700 0%, #FDB931 100%); color: #fff; box-shadow: 0 2px 4px rgba(253, 185, 49, 0.2); }
.hz-rank-2 { background: linear-gradient(135deg, #E0E0E0 0%, #BDBDBD 100%); color: #555; }
.hz-rank-3 { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); color: #fff; }
.hz-rank-normal { background: #e3f2fd; color: #1976d2; }

/* View Count */
.hz-view-count { 
    font-size: 11px; color: #d0021b; font-weight: 600; 
    background: #fff0f0; padding: 2px 8px; border-radius: 10px; height: 20px;
    display: inline-flex; align-items: center; gap: 4px;
}
.hz-view-count svg { width: 14px; height: 14px; stroke-width: 2.5; }

/* Recently Viewed */
#hz-recent-section { margin-top: 25px; padding-top: 15px; border-top: 1px dashed #e5e5e5; }
.hz-horizontal-list { display: flex; gap: 12px; overflow-x: auto; padding: 10px 2px; scrollbar-width: none; }
.hz-horizontal-list::-webkit-scrollbar { display: none; }
.hz-recent-item { min-width: 110px; width: 110px; text-decoration: none !important; background: #fff; border-radius: 12px; border: 1px solid #f0f0f0; padding: 10px; transition: 0.2s; position: relative; }
.hz-recent-item:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); border-color: #388d45; }
.hz-recent-item .img-box { width: 100%; height: 90px; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; }
.hz-recent-item img { max-width: 100%; max-height: 100%; object-fit: contain; }
.hz-recent-item .txt-box { text-align: center; }
.hz-recent-item .r-title { font-size: 11px; color: #333; height: 28px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; margin-bottom: 4px; font-weight: 500; }
.hz-recent-item .r-price { font-size: 11px; font-weight: 700; color: #d0021b; }

/* Item Kết quả tìm kiếm (Dropdown) */
.smart-search-item { display: flex; align-items: center; padding: 14px 24px; border-bottom: 1px solid #f2f2f7; text-decoration: none !important; background: transparent; transition: 0.2s; position: relative; }
.smart-search-item:hover { background: #f9f9f9; }
.hz-item-img { width: 60px; height: 60px; object-fit: contain; border-radius: 12px; margin-right: 18px; background: #fff; border: 1px solid rgba(0,0,0,0.05); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.hz-item-info { flex: 1; min-width: 0; padding-right: 10px; }
.hz-item-title { display: block; font-size: 14px; font-weight: 600; color: #1d1d1f; margin-bottom: 6px; }
.hz-price-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;}
.hz-item-price { font-weight: 700; color: #ff3b30; font-size: 15px; }
.hz-item-compare { font-size: 12px; color: #aeaeb2; text-decoration: line-through; }
.hz-stock-label { font-size: 10px; color: #34c759; background: #e0f8e5; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.hz-incart-mini { font-size: 10px; color: #ff9500; background: #fff8dc; border: 1px solid #ffcc00; padding: 3px 8px; border-radius: 6px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.btn-hz-option { background: #388d45; color: #fff; font-weight: 600; font-size: 12px; padding: 8px 18px; border-radius: 20px; border: none; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 10px rgba(52, 199, 89, 0.25); }
.btn-hz-option:hover { background: #248a3d; transform: scale(1.05); box-shadow: 0 6px 14px rgba(52, 199, 89, 0.35); }

.loading-spinner, .no-result { padding: 40px; text-align: center; color: #86868b; font-size: 14px; }
.hz-spinner-apple { width: 24px; height: 24px; position: relative; display: inline-block; vertical-align: middle; margin-right: 8px; }
.hz-spinner-apple:after { content: " "; display: block; width: 20px; height: 20px; margin: 2px; border-radius: 50%; border: 2px solid #86868b; border-color: #86868b transparent #86868b transparent; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- 4. MOBILE FULLSCREEN MODE (QUAN TRỌNG) --- */
@media (max-width: 767px) {
    /* Biến container thành Full màn hình, đè lên tất cả */
    .custom-smart-search-results { 
        display: flex; /* Dùng flex để chia cột */
        flex-direction: column;
        position: fixed !important; 
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        width: 100vw !important; height: 100vh !important; 
        margin: 0 !important; border-radius: 0 !important; 
        background: #fff !important; 
        z-index: 9999999 !important; /* Đè lên menu, header */
        border: none !important;
        transform: none !important;
        animation: none !important; /* Tắt hiệu ứng trượt dropdown */
    }

    /* Header Mobile */
    .hz-search-header-apple {
        background: #fff;
        border-bottom: 1px solid #f1f1f1;
        padding: 10px 15px;
    }

    /* Ẩn tiêu đề cũ, Hiện ô Input mới */
    .hz-header-title { display: none !important; }
    
    .hz-mobile-input-wrapper { 
        display: block !important; 
        flex: 1; 
        position: relative; 
        margin-right: 12px;
    }
    
    /* Style ô Input Mobile */
    .hz-mobile-input {
        width: 100%; height: 40px;
        background: #f5f5f5;
        border: none; border-radius: 8px;
        padding: 0 15px;
        font-size: 16px; /* 16px chặn iOS zoom */
        color: #333; outline: none;
    }
    .hz-mobile-input:focus { background: #eee; }

    /* Nút đóng trên mobile */
    .hz-close-search {
        width: auto; height: auto;
        background: transparent !important;
        color: #007aff !important; /* Màu xanh style iOS */
        font-size: 15px; font-weight: 500;
        padding: 5px;
    }
    .hz-close-search i { display: none; } /* Ẩn icon X */
    .hidden-xs { display: none !important; } /* Ẩn cái gì thuộc desktop */
    .visible-xs { display: inline-block !important; }

    /* Nội dung cuộn được */
    .hz-initial-view, .results-content, .loading-spinner {
        flex: 1; /* Chiếm phần còn lại của màn hình */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 80px; /* Tránh bị che bởi nav bar trình duyệt */
    }
    
    /* Layout cột dọc trên mobile */
    .hz-stats-grid { flex-direction: column; gap: 20px; }
    .hz-initial-view { padding: 15px; }
}