/* =============================================================================
   DOCUMENT SCANNER STYLES — Casa DW
   Extends the existing modal-fix-v2 CSS for the new 3-step scanner workflow
   ============================================================================= */

/* --- Step Indicators --- */
.scanner-steps {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 auto;
}

.scanner-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: #6b7280;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.scanner-step .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2a2f3e;
    color: #6b7280;
    font-weight: 700;
    font-size: 11px;
    transition: all 0.3s ease;
}

.scanner-step.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.15);
}

.scanner-step.active .step-num {
    background: #3b82f6;
    color: #fff;
}

.scanner-step.completed {
    color: #10b981;
}

.scanner-step.completed .step-num {
    background: #10b981;
    color: #fff;
}

.scanner-step .step-label {
    font-weight: 500;
}

/* Insert chevrons between steps */
.scanner-step + .scanner-step::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5l7 7-7 7'/%3E%3C/svg%3E");
    background-size: contain;
    flex-shrink: 0;
}

/* --- Scanner Panels --- */
.scanner-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* --- Step 1: Image + Overlay Wrapper --- */
#scannerCanvasArea {
    flex: 1 1 auto;
    min-height: 250px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #111526;
    position: relative;
}

.scanner-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.scanner-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    cursor: default;
    touch-action: none;
}

/* --- Step 2: Filter Selector --- */
.filter-selector {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: #1e2333;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    overflow-x: auto;
    flex-shrink: 0;
}

.filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #252a3b;
    color: #a0a8c0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 500;
    min-width: 90px;
    flex-shrink: 0;
}

.filter-btn:hover {
    background: #2e3449;
    color: #d0d5e0;
}

.filter-btn.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    color: #fff;
}

.filter-preview {
    border-radius: 4px;
    background: #1a1f2e;
    display: block;
}

/* --- Step 2: Filter Canvas Area --- */
#step2CanvasArea {
    flex: 1 1 auto;
    min-height: 200px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background: #111526;
    padding: 12px;
}

.filter-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    border-radius: 2px;
}

/* --- Step 3: Pages Info Bar --- */
.pages-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #1e2333;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.pages-info span {
    color: #d0d5e0;
    font-size: 14px;
    font-weight: 600;
}

.btn-sm {
    padding: 4px 12px !important;
    font-size: 12px !important;
}

/* --- Step 3: Pages Queue --- */
.pages-queue {
    display: flex;
    gap: 12px;
    padding: 20px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1 1 auto;
    align-items: flex-start;
    align-content: flex-start;
    flex-wrap: wrap;
    background: #151828;
    min-height: 200px;
}

.page-thumb {
    position: relative;
    width: 120px;
    height: 170px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #1e2333;
    border: 2px solid rgba(255,255,255,0.08);
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.page-thumb:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(59,130,246,0.2);
}

.page-thumb.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.page-thumb.drag-over {
    border-color: #10b981;
    background: rgba(16,185,129,0.1);
}

.page-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.page-number {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.page-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.page-thumb:hover .page-remove {
    opacity: 1;
}

/* --- Step 3: Combine Options --- */
.combine-options {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    background: #1e2333;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.combine-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a0a8c0;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.combine-label:hover {
    background: rgba(255,255,255,0.05);
    color: #d0d5e0;
}

.combine-label input[type="radio"] {
    accent-color: #3b82f6;
}

.combine-label i {
    color: #3b82f6;
    font-size: 16px;
}

/* --- Receipt Count Badge --- */
.receipt-count-badge {
    width: 100%;
    text-align: center;
    padding: 6px 0;
    color: #6b7280;
    font-size: 11px;
    font-style: italic;
}

/* --- Margin Controls Bar --- */
.margin-controls-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #1a1f2e;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.margin-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    min-width: 70px;
}

.margin-label i {
    color: #10b981;
    font-size: 14px;
}

.margin-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #252a3b;
    border: 1px solid rgba(255,255,255,0.1);
    color: #d0d5e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.margin-btn:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.margin-btn:active {
    transform: scale(0.92);
}

.margin-btn-reset {
    margin-left: 4px;
}

.margin-btn-reset:hover {
    background: #f59e0b;
    border-color: #f59e0b;
}

.margin-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #f59e0b, #374151 45%, #374151 55%, #10b981);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    min-width: 80px;
    max-width: 200px;
}

.margin-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #3b82f6;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: box-shadow 0.15s ease;
}

.margin-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
}

.margin-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #3b82f6;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.margin-value {
    font-size: 12px;
    font-weight: 700;
    min-width: 36px;
    text-align: center;
    color: #9ca3af;
    font-family: 'Courier New', monospace;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .scanner-steps {
        gap: 2px;
    }
    .scanner-step {
        padding: 3px 8px;
        font-size: 11px;
    }
    .scanner-step .step-label {
        display: none;
    }
    .scanner-step.active .step-label {
        display: inline;
    }
    .filter-selector {
        gap: 6px;
        padding: 8px 12px;
    }
    .filter-btn {
        min-width: 75px;
        font-size: 10px;
    }
    .filter-preview {
        width: 60px !important;
        height: 45px !important;
    }
    .pages-queue {
        padding: 12px;
        gap: 8px;
    }
    .page-thumb {
        width: 90px;
        height: 130px;
    }
    .combine-options {
        flex-direction: column;
        gap: 8px;
    }
    .margin-controls-bar {
        padding: 6px 10px;
        gap: 6px;
    }
    .margin-label span {
        display: none;
    }
    .margin-label {
        min-width: auto;
    }
    .margin-slider {
        max-width: 140px;
    }
}

@media (max-width: 480px) {
    .scanner-step + .scanner-step::before {
        display: none;
    }
    .editor-header {
        flex-wrap: wrap;
        gap: 6px;
    }
    .scanner-steps {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}
