/* ===================================================
   Visual Product Search by Image / Camera Styles
   =================================================== */

/* Camera / Lens Button inside Search Bars */
.btn-image-search-trigger:not(.btn):not(.btn-modern) {
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    margin: 0 4px;
    border-radius: 50%;
    color: #4b5563;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    flex-shrink: 0;
    z-index: 5;
}

.btn-image-search-trigger:not(.btn):not(.btn-modern):hover {
    color: var(--primary-color, #2563eb);
    background: rgba(37, 99, 235, 0.08);
    transform: scale(1.1);
}

.btn-image-search-trigger:not(.btn):not(.btn-modern) svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.btn-image-search-trigger:not(.btn):not(.btn-modern):hover svg {
    transform: rotate(-8deg);
}

/* Modal Overlay */
.img-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.img-search-overlay.active {
    display: flex;
    opacity: 1;
}

/* Modal Dialog */
.img-search-modal {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.img-search-overlay.active .img-search-modal {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.img-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
}

.img-search-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.img-search-icon-badge {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.img-search-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.img-search-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: #64748b;
}

.img-search-close-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.img-search-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

/* Modal Content Area */
.img-search-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

/* Options Selector (Camera vs File) */
.img-search-action-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.img-search-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 22px 16px;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    position: relative;
    user-select: none;
}

.img-search-action-btn:hover,
.img-search-action-btn.dragover {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.04);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(37, 99, 235, 0.12);
}

.img-search-action-btn.btn-camera-highlight {
    border-style: solid;
    border-color: #3b82f6;
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
}

.img-search-action-btn.btn-camera-highlight:hover {
    box-shadow: 0 8px 20px -4px rgba(59, 130, 246, 0.25);
}

.img-search-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: #2563eb;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease;
}

.img-search-action-btn:hover .img-search-action-icon {
    transform: scale(1.1);
}

.img-search-action-label {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.img-search-action-hint {
    font-size: 12px;
    color: #64748b;
}

/* Hidden Native Inputs */
.img-search-hidden-input {
    display: none !important;
}

/* Scanning / Preview State */
.img-search-preview-container {
    display: none;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.img-search-preview-box {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 16px;
    overflow: hidden;
    background: #0f172a;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    border: 3px solid #ffffff;
}

.img-search-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Glowing Laser Scanning Beam */
.img-search-laser {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0) 0%, #38bdf8 50%, rgba(37, 99, 235, 0) 100%);
    box-shadow: 0 0 15px #38bdf8, 0 0 25px #0284c7;
    animation: imgScanBeam 1.8s ease-in-out infinite alternate;
    z-index: 10;
}

@keyframes imgScanBeam {
    0% {
        top: 2%;
    }
    100% {
        top: 96%;
    }
}

.img-search-scanner-status {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #2563eb;
}

.img-search-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(37, 99, 235, 0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: imgSpinner 0.75s linear infinite;
}

@keyframes imgSpinner {
    to {
        transform: rotate(360deg);
    }
}

.img-search-retake-btn {
    margin-top: 10px;
    background: #f1f5f9;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}

.img-search-retake-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Results Grid */
.img-search-results-wrap {
    display: none;
    margin-top: 10px;
}

.img-search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.img-search-results-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.img-search-count-badge {
    background: #eff6ff;
    color: #2563eb;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.img-search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.img-search-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.img-search-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.08);
    border-color: #93c5fd;
}

.img-search-card-thumb-wrap {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: #f8fafc;
    overflow: hidden;
}

.img-search-card-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.img-search-card:hover .img-search-card-thumb {
    transform: scale(1.05);
}

.img-search-match-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(16, 185, 129, 0.92);
    backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.img-search-card-details {
    padding: 10px 12px 14px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.img-search-card-category {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 2px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.img-search-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.img-search-card-prices {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.img-search-card-price {
    font-size: 14.5px;
    font-weight: 700;
    color: #e11d48;
}

.img-search-card-old-price {
    font-size: 11.5px;
    color: #94a3b8;
    text-decoration: line-through;
}

.img-search-empty-state {
    text-align: center;
    padding: 36px 16px;
    color: #64748b;
}

.img-search-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .img-search-modal {
        max-height: 94vh;
        border-radius: 20px 20px 0 0;
        margin-top: auto;
        margin-bottom: 0;
    }

    .img-search-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .img-search-action-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .img-search-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}
