/* Document Scanner — Fullscreen modal, viewport-locked */
#doc-scanner-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 10000; background: #000; display: flex; flex-direction: column;
    overflow: hidden; /* nunca scroll en el overlay */
}
.ds-header {
    display: flex; align-items: center; padding: 6px 10px; background: #111;
    color: #fff; gap: 6px; flex-shrink: 0;
}
.ds-title { font-weight: 600; font-size: 0.9rem; flex: 1; }
.ds-page-count { font-size: 0.8rem; color: #9ca3af; }
.ds-body {
    flex: 1; display: flex; overflow: hidden; position: relative;
    min-height: 0; /* permite que flex children se contraigan */
}
.ds-body > div {
    position: absolute; inset: 0; display: none; flex-direction: column;
    overflow: hidden;
}
.ds-body > div.ds-active { display: flex; }

/* Camera */
.ds-camera-view { background: #000; }

/* Preview — imagen + controles + botones, todo en viewport */
.ds-preview-view { background: #1a1a1a; }
.ds-preview-canvas {
    flex: 1; width: 100%; min-height: 0;
    object-fit: contain;
}
.ds-preview-controls {
    padding: 6px 10px; background: #111; flex-shrink: 0;
    overflow-x: auto;
}
.ds-slider-row {
    display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
    flex-wrap: wrap;
}
.ds-slider-label {
    color: #9ca3af; font-size: 0.75rem; min-width: 55px; text-align: right;
}
.ds-slider {
    flex: 1; min-width: 80px; height: 4px;
    -webkit-appearance: none; appearance: none;
    background: #374151; border-radius: 2px; outline: none;
}
.ds-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 22px; height: 22px;
    border-radius: 50%; background: #2563eb; cursor: pointer;
}
.ds-checkbox-label {
    color: #9ca3af; font-size: 0.8rem; display: flex; align-items: center; gap: 3px;
}
.ds-preview-actions {
    display: flex; gap: 6px; padding: 8px 10px; justify-content: center;
    background: #111; flex-shrink: 0; flex-wrap: wrap;
}

/* Pages grid */
.ds-pages-view { background: #1a1a1a; padding: 10px; overflow-y: auto; }
.ds-pages-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px; align-content: start;
}
.ds-page-thumb {
    position: relative; background: #fff; border-radius: 4px;
    overflow: hidden; cursor: grab; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.ds-page-thumb canvas { width: 100%; display: block; }
.ds-page-label {
    display: block; text-align: center; font-size: 0.65rem;
    color: #666; padding: 2px 0;
}
.ds-page-rotate {
    position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
    border-radius: 50%; border: none; background: rgba(37,99,235,0.9);
    color: #fff; font-size: 12px; cursor: pointer; line-height: 1;
}
.ds-page-delete {
    position: absolute; top: 2px; right: 2px; width: 22px; height: 22px;
    border-radius: 50%; border: none; background: rgba(220,38,38,0.9);
    color: #fff; font-size: 14px; cursor: pointer; line-height: 1;
}
.ds-enhance-status { color: #fbbf24; font-size: 0.75rem; }
.ds-drag-over { outline: 2px solid #2563eb; outline-offset: 2px; }
.ds-pages-actions {
    display: flex; gap: 6px; padding: 8px 0 0; justify-content: center;
    flex-shrink: 0; flex-wrap: wrap;
}

/* Form */
.ds-form-view {
    background: #1a1a1a; padding: 12px; overflow-y: auto; color: #fff;
}
.ds-form-group { margin-bottom: 10px; }
.ds-form-group label { display: block; font-size: 0.8rem; color: #9ca3af; margin-bottom: 3px; }
.ds-form-row { display: flex; gap: 8px; }
.ds-form-row .ds-form-group { flex: 1; }
.ds-input {
    width: 100%; padding: 7px 8px; border: 1px solid #374151;
    border-radius: 6px; background: #111; color: #fff; font-size: 0.9rem;
    box-sizing: border-box;
}
.ds-input:focus { outline: none; border-color: #2563eb; }
.ds-form-actions { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.ds-status { text-align: center; font-size: 0.8rem; color: #9ca3af; margin-top: 6px; }

/* Buttons */
.ds-btn {
    padding: 8px 14px; border: 1px solid #374151; border-radius: 6px;
    background: #1f2937; color: #fff; font-size: 0.82rem; cursor: pointer;
    font-weight: 500; white-space: nowrap;
}
.ds-btn:hover { background: #374151; }
.ds-btn-primary { background: #2563eb; border-color: #2563eb; }
.ds-btn-primary:hover { background: #1d4ed8; }
.ds-btn-close {
    width: 32px; height: 32px; padding: 0; font-size: 1.3rem;
    line-height: 1; text-align: center; border-radius: 50%;
}
.ds-btn-sm {
    padding: 4px 8px; font-size: 0.7rem;
}

/* Native camera */
.ds-native-camera {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px; padding: 16px;
    overflow-y: auto;
}
.ds-native-text { color: #9ca3af; font-size: 1rem; text-align: center; }
.ds-native-btn { font-size: 1rem; padding: 14px 28px; cursor: pointer; display: inline-block; text-align: center; }
.ds-native-hint { color: #6b7280; font-size: 0.8rem; margin-top: 12px; }

/* Crop mode */
.ds-crop-actions {
    display: flex; gap: 6px; padding: 8px 10px; justify-content: center;
    align-items: center; background: #111; flex-shrink: 0; flex-wrap: wrap;
}
.ds-crop-hint {
    color: #9ca3af; font-size: 0.78rem; text-align: center;
    width: 100%; margin: 0 0 4px;
}

/* Mobile */
@media (max-width: 768px) {
    .ds-pages-grid { grid-template-columns: repeat(3, 1fr); }
    .ds-form-row { flex-direction: column; gap: 0; }
    .ds-btn { padding: 8px 12px; font-size: 0.78rem; }
    .ds-btn-sm { padding: 5px 8px; font-size: 0.7rem; }
    .ds-slider-label { min-width: 45px; font-size: 0.7rem; }
    .ds-native-camera { padding: 12px; gap: 10px; }
    .ds-preview-controls { padding: 4px 8px; }
    .ds-slider-row { margin-bottom: 2px; }
}
