/**
 * Document Upload Styles
 *
 * Modal and components for OCR document extraction feature.
 */

/* ============================================
   Upload Trigger Button
   ============================================ */

.document-upload-trigger {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 12px;
    border: 1px dashed #0ea5e9;
}

.document-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: white;
    border: 2px solid #0ea5e9;
    border-radius: 8px;
    color: #0369a1;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.document-upload-btn:hover {
    background: #0ea5e9;
    color: white;
}

.document-upload-btn svg {
    flex-shrink: 0;
}

.upload-hint {
    font-size: 0.875rem;
    color: #64748b;
}

/* ============================================
   Modal
   ============================================ */

.document-upload-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.document-upload-modal.visible {
    opacity: 1;
    visibility: visible;
}

.document-upload-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 2rem;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.document-upload-modal.visible .document-upload-content {
    transform: scale(1);
}

.document-upload-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.document-upload-close:hover {
    background: #e2e8f0;
    color: #334155;
}

.document-upload-content h2 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.document-upload-subtitle {
    margin: 0 0 1.5rem;
    font-size: 0.9375rem;
    color: #64748b;
    line-height: 1.5;
}

/* ============================================
   Dropzone
   ============================================ */

.document-upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.document-upload-dropzone:hover,
.document-upload-dropzone.dragover {
    border-color: #0ea5e9;
    background: #f0f9ff;
}

.dropzone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: #94a3b8;
}

.document-upload-dropzone:hover .dropzone-icon,
.document-upload-dropzone.dragover .dropzone-icon {
    color: #0ea5e9;
}

.dropzone-text {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: #334155;
}

.dropzone-hint {
    margin: 0;
    font-size: 0.875rem;
    color: #94a3b8;
}

/* ============================================
   Preview
   ============================================ */

.document-upload-preview {
    text-align: center;
}

#document-preview-img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ============================================
   Progress
   ============================================ */

.document-upload-progress {
    text-align: center;
    padding: 2rem;
}

.progress-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border: 4px solid #e2e8f0;
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-text {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: #334155;
}

.progress-hint {
    margin: 0;
    font-size: 0.875rem;
    color: #94a3b8;
}

/* ============================================
   Result
   ============================================ */

.document-upload-result {
    text-align: center;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #10b981;
    border-radius: 50%;
    color: white;
    font-size: 1rem;
}

.result-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
}

.result-fields {
    text-align: left;
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.result-field {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.result-field:last-of-type {
    border-bottom: none;
}

.field-label {
    font-weight: 500;
    color: #64748b;
}

.field-value {
    font-weight: 600;
    color: #1e293b;
}

.result-confidence {
    margin-top: 0.75rem;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

.confidence-high {
    background: #d1fae5;
    color: #065f46;
}

.confidence-medium {
    background: #fef3c7;
    color: #92400e;
}

.confidence-low {
    background: #fee2e2;
    color: #991b1b;
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ============================================
   Error
   ============================================ */

.document-upload-error {
    text-align: center;
    padding: 1.5rem;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #f59e0b;
}

.error-message {
    margin: 0 0 1.5rem;
    font-size: 1rem;
    color: #64748b;
}

/* ============================================
   Toast Queue System
   ============================================ */

/* Container for stacked toasts */
.document-toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    z-index: 10000;
    pointer-events: none;
}

/* Individual toast in queue */
.document-toast {
    padding: 0.75rem 1.5rem;
    background: #1e293b;
    color: white;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    white-space: nowrap;
    max-width: 90vw;
    text-overflow: ellipsis;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.document-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.document-toast.success {
    background: #10b981;
}

.document-toast.error {
    background: #ef4444;
}

.document-toast.warning {
    background: #f59e0b;
}

.document-toast.info {
    background: #0ea5e9;
}

/* ============================================
   Buttons (reuse existing styles or define)
   ============================================ */

.document-upload-content .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.document-upload-content .btn-primary {
    background: #0ea5e9;
    color: white;
}

.document-upload-content .btn-primary:hover {
    background: #0284c7;
}

.document-upload-content .btn-secondary {
    background: #f1f5f9;
    color: #334155;
}

.document-upload-content .btn-secondary:hover {
    background: #e2e8f0;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 640px) {
    .document-upload-content {
        padding: 1.5rem;
        margin: 0.5rem;
    }

    .document-upload-content h2 {
        font-size: 1.25rem;
    }

    .preview-actions,
    .result-actions {
        flex-direction: column;
    }

    .preview-actions .btn,
    .result-actions .btn {
        width: 100%;
    }
}

/* ============================================
   OCR Indicators
   ============================================ */

/* Input field filled via OCR */
.ocr-filled {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    border-color: #0ea5e9 !important;
}

.ocr-filled:focus {
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15) !important;
}

/* Badge next to label */
.ocr-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #1d4ed8;
    vertical-align: middle;
}

/* Banner at top of form */
.ocr-source-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 10px;
    font-size: 0.875rem;
    color: #0369a1;
}

.ocr-source-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.ocr-source-text {
    flex: 1;
}

.ocr-source-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: transparent;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ocr-source-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #334155;
}
