/* Modern Upload Form Styling - Best Practice Design */

/* Combined Upload Container */
.combined-upload-container {
    display: block;
}

.upload-area {
    margin-bottom: 20px;
}

.details-form {
    border-top: 1px solid #e1e5e9;
    padding-top: 20px;
    animation: slideDown 0.3s ease-out;
}

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

.details-form .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: start;
}

.details-form .form-group.full-width {
    grid-column: 1 / -1;
}

/* Responsive layout adjustments */
@media (max-width: 767px) {
    .details-form .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Processed Image Display */
#processedImageContainer {
    background: #f8f9fa;
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    margin-top: 15px;
}

#processedImagePreview {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: block;
    margin: 0 auto;
}

#scoreDisplay {
    font-size: 18px;
    font-weight: bold;
    color: #28a745;
    margin-top: 10px;
}

.processing-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

/* Modern Modal Styling */
.modern-modal {
    z-index: 10002 !important; /* Ensure upload modal appears above hunt feed */
}

.modern-modal .modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

/* Ensure upload modal backdrop is properly layered */
#uploadImageModal {
    z-index: 10002 !important;
}

#uploadImageModal + .modal-backdrop,
#uploadImageModal ~ .modal-backdrop {
    z-index: 10001 !important;
}

/* Force upload modal to be interactive */
#uploadImageModal .modal-dialog {
    position: relative;
    z-index: 10003 !important;
    pointer-events: auto !important;
}

#uploadImageModal .modal-content {
    position: relative;
    z-index: 10004 !important;
    pointer-events: auto !important;
}

/* Ensure form elements in upload modal are properly styled */
#uploadImageModal .form-select,
#uploadImageModal .form-input,
#uploadImageModal select,
#uploadImageModal input {
    padding: 0.75rem !important;
    border: 1px solid #e1e5e9 !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    background: white !important;
    width: 100% !important;
    box-sizing: border-box !important;
    appearance: auto !important;
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
}

#uploadImageModal .form-group {
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: 1rem !important;
}

#uploadImageModal .form-label {
    margin-bottom: 0.5rem !important;
    font-weight: 500 !important;
    color: #333 !important;
}

.modern-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-bottom: none;
    padding: 1.5rem 2rem;
}

.modern-header .modal-title {
    font-weight: 600;
    font-size: 1.25rem;
    margin: 0;
}

.modern-close {
    color: white !important;
    opacity: 1 !important;
    text-shadow: none;
    font-size: 1.8rem;
    font-weight: 300;
    padding: 0;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    cursor: pointer;
}

.modern-close span {
    display: block;
    font-size: 1.5rem;
    line-height: 1;
    margin-top: -2px;
}

.modern-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
    border-color: rgba(255,255,255,0.5);
}

.modern-body {
    padding: 2rem;
    background: #fafbfc;
}

.modern-footer {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-lg {
    max-width: 700px;
}

.modern-upload-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0;
}

/* Single column layout */
.upload-content-grid {
    display: block;
}

.upload-area-section {
    margin-bottom: 1.5rem;
}

.form-section {
    display: block;
}

/* Processing Results Section at Bottom */
.processing-results-section {
    margin-top: 3rem;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 16px;
    border: 1px solid #e9ecef;
}

/* Step Indicator */
.upload-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    padding: 0 2rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.step-label {
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: #007bff;
    color: white;
}

.step.active .step-label {
    color: #007bff;
}

.step.completed .step-number {
    background: #28a745;
    color: white;
}

.step.completed .step-label {
    color: #28a745;
}

