/* ============================================
   MULTI-PAGE RECEIPT UPLOAD STYLES
   ============================================ */

/* Container */
.receipt-upload-container {
    padding: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Upload Header */
.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.upload-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.page-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: rgba(139, 92, 246, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(9, 15, 27, 0.3);
}

.drop-zone:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
    transform: translateY(-2px);
}

.drop-zone.drag-active {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: inline-block;
}

.drop-zone-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.drop-zone-subtitle {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.drop-zone-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Page Previews Grid */
.page-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    min-height: 50px;
}

.page-previews:empty {
    display: none;
}

/* Page Preview Cards */
.page-preview {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 2px solid var(--border-color);
    cursor: move;
    transition: all 0.2s ease;
    background: rgba(9, 15, 27, 0.5);
}

.page-preview:hover {
    border-color: #8b5cf6;
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(139, 92, 246, 0.2);
}

.page-preview.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.page-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Page Overlay */
.page-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.7) 0%,
        transparent 30%,
        transparent 70%,
        rgba(0,0,0,0.7) 100%
    );
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.5rem;
}

.page-preview:hover .page-overlay {
    opacity: 1;
}

.page-number {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0,0,0,0.6);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    align-self: flex-start;
    backdrop-filter: blur(4px);
}

/* Delete Button */
.btn-delete {
    align-self: flex-end;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

.btn-delete:active {
    transform: scale(0.95);
}

/* Drag Handle */
.drag-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    pointer-events: none;
}

.page-preview:hover .drag-handle {
    opacity: 1;
}

/* Upload Actions */
.upload-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.upload-actions button {
    min-width: 120px;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal Size Override */
.modal-lg {
    max-width: 900px;
    width: 90%;
}

/* Ensure modal is scrollable and properly sized */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.modal-overlay .modal-content {
    background: var(--card-bg, #1a2332);
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 0;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .receipt-upload-container {
        padding: 1rem;
    }

    .page-previews {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }

    .drop-zone-title {
        font-size: 1rem;
    }

    .upload-icon {
        font-size: 2.5rem;
    }

    .upload-actions {
        flex-direction: column-reverse;
    }

    .upload-actions button {
        width: 100%;
        min-width: 0;
    }

    .modal-lg {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .page-previews {
        grid-template-columns: repeat(2, 1fr);
    }

    .upload-header h3 {
        font-size: 1.125rem;
    }

    .page-count {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.drop-zone:focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 4px;
}

.btn-delete:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .drop-zone,
    .page-preview,
    .btn-delete,
    .spinner {
        animation: none;
        transition: none;
    }

    .page-preview:hover {
        transform: none;
    }
}

/* ============================================
   PROCESSING ANIMATION
   ============================================ */

.processing-container {
    text-align: center;
    padding: 2rem;
}

.processing-container h3 {
    margin-top: 1rem;
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.processing-container p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 0.9375rem;
}

.processing-steps {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.step-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.1);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.step.active .step-icon {
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    color: white;
    border-color: #8b5cf6;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.step-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.step.active .step-text {
    color: var(--text-primary);
    font-weight: 600;
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

.loading-spinner .spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@media (max-width: 640px) {
    .processing-steps {
        gap: 1rem;
    }

    .step-icon {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
    }

    .step-text {
        font-size: 0.75rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .receipt-upload-container,
    .processing-container {
        display: none;
    }
}
