/* Lens Search Button */
.lens {
    position: absolute;
    right: 65px; /* Increased from 60px to prevent overlap with the main search button */
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s ease;
    border-radius: 4px;
    z-index: 10;
}

.lens:hover {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.1);
}

.lens:active {
    transform: translateY(-50%) scale(0.95);
}

.searchbox-icon-button svg {
    width: 20px;
    height: 20px;
}

/* Ensure the search input has enough padding to prevent text overlapping the new button */
.search-bar input {
    padding-right: 110px !important;
}

/* Ensure the search bar accommodates the new button seamlessly */
.search-bar {
    position: relative;
    /* Removed display: flex to prevent conflicts with existing Marketonex styles */
}

/* Lens Popup UI */
#lens-popup {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    padding: 16px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 12px;
    transform-origin: top right;
    animation: mx-popup-fade-in 0.2s ease-out forwards;
}

@keyframes mx-popup-fade-in {
    from { opacity: 0; transform: scale(0.95) translateY(-5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

#lens-popup.visible {
    display: flex;
}

#lens-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

#lens-popup-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

#lens-popup-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 18px;
    padding: 4px;
}

#lens-popup-header button:hover {
    color: #4b5563;
}

#lens-popup-desc {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.lens-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.lens-action-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.lens-action-btn i {
    font-size: 16px;
    color: #3b82f6;
}

/* Image Preview & Text Input Area */
#lens-preview-container {
    display: none;
    flex-direction: column;
    gap: 12px;
}

#lens-image-preview {
    width: 100%;
    height: 120px;
    object-fit: contain;
    border-radius: 8px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

#lens-text-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

#lens-text-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

#lens-submit-btn {
    width: 100%;
    padding: 10px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#lens-submit-btn:hover {
    background: #2563eb;
}

/* Loading State */
#lens-loading-container {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
    gap: 16px;
}

.lens-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: lens-spin 1s linear infinite;
}

@keyframes lens-spin {
    to { transform: rotate(360deg); }
}

#lens-loading-text {
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    animation: pulse-text 1.5s infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Fallback message toast */
.lens-fallback-toast {
    background: #fffbeb;
    color: #92400e;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #fcd34d;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fade-in 0.3s ease-out;
}

.lens-fallback-toast i {
    font-size: 18px;
    color: #d97706;
}
