/**
 * Modern Search By Image Integration CSS
 * Styles for camera icon integration and modal
 */

/* Camera Icon Integration */
.search-image-icon {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #E8A623;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 10;
    padding: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-image-icon:hover {
    color: #d4941f;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(232, 166, 35, 0.3);
}

/* Ensure search input has enough padding for the icon */
input[data-search-image-icon-added="true"] {
    padding-right: 80px !important;
}

/* Modern Modal Styles */
.search-image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.search-image-modal-content {
    background-color: #fff;
    margin: 3% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: translateY(-50px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.search-image-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #E8A623 0%, #d4941f 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.search-image-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.search-image-modal-close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.search-image-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.search-image-modal-body {
    padding: 30px;
}

/* Upload Area Styles */
.image-upload-area {
    min-height: 200px !important;
    display: block !important;
    position: relative;
    border: 2px dashed #E8A623;
    border-radius: 12px;
    background: linear-gradient(135deg, #fefefe 0%, #f8f9fa 100%);
    transition: all 0.3s ease;
    cursor: pointer;
}

.image-upload-area:hover {
    border-color: #d4941a;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.image-upload-area.dragover {
    border-color: #28a745;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    transform: scale(1.02);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 180px;
    padding: 20px;
    text-align: center;
}

.upload-placeholder .fa-camera {
    font-size: 48px !important;
    color: #E8A623 !important;
    margin-bottom: 15px !important;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.upload-placeholder p {
    margin: 8px 0;
    font-size: 16px;
    color: #495057;
    font-weight: 500;
}

.upload-placeholder .upload-hint {
    font-size: 12px !important;
    color: #6c757d !important;
    font-weight: normal !important;
}

/* Image Preview - cleaner design without double border */
.image-preview {
    position: relative;
    text-align: center;
    padding: 20px;
    background: transparent;
    border: none;
    margin-top: 0;
}

.image-preview img {
    max-width: 200px !important;
    max-height: 150px !important;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    display: block;
    margin: 0 auto;
    border: 3px solid #fff;
}

/* Enhanced remove button - only X icon, no text */
.btn-remove-image {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc3545;
    color: white;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
    transition: all 0.2s ease;
    line-height: 1;
    text-align: center;
    /* Hide any text content */
    text-indent: -9999px;
    overflow: hidden;
}

.btn-remove-image:hover {
    background: #c82333;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.btn-remove-image::before {
    content: '×';
    font-size: 24px;
    line-height: 1;
    text-indent: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Search Controls */
.search-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding: 15px 0;
}

.search-controls .btn {
    min-width: 120px;
    padding: 10px 20px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.search-controls .btn-primary {
    background: linear-gradient(135deg, #E8A623 0%, #d4941a 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(232, 166, 35, 0.3);
}

.search-controls .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #d4941a 0%, #c08717 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(232, 166, 35, 0.4);
}

.search-controls .btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.search-controls .btn-secondary {
    background: #6c757d;
    border: none;
    color: white;
}

.search-controls .btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Search Results Preview */
.search-results-preview {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #f3f4f6;
}

.search-results-preview h4 {
    margin: 0 0 20px 0;
    color: #374151;
    font-size: 18px;
    font-weight: 600;
}

/* Loading States */
.waiting-message {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 1px solid #E8A623;
    border-radius: 12px;
    margin: 15px 0;
    animation: pulse 2s infinite;
    box-shadow: 0 4px 12px rgba(232, 166, 35, 0.2);
}

.waiting-message .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 4px 12px rgba(232, 166, 35, 0.2); }
    50% { box-shadow: 0 6px 20px rgba(232, 166, 35, 0.4); }
    100% { box-shadow: 0 4px 12px rgba(232, 166, 35, 0.2); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Success message for smooth transition */
.success-message {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #28a745;
    border-radius: 12px;
    padding: 20px;
    margin: 15px 0;
    text-align: center;
    color: #155724;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-image-modal-content {
        width: 95%;
        margin: 5% auto;
        border-radius: 12px;
    }
    
    .search-image-modal-header {
        padding: 20px 24px;
    }
    
    .search-image-modal-body {
        padding: 24px 20px;
    }
    
    .image-upload-area {
        padding: 40px 15px;
    }
    
    .upload-placeholder .fa-camera {
        font-size: 40px !important;
    }
    
    .search-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-controls .btn {
        width: 100%;
        padding: 16px 24px;
    }
    
    .search-image-icon {
        right: 15px;
        font-size: 18px;
    }
    
    input[data-search-image-icon-added="true"] {
        padding-right: 60px !important;
    }
}

@media (max-width: 480px) {
    .search-image-modal-content {
        width: 98%;
        margin: 2% auto;
        max-height: 96vh;
    }
    
    .search-image-modal-header h3 {
        font-size: 18px;
    }
    
    .image-upload-area {
        padding: 30px 15px;
    }
    
    .upload-placeholder p {
        font-size: 14px;
    }
    
    .search-image-icon {
        right: 10px;
        font-size: 16px;
        padding: 6px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .search-image-modal-content {
        border: 2px solid #000;
    }
    
    .search-image-icon {
        border: 1px solid #000;
    }
    
    .image-upload-area {
        border-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .search-image-modal,
    .search-image-modal-content,
    .search-image-icon,
    .btn,
    .image-upload-area {
        animation: none;
        transition: none;
    }
    
    .upload-placeholder .fa-camera {
        animation: none;
    }
}

.search-by-image-container {
    padding: 20px;
    margin-bottom: 30px;
}

.search-by-image-form {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.add-label-form {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-by-image-form .form-group,
.add-label-form .form-group {
    margin-bottom: 20px;
}

.search-by-image-form label,
.add-label-form label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.search-results-container {
    margin-top: 30px;
}

/* Prediction Results Styles */
.prediction-result {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    border-left: 4px solid #28a745;
}

.prediction-result h3 {
    margin-bottom: 15px;
    color: #495057;
}

.all-predictions {
    background: #ffffff;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-top: 15px;
}

.all-predictions h4 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1rem;
}

.predictions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.predictions-list .badge {
    font-size: 13px;
    padding: 8px 12px;
    font-weight: 500;
    border-radius: 20px;
}

.badge-success {
    background-color: #28a745;
    color: white;
}

.badge-secondary {
    background-color: #6c757d;
    color: white;
}

/* Product Items */
.product-item {
    height: 100%;
    transition: all 0.3s ease;
    border: 1px solid #dee2e6;
}

.product-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: #007bff;
}

.product-item img {
    object-fit: cover;
    height: 250px;
    width: 100%;
}

.product-item .card-body {
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.product-item .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #212529;
}

.product-item .card-text {
    flex-grow: 1;
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 10px;
}

.product-item .btn {
    margin-top: auto;
    font-weight: 500;
}

/* Loading Animation */
.spin {
    animation: spin 1s infinite linear;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Alert Styles */
.alert-dismissible {
    padding-right: 4rem;
}

.alert-dismissible .close {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.75rem 1.25rem;
    color: inherit;
}

/* Card Layout */
.card {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-by-image-container {
        padding: 10px;
    }
    
    .prediction-result,
    .all-predictions {
        padding: 15px;
    }
    
    .product-item img {
        height: 200px;
    }
    
    .predictions-list {
        justify-content: center;
    }
}

/* Upload area when image is selected */
.image-upload-area.has-image {
    border: 2px solid #28a745;
    background: linear-gradient(135deg, #f8fff8 0%, #f0f8f0 100%);
}

.image-upload-area.has-image:hover {
    border-color: #28a745;
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
}

/* No results message styling */
.no-results-message {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 1px solid #E8A623;
    border-radius: 12px;
    padding: 25px;
    margin: 15px 0;
    text-align: center;
    color: #856404;
    animation: slideIn 0.3s ease-out;
}

.no-results-message .fa-exclamation-triangle {
    font-size: 32px;
    margin-bottom: 15px;
    color: #E8A623;
}

.no-results-message h4 {
    margin: 10px 0;
    font-weight: bold;
    color: #856404;
    font-size: 18px;
}

.no-results-message p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #856404;
}

.no-results-message .suggestions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(232, 166, 35, 0.3);
}

.no-results-message .suggestions p {
    font-weight: 500;
    margin-bottom: 10px;
}

.no-results-message .suggestion-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.no-results-message .btn-suggestion {
    background: #E8A623;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.no-results-message .btn-suggestion:hover {
    background: #d4941a;
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
} 