/* ============================================================
 * VHANDY ECO — AI Image Search Styles
 * Tính năng tìm kiếm sản phẩm bằng hình ảnh AI
 * ============================================================ */

/* ── Phân cách giữa text search và image search ─────────────── */
.image-search-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 16px;
    color: rgba(255,255,255,0.45);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.image-search-divider::before,
.image-search-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.15);
}

/* ── Khu vực drag & drop ──────────────────────────────────────── */
.image-upload-zone {
    position: relative;
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 14px;
    padding: 20px;
    cursor: pointer;
    text-align: center;
    transition: all 0.25s ease;
    background: rgba(255,255,255,0.04);
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-upload-zone:hover,
.image-upload-zone.drag-over {
    border-color: rgba(107,155,125,0.7);
    background: rgba(107,155,125,0.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(107,155,125,0.15);
}
.image-upload-zone.has-image {
    border-style: solid;
    border-color: rgba(107,155,125,0.5);
    padding: 10px;
    min-height: unset;
}

/* File input phủ toàn bộ zone - cách đáng tin cậy nhất để mở file picker */
.image-upload-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    font-size: 0; /* ẩn tên file mặc định */
}
/* Ẩn input khi đã có ảnh (để nút X hoạt động) */
.image-upload-zone.has-image input[type="file"] {
    display: none;
}


/* Placeholder nội dung */
.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.upload-placeholder i {
    font-size: 28px;
    color: rgba(255,255,255,0.35);
    transition: color 0.2s;
}
.image-upload-zone:hover .upload-placeholder i {
    color: rgba(107,155,125,0.8);
}
.upload-placeholder span {
    color: rgba(255,255,255,0.55);
    font-size: 13px;
}
.upload-placeholder span strong {
    color: rgba(107,155,125,0.9);
}
.upload-placeholder small {
    color: rgba(255,255,255,0.3);
    font-size: 11px;
}

/* Preview ảnh đã chọn */
.upload-preview {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}
.upload-preview #previewImg {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid rgba(107,155,125,0.4);
    flex-shrink: 0;
}
.upload-preview-info {
    flex: 1;
    min-width: 0;
}
.upload-preview-name {
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-preview-size {
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    margin-top: 3px;
}
.remove-image {
    background: rgba(231,76,60,0.2);
    border: 1px solid rgba(231,76,60,0.3);
    color: #e74c3c;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
    margin-left: auto;
}
.remove-image:hover {
    background: rgba(231,76,60,0.35);
    transform: scale(1.1);
}

/* ── Nút tìm kiếm bằng ảnh ───────────────────────────────────── */
.btn-image-search {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6B8F71, #4a7a55);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    letter-spacing: 0.3px;
}
.btn-image-search:hover:not(:disabled) {
    background: linear-gradient(135deg, #7a9e80, #5a8a65);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(107,143,113,0.35);
}
.btn-image-search:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}
.btn-image-search.loading {
    pointer-events: none;
    opacity: 0.8;
}
.btn-image-search .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: imgSearchSpin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes imgSearchSpin {
    to { transform: rotate(360deg); }
}

/* ── Khu vực kết quả ─────────────────────────────────────────── */
.image-search-results {
    margin-top: 20px;
    animation: imgResultsFadeIn 0.4s ease;
}
@keyframes imgResultsFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.results-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.results-ai-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, rgba(107,155,125,0.2), rgba(74,122,85,0.15));
    border: 1px solid rgba(107,155,125,0.3);
    color: rgba(107,155,125,1);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.results-ai-tag i {
    font-size: 10px;
}
.results-analysis {
    color: rgba(255,255,255,0.55);
    font-size: 12px;
    line-height: 1.4;
    flex: 1;
}
.results-count-badge {
    color: rgba(255,255,255,0.35);
    font-size: 11px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Grid sản phẩm kết quả ───────────────────────────────────── */
.image-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
@media (min-width: 640px) {
    .image-results-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 900px) {
    .image-results-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ── Card sản phẩm nhỏ trong kết quả ────────────────────────── */
.img-result-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
}
.img-result-card:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(107,155,125,0.35);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.img-result-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: rgba(255,255,255,0.04);
}
.img-result-info {
    padding: 8px 10px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.img-result-cat {
    font-size: 10px;
    color: rgba(107,155,125,0.8);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}
.img-result-name {
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}
.img-result-material {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Trạng thái Empty / Error ────────────────────────────────── */
.img-search-empty {
    text-align: center;
    padding: 24px 16px;
    color: rgba(255,255,255,0.4);
}
.img-search-empty i {
    font-size: 32px;
    display: block;
    margin-bottom: 10px;
    opacity: 0.5;
}
.img-search-empty p {
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}
.img-search-error {
    background: rgba(231,76,60,0.1);
    border: 1px solid rgba(231,76,60,0.25);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.img-search-error i {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 1px;
    flex-shrink: 0;
}
.img-search-error span {
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    line-height: 1.5;
}

/* ── Skeleton Loading ────────────────────────────────────────── */
.img-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
@media (min-width: 640px) {
    .img-skeleton-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
    .img-skeleton-grid { grid-template-columns: repeat(4, 1fr); }
}
.img-skeleton-card {
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
}
.img-skeleton-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.05) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.05) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
.img-skeleton-text {
    padding: 8px 10px;
}
.img-skeleton-line {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.05) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.05) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    margin-bottom: 6px;
}
.img-skeleton-line:last-child { width: 65%; }
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── AI Badge nhỏ trong search panel header ──────────────────── */
.search-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, rgba(107,155,125,0.15), rgba(74,122,85,0.1));
    border: 1px solid rgba(107,155,125,0.2);
    color: rgba(107,155,125,0.9);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}
