/* PWA Full Screen Styles v2.0.0 - Fixed for scrolling */
html, body {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for better mobile support */
    min-height: 100svh; /* Small viewport height for fullscreen apps */
    overflow-x: hidden; /* Solo ocultar scroll horizontal */
    overflow-y: auto; /* Permitir scroll vertical */
    overscroll-behavior-x: none; /* Prevent horizontal overscroll */
    -webkit-overflow-scrolling: touch;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
    /* Fullscreen optimizations */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Responsive body positioning */
body {
    position: relative; /* Cambiar de fixed a relative */
    width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: 100svh;
    /* Allow content to expand beyond viewport */
    max-width: 100vw;
}

/* Específico para Chrome en Android */
@supports (-webkit-fill-available: 100vh) {
    html {
        min-height: -webkit-fill-available;
    }
    body {
        min-height: -webkit-fill-available;
    }
}

/* Mobile optimizations - Fixed for scrolling */
@media screen and (max-width: 1024px) {
    html {
        min-height: 100vh !important;
        min-height: 100dvh !important;
        min-height: 100svh !important;
        min-height: -webkit-fill-available !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        position: relative !important;
    }
    
    body {
        min-height: 100vh !important;
        min-height: 100dvh !important;
        min-height: 100svh !important;
        min-height: -webkit-fill-available !important;
        width: 100vw !important;
        position: relative !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior-x: none !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Contenedores principales con scroll habilitado */
    .min-h-screen {
        min-height: 100vh !important;
        min-height: 100dvh !important;
        min-height: 100svh !important;
        min-height: -webkit-fill-available !important;
    }
    
    /* Contenedores flex con scroll */
    #loginScreen, #mainApp {
        min-height: 100vh !important;
        min-height: 100dvh !important;
        min-height: 100svh !important;
        min-height: -webkit-fill-available !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
}

/* Específico para dispositivos muy pequeños */
@media screen and (max-width: 480px) {
    * {
        -webkit-tap-highlight-color: transparent !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }
}

/* Ensure PWA uses full screen space */
.min-h-screen {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Safe area handling for devices with notches */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* Header Install Button Styles */
#headerInstallBtn {
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#headerInstallBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#headerInstallBtn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments for mobile */
@media (max-width: 640px) {
    #headerInstallBtn {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    #headerInstallBtn svg {
        width: 14px;
        height: 14px;
    }
    
    #headerInstallBtn span {
        display: none;
    }
}

@media (max-width: 480px) {
    #headerInstallBtn {
        padding: 6px 8px;
    }
}

/* Login Install Button Styles */
#loginInstallBtn {
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
    border: 1px solid rgba(37, 99, 235, 0.1);
}

#loginInstallBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

#loginInstallBtn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

/* Animation for login install button */
#loginInstallBtn {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Clean Scanner Overlay Styles */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    pointer-events: none;
    z-index: 20;
}

.scanner-overlay.active {
    display: block;
}

/* Scanning line */
.scanner-line {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 50%;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        #6b7280 20%, 
        #ffffff 50%,
        #6b7280 80%, 
        transparent 100%);
    box-shadow: 
        0 0 10px #6b7280,
        0 0 20px #6b7280,
        0 0 40px rgba(107, 114, 128, 0.8),
        inset 0 0 10px #ffffff;
    animation: scannerMove 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    border-radius: 1px;
}

.scanner-line::before,
.scanner-line::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #6b7280, transparent);
}

.scanner-line::before {
    top: -3px;
    animation: scannerMove 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite 0.2s;
    opacity: 0.6;
}

.scanner-line::after {
    bottom: -3px;
    animation: scannerMove 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite 0.4s;
    opacity: 0.4;
}

@keyframes scannerMove {
    0% { 
        top: 12%; 
        opacity: 0;
        transform: scaleX(0.8);
    }
    10% {
        opacity: 0.8;
        transform: scaleX(1);
    }
    50% { 
        top: 88%; 
        opacity: 1;
        transform: scaleX(1.2);
    }
    90% {
        opacity: 0.8;
        transform: scaleX(1);
    }
    100% { 
        top: 12%; 
        opacity: 0;
        transform: scaleX(0.8);
    }
}

