/**
 * Estilos principales - Checador Biométrico
 * Diseño mobile-first optimizado para Android Chrome
 */

/* ================================================
   Variables y Reset
   ================================================ */
:root {
    /* Colores principales */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;

    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-entrada: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-salida: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);

    /* Fondo oscuro */
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-elevated: #252542;
    --bg-input: #2a2a4a;

    /* Texto */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    /* Estados */
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);

    /* Espaciado */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Bordes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Safe areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ================================================
   Layout Principal
   ================================================ */
#app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    animation: fadeIn var(--transition-normal);
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Header */
.header {
    padding: var(--spacing-md);
    padding-top: calc(var(--spacing-md) + var(--safe-top));
    background: var(--bg-card);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.clock {
    font-size: 1.5rem;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary-light);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: var(--spacing-sm) 0;
    transition: opacity var(--transition-fast);
}

.back-btn:active {
    opacity: 0.7;
}

.header-title {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: var(--spacing-lg);
    padding-bottom: calc(var(--spacing-lg) + var(--safe-bottom));
    overflow-y: auto;
}

.main-content.centered {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================================================
   Pantalla de Carga
   ================================================ */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: var(--spacing-lg);
}

.loader-ring {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ================================================
   Pantalla de Búsqueda
   ================================================ */
.search-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: var(--spacing-lg);
}

.search-header {
    text-align: center;
}

.search-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.search-header p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--spacing-md);
    font-size: 1.25rem;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: var(--spacing-md);
    padding-left: calc(var(--spacing-md) * 3);
    padding-right: calc(var(--spacing-md) * 3);
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 1.0625rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.clear-btn {
    position: absolute;
    right: var(--spacing-md);
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.clear-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

/* Resultados de búsqueda */
.search-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
}

.user-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast);
    border: 1px solid transparent;
}

.user-card:active {
    transform: scale(0.98);
    background: var(--bg-elevated);
}

.user-card.no-credential {
    border-color: var(--warning);
    opacity: 0.7;
}

.user-card .avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

.user-card .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-card .info {
    flex: 1;
    min-width: 0;
}

.user-card .name {
    font-weight: 600;
    font-size: 1.0625rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card .details {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card .arrow {
    color: var(--text-muted);
    font-size: 1.25rem;
}

.user-card .no-cred-badge {
    font-size: 0.75rem;
    background: var(--warning);
    color: #000;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

/* ================================================
   Pantalla de Autenticación
   ================================================ */
.auth-container {
    text-align: center;
    width: 100%;
    max-width: 360px;
}

.user-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials {
    font-size: 2.5rem;
    font-weight: 600;
}

.auth-container h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.user-info {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: var(--spacing-xl);
}

.biometric-prompt {
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-xl);
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fingerprint-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-md);
    color: var(--primary-light);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.prompt-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.error-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    color: var(--error);
}

/* ================================================
   Pantalla de Tipo de Movimiento
   ================================================ */
.type-container {
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.welcome-message {
    margin-bottom: var(--spacing-xl);
}

.welcome-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--gradient-success);
    border-radius: 50%;
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
}

.welcome-message h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--success);
}

.welcome-message p {
    color: var(--text-secondary);
}

.time-display {
    margin-bottom: var(--spacing-2xl);
}

.time-display #currentTime {
    display: block;
    font-size: 4rem;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.time-display #currentDate {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: var(--spacing-sm);
}

.type-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.type-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    color: white;
}

.type-btn:active {
    transform: scale(0.95);
}

.type-btn.entrada {
    background: var(--gradient-entrada);
    box-shadow: 0 8px 32px rgba(17, 153, 142, 0.4);
}

.type-btn.salida {
    background: var(--gradient-salida);
    box-shadow: 0 8px 32px rgba(79, 172, 254, 0.4);
}

.type-btn.salida-comer {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 8px 32px rgba(245, 87, 108, 0.4);
}

.type-btn.entrada-comer {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 8px 32px rgba(0, 242, 254, 0.4);
}

.type-icon {
    font-size: 3rem;
}

.type-label {
    font-size: 1.25rem;
    font-weight: 600;
}

/* ================================================
   Pantalla de Captura
   ================================================ */
.capture-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: var(--spacing-lg);
}

.camera-view {
    position: relative;
    flex: 1;
    min-height: 300px;
    background: #000;
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.camera-view video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.face-guide {
    width: 200px;
    height: 260px;
    border: 3px dashed rgba(255, 255, 255, 0.4);
    border-radius: 50%;
}

.capture-countdown {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    font-size: 6rem;
    font-weight: 200;
    color: white;
    animation: countdownPulse 1s ease infinite;
}

@keyframes countdownPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.capture-status {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.status-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.status-icon {
    font-size: 1.5rem;
}

.status-icon.pending {
    opacity: 0.5;
}

.status-icon.success {
    opacity: 1;
}

.status-text {
    font-size: 0.9375rem;
}

/* ================================================
   Pantalla de Éxito
   ================================================ */
.success-container {
    text-align: center;
    width: 100%;
    max-width: 360px;
}

.success-animation {
    margin-bottom: var(--spacing-xl);
}

.checkmark-circle {
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.checkmark {
    width: 100%;
    height: 100%;
}

.checkmark-circle-bg {
    stroke: var(--success);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: circleAnim 0.6s ease-out forwards;
}

.checkmark-check {
    stroke: var(--success);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: checkAnim 0.3s ease-out 0.6s forwards;
}

@keyframes circleAnim {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes checkAnim {
    to {
        stroke-dashoffset: 0;
    }
}

.success-container h2 {
    font-size: 1.75rem;
    color: var(--success);
    margin-bottom: var(--spacing-sm);
}

.success-time {
    font-size: 2.5rem;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    margin-bottom: var(--spacing-sm);
}

.success-user {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin-bottom: var(--spacing-xl);
}

.success-details {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
}

.detail-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    color: var(--text-secondary);
}

.auto-close {
    color: var(--text-muted);
    font-size: 0.875rem;
    animation: blink 1s ease infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ================================================
   Pantalla de Error
   ================================================ */
.error-container {
    text-align: center;
    width: 100%;
    max-width: 360px;
}

.error-animation {
    width: 100px;
    height: 100px;
    margin: 0 auto var(--spacing-xl);
    background: rgba(239, 68, 68, 0.1);
    border: 3px solid var(--error);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-x {
    font-size: 3rem;
    color: var(--error);
}

.error-container h2 {
    color: var(--error);
    margin-bottom: var(--spacing-sm);
}

.error-container p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
}

/* ================================================
   Botones
   ================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    border: none;
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-large {
    width: 100%;
    padding: var(--spacing-lg);
    font-size: 1.125rem;
    border-radius: var(--radius-xl);
}

.btn-icon {
    font-size: 1.25rem;
}

/* ================================================
   Utilidades
   ================================================ */
.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
}

/* Responsive ajustes para pantallas muy pequeñas */
@media (max-width: 320px) {
    :root {
        font-size: 14px;
    }

    .type-buttons {
        grid-template-columns: 1fr;
    }

    .type-btn {
        aspect-ratio: auto;
        padding: var(--spacing-xl);
    }
}

/* Landscape en móviles */
@media (max-height: 500px) and (orientation: landscape) {
    .type-buttons {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }

    .type-btn {
        aspect-ratio: auto;
        padding: var(--spacing-lg);
    }

    .camera-view {
        min-height: 200px;
    }
}