/* ============================================
   SCAN A4 PRO - CÁMARA AVANZADA v2
   Basado en CamaraPerfecta2
   ============================================ */

#scanA4ProContainer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    z-index: 100000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#scanA4ProContainer * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Animación spin para overlay */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Pantalla de Inicio */
#scanA4StartScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, #0a0a0a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 40px;
}

.scan-logo {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2cbf 100%);
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(0,212,255,0.3);
}

.scan-title {
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

.scan-subtitle {
    color: rgba(255,255,255,0.6);
    font-size: 16px;
    margin-bottom: 40px;
    text-align: center;
}

.scan-btn {
    width: 100%;
    max-width: 300px;
    padding: 20px;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2cbf 100%);
    border: none;
    border-radius: 16px;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0,212,255,0.3);
}

/* Vista Cámara */
#scanA4CameraView {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

#scanA4CameraView.active {
    display: block;
}

#scanA4Video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Header simple */
.scan-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}

.scan-close-btn {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.scan-res-badge {
    color: #00d4ff;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0,0,0,0.5);
    padding: 4px 10px;
    border-radius: 10px;
}

/* Overlay orientación inválida */
#scanA4InvalidOverlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.88);
    z-index: 80;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

/* Área de recorte A4 - AUMENTADA */
.scan-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92vw;
    height: calc(92vw * 1.414);
    max-height: 72vh;
    transition: width 0.3s ease, height 0.3s ease;
}

/* Marco A4 apaisado - AUMENTADO */
.scan-area.landscape {
    width: min(95vw, calc(72vh * 1.414));
    height: calc(min(95vw, calc(72vh * 1.414)) / 1.414);
    max-height: 72vh;
}

.scan-crop-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid rgba(0, 212, 255, 0.9);
    border-radius: 16px;
    box-shadow: 
        0 0 0 9999px rgba(0, 0, 0, 0.75),
        inset 0 0 30px rgba(0, 212, 255, 0.15),
        0 0 20px rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.03);
}

/* Etiqueta A4 - Mismo tamaño que botones de control */
.scan-crop-label {
    position: absolute;
    top: -70px;
    left: 50%;
    transform: translateX(-50%);
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    color: #000;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
    letter-spacing: 1px;
}

.scan-corner {
    position: absolute;
    width: 32px;
    height: 32px;
    border-color: rgba(0, 212, 255, 0.95);
    border-style: solid;
    border-width: 0;
}

.scan-corner-tl { top: -4px; left: -4px; border-top-width: 5px; border-left-width: 5px; border-top-left-radius: 12px; }
.scan-corner-tr { top: -4px; right: -4px; border-top-width: 5px; border-right-width: 5px; border-top-right-radius: 12px; }
.scan-corner-bl { bottom: -4px; left: -4px; border-bottom-width: 5px; border-left-width: 5px; border-bottom-left-radius: 12px; }
.scan-corner-br { bottom: -4px; right: -4px; border-bottom-width: 5px; border-right-width: 5px; border-bottom-right-radius: 12px; }

/* Grid guía */
.scan-grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.4;
}

.scan-grid-v {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: rgba(0, 212, 255, 0.6);
    left: 33.33%;
}

.scan-grid-v:nth-child(2) { left: 66.66%; }

.scan-grid-h {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(0, 212, 255, 0.6);
    top: 33.33%;
}

.scan-grid-h:nth-child(4) { top: 66.66%; }

/* Controles inferiores */
.scan-bottom-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(20px);
    padding: 20px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    z-index: 20;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.scan-control-btn {
    width: 58px;
    height: 58px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    color: #fff;
    font-size: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

/* Botón especial verde para girar */
.scan-control-btn.btn-rotate {
    background: rgba(22,163,74,0.25);
    border-color: rgba(22,163,74,0.6);
    color: #4ade80;
}

.scan-control-btn.btn-rotate:active,
.scan-control-btn.btn-rotate.active {
    background: rgba(22,163,74,0.5);
    border-color: #4ade80;
}

.scan-control-btn:active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.95);
}

.scan-control-btn.active {
    background: rgba(0,212,255,0.3);
    border-color: #00d4ff;
    color: #00d4ff;
}

.scan-control-btn span {
    font-size: 11px;
    margin-top: 4px;
    font-weight: 500;
}

.scan-shutter-btn {
    width: 78px;
    height: 78px;
    background: rgba(255,255,255,0.95);
    border: 4px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 0 0 4px rgba(0,212,255,0.5), 0 0 30px rgba(0,212,255,0.3);
    flex-shrink: 0;
}

.scan-shutter-btn:active {
    transform: scale(0.9);
}

.scan-shutter-inner {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2cbf 100%);
    border-radius: 50%;
}

/* Vista Preview */
#scanA4PreviewView {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    z-index: 200;
    flex-direction: column;
}

#scanA4PreviewView.active {
    display: flex;
}

.scan-preview-header {
    height: 60px;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.scan-preview-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.icon-btn {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

.scan-canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #1a1a1a;
}

#scanA4Canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border-radius: 8px;
    object-fit: contain;
}

.scan-preview-actions {
    padding: 25px 20px;
    background: rgba(0,0,0,0.9);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.scan-btn-retake {
    padding: 25px 20px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 16px;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 65px;
    transition: all 0.2s ease;
}

.scan-btn-retake:active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.98);
}

.scan-btn-save {
    padding: 25px 20px;
    background: linear-gradient(135deg, #00d4ff 0%, #7b2cbf 100%);
    border: none;
    border-radius: 16px;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 65px;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
    transition: all 0.2s ease;
}

.scan-btn-save:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 212, 255, 0.3);
}

/* Filtros */
.scan-filters-bar {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(0,0,0,0.8);
    overflow-x: auto;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.scan-filter-btn {
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
}

.scan-filter-btn.active {
    background: #00d4ff;
    color: #000;
    border-color: #00d4ff;
}