@keyframes scannerPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Corner indicators - Minimal */
.scanner-corners {
    position: absolute;
    top: 8%;
    left: 8%;
    right: 8%;
    bottom: 8%;
    pointer-events: none;
}

.scanner-corners::before,
.scanner-corners::after {
    display: none;
}

/* Success state */
.scanner-overlay.success {
    background: 
        radial-gradient(ellipse at center, rgba(107, 114, 128, 0.2) 20%, transparent 60%),
        linear-gradient(45deg, rgba(107, 114, 128, 0.1) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(107, 114, 128, 0.1) 100%);
    animation: successPulse 0.6s ease-out;
}

.scanner-overlay.success .scanner-line {
    background: linear-gradient(90deg, 
        transparent 0%, 
        #ffffff 20%, 
        #6b7280 50%,
        #ffffff 80%, 
        transparent 100%);
    box-shadow: 
        0 0 20px #6b7280,
        0 0 40px #ffffff,
        0 0 60px rgba(107, 114, 128, 0.8);
    height: 4px;
    animation: successScan 0.6s ease-out;
}

@keyframes successPulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; transform: scale(1.02); }
    100% { opacity: 0.9; transform: scale(1); }
}

@keyframes successScan {
    0% { 
        top: 12%; 
        transform: scaleX(1) scaleY(1);
    }
    50% { 
        top: 50%; 
        transform: scaleX(1.5) scaleY(2);
        opacity: 1;
    }
    100% { 
        top: 88%; 
        transform: scaleX(1) scaleY(1);
    }
}

/* Estilos para la lista de personas escaneadas */
.person-item {
    transition: all 0.2s ease;
    position: relative;
}

.person-item:active {
    background-color: #f3f4f6;
}

/* Animación de entrada para nuevas personas */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.person-item.new-item {
    animation: slideInRight 0.3s ease-out;
}

/* Animación de salida para personas eliminadas */
@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
        max-height: 80px;
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-top: 0;
        margin-bottom: 0;
    }
}

.person-item.removing {
    animation: slideOutLeft 0.3s ease-out forwards;
}

/* Efecto de selección para long press */
.person-item.selecting {
    background-color: #fef2f2 !important;
    border-left: 4px solid #ef4444;
    transform: translateX(4px);
}

/* Badge de tipo de persona */
.person-badge {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Contador de personas */
#scannedCount {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Scrollbar personalizada para la lista */
#scannedList::-webkit-scrollbar {
    width: 4px;
}

#scannedList::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

#scannedList::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

#scannedList::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Estado vacío */
#emptyState {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments para la lista */
@media (max-width: 640px) {
    .person-item {
        padding: 12px 16px;
    }
    
    .person-item h4 {
        font-size: 13px;
    }
    
    .person-item p {
        font-size: 11px;
    }
    
    .person-badge {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* Estilos para las pestañas */
.tab-button {
    transition: all 0.2s ease;
    position: relative;
}

.tab-button:hover {
    background-color: #f9fafb;
}

.tab-button.active {
    background-color: #f9fafb;
    color: #1f2937;
    border-bottom-color: #1f2937;
}

.tab-button.active span:last-child {
    background-color: #1f2937;
    color: white;
}

.tab-button:not(.active) span:last-child {
    background-color: #6b7280;
    color: white;
}

.tab-content {
    display: block;
}

.tab-content.hidden {
    display: none;
}

/* Animación para cambio de pestañas */
.tab-content {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos específicos para proveedores */
.proveedor-item {
    border-left: 4px solid #f59e0b;
}

.proveedor-item .person-badge {
    background-color: #fef3c7;
    color: #92400e;
}

/* Estilos específicos para direcciones */
.direccion-item {
    border-left: 4px solid #3b82f6;
}

.direccion-item:hover {
    background-color: #eff6ff;
}

/* Responsive para pestañas en pantallas pequeñas */
@media (max-width: 640px) {
    .tab-button {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .tab-button .flex {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .tab-button span:last-child {
        font-size: 0.625rem;
        padding: 0.125rem 0.375rem;
    }
}