.step-connector {
    flex: 1;
    height: 2px;
    background: #e9ecef;
    margin: 0 1rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.step.completed + .step-connector {
    background: #28a745;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #e9ecef;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #fafbfc;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: #007bff;
    background: #f8f9ff;
}

.upload-area.drag-over {
    border-color: #007bff;
    background: #e3f2fd;
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    color: #6c757d;
    margin-bottom: 1rem;
}

.upload-content h3 {
    margin: 0;
    color: #333;
    font-weight: 600;
    font-size: 1.2rem;
}

.upload-content p {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
}

.upload-browse-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-browse-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

/* Image Preview */
.image-preview {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    text-align: left;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.image-preview img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.image-info {
    flex: 1;
}

.image-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.image-size {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.change-image-btn {
    background: #f8f9fa;
    color: #007bff;
    border: 1px solid #e9ecef;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.change-image-btn:hover {
    background: #e9ecef;
    border-color: #007bff;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.label-required {
    color: #dc3545;
    font-weight: 600;
}

.form-select, .form-input {
    padding: 0.75rem !important;
    border: 1px solid #e1e5e9 !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    background: white !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.form-select:focus, .form-input:focus {
    outline: none !important;
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1) !important;
}

.form-help {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.help-icon {
    font-size: 0.9rem;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #e1e5e9;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: #007bff;
    border-color: #007bff;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Progress and Results */
.upload-progress, .upload-success, .upload-error {
    text-align: center;
    padding: 2rem;
}

/* Success Actions */
.success-actions {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.auto-redirect {
    padding: 1rem;
    background: rgba(0, 123, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(0, 123, 255, 0.2);
}

.redirect-text {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.redirect-text svg {
    color: #007bff;
}

.redirect-text span {
    font-weight: 600;
    color: #007bff;
}

.cancel-redirect {
    background: none !important;
    border: none !important;
    color: #6c757d !important;
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 0.25rem 0;
}

.cancel-redirect:hover {
    color: #495057 !important;
    text-decoration: none;
}

.progress-animation, .success-animation, .error-animation {
    margin-bottom: 1.5rem;
}

.progress-circle {
    position: relative;
    display: inline-block;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: #e9ecef;
    stroke-width: 4;
}

.progress-ring-fill {
    fill: none;
    stroke: #007bff;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 220;
    stroke-dashoffset: 220;
    animation: progress-fill 3s ease-in-out infinite;
}

@keyframes progress-fill {
    0% { stroke-dashoffset: 220; }
    50% { stroke-dashoffset: 110; }
    100% { stroke-dashoffset: 220; }
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    color: #007bff;
}

.success-checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #28a745;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    animation: success-bounce 0.6s ease;
}

@keyframes success-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.error-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    animation: error-shake 0.6s ease;
}

@keyframes error-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Action Buttons */
.upload-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

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

.btn-success:hover {
    background: #1e7e34;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40,167,69,0.3);
}

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

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108,117,125,0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modern-upload-container {
        padding: 0 1rem;
        max-width: 100%;
    }
    
    /* Mobile adjustments */
    .upload-area-section {
        margin-bottom: 1rem;
    }
    
    .processing-results-section {
        margin-top: 2rem;
        padding: 1.5rem;
    }
    
    .upload-steps {
        padding: 0 1rem;
    }
    
    .step-connector {
        margin: 0 0.5rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .image-preview {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .upload-actions {
        flex-direction: column-reverse;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .upload-steps {
        padding: 0 0.5rem;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .step-label {
        font-size: 11px;
    }
    
    .upload-area {
        padding: 1.5rem 1rem;
    }
    
    .upload-content h3 {
        font-size: 1rem;
    }
}

/* Progressive Processing UI Styles */
.processing-status {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
    animation: fadeIn 0.3s ease-out;
}

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

.processing-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.processing-message {
    text-align: center;
    font-weight: 600;
    color: #28a745;
    margin-bottom: 15px;
    font-size: 16px;
}

.processing-progress {
    margin-bottom: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    border-radius: 4px;
    transition: width 0.3s ease-out;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.processed-image-container {
    margin-top: 20px;
    text-align: center;
    animation: slideUp 0.5s ease-out;
}

.processed-image-container h4 {
    color: #28a745;
    margin-bottom: 15px;
    font-size: 18px;
}

.processed-image-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 2px solid #28a745;
}

.score-container {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 8px;
    text-align: center;
    animation: scoreReveal 0.5s ease-out;
}

.score-container h4 {
    margin: 0;
    font-size: 20px;
    font-weight: bold;
}

#aiScore {
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes scoreReveal {
    from { 
        opacity: 0; 
        transform: scale(0.8) translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

/* Elegant Processing UI Redesign */
.processing-status {
    margin-top: 30px;
    padding: 0;
    background: transparent;
    border: none;
    animation: fadeIn 0.4s ease-out;
}

.processing-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 123, 255, 0.1);
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.processing-message {
    text-align: center;
    font-size: 15px;
    color: #6c757d;
    margin-bottom: 20px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.processing-progress {
    margin-bottom: 30px;
    padding: 0 10px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #f1f3f4;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Processed Image Container - Clean Card Design */
.processed-image-container {
    margin: 30px 0;
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.processed-image-container h4 {
    color: #28a745;
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.processed-image-container img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 2px solid #e8f5e8;
    transition: transform 0.2s ease;
}

.processed-image-container img:hover {
    transform: scale(1.02);
}

/* Score Container - Premium Card Design */
.score-container {
    margin: 20px 0 0 0;
    padding: 20px 24px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(40, 167, 69, 0.3);
    animation: scoreReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.score-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255,255,255,0.1) 50%,
        transparent 70%
    );
    pointer-events: none;
}

.score-container h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.95;
}

#aiScore {
    font-size: 28px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* Responsive adjustments for processing UI */
@media (max-width: 768px) {
    .processing-status {
        margin-top: 20px;
    }
    
    .processing-message {
        font-size: 14px;
    }
    
    .processed-image-container {
        margin: 20px 0;
        padding: 20px;
    }
    
    .processed-image-container img {
        max-height: 300px;
    }
    
    .image-preview img {
        width: 100px;
        height: 100px;
    }
    
    .score-container {
        padding: 16px 20px;
    }
    
    .score-container h4 {
        font-size: 15px;
    }
    
    #aiScore {
        font-size: 24px;
    }
}