/* ============================================
   RECEIPT SCANNER MODAL STYLES
   ============================================ */

/* Scanner Modal Base */
.receipt-scanner-modal .modal-content {
    max-width: 900px;
    height: 90vh;
    max-height: 800px;
}

.receipt-scanner-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.scanner-icon {
    font-size: 1.5rem;
}

.scanner-body {
    padding: 0;
    overflow: hidden;
}

/* Choice Screen */
.scanner-choice {
    padding: 2rem;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.choice-btn {
    padding: 2rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.choice-btn:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
    transform: translateY(-2px);
}

.choice-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.choice-btn h4 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.choice-btn p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Ensure text is always readable */
@media (prefers-color-scheme: light) {
    .choice-btn h4 {
        color: #1e293b;
    }

    .choice-btn p {
        color: #64748b;
    }
}

.scanner-tips {
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
}

.scanner-tips h5 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.scanner-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.scanner-tips li {
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.25rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.scanner-tips li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #8b5cf6;
}

/* Camera View */
.scanner-camera {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

#camera-preview {
    width: 100%;
    flex: 1;
    object-fit: cover;
    background: #000;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 80px;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-frame {
    width: 80%;
    max-width: 400px;
    aspect-ratio: 8.5 / 11;
    border: 3px dashed rgba(139, 92, 246, 0.8);
    border-radius: 8px;
    background: rgba(139, 92, 246, 0.1);
}

.camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem;
    background: rgba(10, 14, 26, 0.95);
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-capture {
    min-width: 200px;
    font-size: 1.125rem;
    padding: 1rem 2rem;
}

/* Preview View */
.scanner-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: auto;
}

#preview-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-actions {
    padding: 1.5rem;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.preview-actions .btn-primary {
    min-width: 200px;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Processing View */
.scanner-processing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    padding: 3rem 2rem;
}

.processing-animation {
    text-align: center;
    max-width: 400px;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    margin: 0 auto 2rem;
    animation: spin 1s linear infinite;
}

.processing-animation h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.processing-status {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.processing-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.step.active {
    opacity: 1;
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}

.step.complete {
    opacity: 1;
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.step-icon {
    font-size: 1.25rem;
}

.step-text {
    flex: 1;
    text-align: left;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

/* ============================================
   RECEIPT REVIEW MODAL STYLES
   ============================================ */

.receipt-review-modal .modal-content {
    max-width: 1400px;
    height: 90vh;
}

.receipt-review-modal .modal-header {
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.confidence-badge.confidence-high {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.confidence-badge.confidence-medium {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.confidence-badge.confidence-low {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.review-body {
    padding: 0;
    overflow: hidden;
}

.review-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    height: 100%;
}

/* Image Panel */
.review-image-panel {
    background: #000;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h4 {
    color: var(--text-primary);
    font-size: 1rem;
    margin: 0;
}

.helper-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.receipt-image-container {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.receipt-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.receipt-image.zoomed {
    transform: scale(1.5);
    cursor: zoom-out;
}

/* Form Panel */
.review-form-panel {
    background: var(--bg-primary);
    overflow-y: auto;
}

.review-form {
    padding: 1.5rem;
}

.form-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.9375rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.modified-field {
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.05) !important;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* Confidence Meters */
.confidence-meter {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meter-bar {
    flex: 1;
    height: 6px;
    background: rgba(100, 116, 139, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

.confidence-meter.confidence-high .meter-fill {
    background: #10b981;
}

.confidence-meter.confidence-medium .meter-fill {
    background: #f59e0b;
}

.confidence-meter.confidence-low .meter-fill {
    background: #ef4444;
}

.meter-label {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

.confidence-meter.confidence-high .meter-label {
    color: #10b981;
}

.confidence-meter.confidence-medium .meter-label {
    color: #f59e0b;
}

.confidence-meter.confidence-low .meter-label {
    color: #ef4444;
}

/* Line Items */
.line-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.line-item-card {
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    padding: 1rem;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.item-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #8b5cf6;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}

.item-description {
    flex: 1;
    color: var(--text-primary);
    font-weight: 600;
}

.item-details {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 2.5rem;
    font-size: 0.875rem;
}

.item-type {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    color: #8b5cf6;
}

.item-quantity {
    color: var(--text-secondary);
}

.item-price {
    margin-left: auto;
    font-weight: 700;
    color: var(--text-primary);
}

/* Review Footer */
.review-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-icon {
    font-size: 1.25rem;
}

.footer-actions {
    display: flex;
    gap: 1rem;
}

/* Modal overlay z-index (above mobile nav) */
.receipt-scanner-modal,
.receipt-review-modal {
    z-index: 10000;
}

.modal-overlay {
    z-index: 10000;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .review-layout {
        grid-template-columns: 1fr;
    }

    .review-image-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .choice-grid {
        grid-template-columns: 1fr;
    }

    .receipt-scanner-modal .modal-content,
    .receipt-review-modal .modal-content {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .scanner-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: calc(100vh - 80px); /* Account for header */
    }

    /* Camera view adjustments for mobile */
    .scanner-camera {
        min-height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #camera-preview {
        min-height: calc(100vh - 250px);
    }

    .camera-controls {
        position: sticky;
        bottom: 0;
        padding: 1rem;
        z-index: 10;
    }

    .btn-capture {
        min-width: 150px;
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }

    /* Preview adjustments */
    .scanner-preview {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .preview-actions {
        position: sticky;
        bottom: 0;
        padding: 1rem;
        z-index: 10;
    }

    /* Choice screen padding */
    .scanner-choice {
        padding: 1.5rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .review-footer {
        flex-direction: column;
        gap: 1rem;
    }

    .footer-actions {
        width: 100%;
        flex-direction: column;
    }

    .footer-actions button {
        width: 100%;
    }
}

/* File Input Styling */
#receipt-file-input {
    display: none;
}

/* When file is selected, show filename */
.file-selected {
    color: var(--text-primary);
    background: var(--card-bg);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    text-align: center;
}

/* Utility Classes */
.hidden {
    display: none !important;
}
