/* ==========================================
   NewAccess — Auth Pages Design System
   Basado en web_v3 design tokens
   ========================================== */

/* --- CSS Variables --- */
:root {
    --primary: #0052D4;
    --primary-dark: #003EA1;
    --secondary: #4364F7;
    --accent: #6FB1FC;
    --gradient: linear-gradient(135deg, #0052D4 0%, #4364F7 50%, #6FB1FC 100%);
    --gradient-dark: linear-gradient(135deg, #001a44 0%, #0a1628 40%, #0052D4 100%);

    --white: #FFFFFF;
    --gray-50: #F8F9FA;
    --gray-100: #F1F3F5;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #CED4DA;
    --gray-500: #ADB5BD;
    --gray-600: #868E96;
    --gray-700: #495057;
    --gray-800: #343A40;
    --gray-900: #212529;

    --success: #00C9A7;
    --success-dark: #00a88c;
    --warning: #F59E0B;
    --danger: #FF6B6B;
    --danger-dark: #e05555;

    --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 16px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

/* --- Base Reset (scoped) --- */
.auth-page {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
}

.auth-page *,
.auth-page *::before,
.auth-page *::after {
    box-sizing: border-box;
}

/* --- Full-Screen Animated Background --- */
.auth-bg {
    position: fixed;
    inset: 0;
    background: var(--gradient-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
    overflow-y: auto;
}

/* Brand watermark */
.auth-bg::before {
    content: '';
    position: absolute;
    width: 55vw;
    height: 55vw;
    max-width: 600px;
    max-height: 600px;
    background: url('/img/na_basic_blue.png') no-repeat center / contain;
    opacity: 0.04;
    bottom: -8%;
    right: -5%;
    pointer-events: none;
    animation: authWatermarkDrift 25s ease-in-out infinite;
}

@keyframes authWatermarkDrift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(-15px, -10px) rotate(3deg); }
}

.auth-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    pointer-events: none;
}

.auth-shape--1 {
    width: 500px;
    height: 500px;
    background: var(--secondary);
    top: -150px;
    right: -100px;
    animation: authFloat1 15s ease-in-out infinite;
}

.auth-shape--2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -120px;
    left: -80px;
    animation: authFloat2 18s ease-in-out infinite;
}

.auth-shape--3 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: authFloat3 20s ease-in-out infinite;
}

@keyframes authFloat1 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(30px, -40px); }
    50% { transform: translate(-20px, 30px); }
    75% { transform: translate(20px, 15px); }
}

@keyframes authFloat2 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-25px, -20px); }
    50% { transform: translate(15px, -35px); }
    75% { transform: translate(-10px, 25px); }
}

@keyframes authFloat3 {
    0%, 100% { transform: translate(-50%, -50%); }
    25% { transform: translate(-45%, -55%); }
    50% { transform: translate(-55%, -45%); }
    75% { transform: translate(-48%, -52%); }
}

/* --- Glassmorphism Card --- */
.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255, 255, 255, 0.1);
    padding: 2rem 1.75rem;
    animation: authCardIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.auth-card--wide {
    max-width: 520px;
}

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

/* --- Logo --- */
.auth-logo {
    display: block;
    margin: 0 auto 1.25rem;
    height: 32px;
    width: auto;
}

/* --- Headings --- */
.auth-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-900);
    text-align: center;
    margin-bottom: 0.15rem;
    line-height: 1.3;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--gray-600);
    text-align: center;
    margin-bottom: 1.25rem;
}

/* --- Form --- */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* --- Input Group --- */
.auth-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-group i.auth-input-icon {
    position: absolute;
    left: 0.85rem;
    color: var(--gray-400);
    font-size: 0.82rem;
    transition: var(--transition-fast);
    pointer-events: none;
    z-index: 2;
}

.auth-input-group input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.4rem;
    font-family: var(--font);
    font-size: 0.88rem;
    color: var(--gray-800);
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    outline: none;
}

.auth-input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 82, 212, 0.12);
}

.auth-input-group input:focus ~ i.auth-input-icon,
.auth-input-group input:focus + i.auth-input-icon {
    color: var(--primary);
}

.auth-input-group input::placeholder {
    color: var(--gray-400);
}

/* Toggle password visibility */
.auth-toggle-pass {
    position: absolute;
    right: 0.85rem;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 0.82rem;
    transition: var(--transition-fast);
    z-index: 2;
}

.auth-toggle-pass:hover {
    color: var(--gray-600);
}

/* --- Options Row (remember me + forgot) --- */
.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

.auth-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-700);
    cursor: pointer;
    font-weight: 500;
}

.auth-options label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.auth-options a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.auth-options a:hover {
    color: var(--primary-dark);
}

/* --- Buttons --- */
.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 1.5rem;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.auth-btn--primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.auth-btn--primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.auth-btn--success {
    background: var(--success);
    color: var(--white);
    border-color: var(--success);
}

.auth-btn--success:hover {
    background: var(--success-dark);
    border-color: var(--success-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.auth-btn--danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}

.auth-btn--danger:hover {
    background: var(--danger-dark);
    border-color: var(--danger-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.auth-btn--outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--gray-200);
}

.auth-btn--outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    transform: translateY(-1px);
}

.auth-btn--secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-100);
}

.auth-btn--secondary:hover {
    background: var(--gray-200);
    border-color: var(--gray-200);
    transform: translateY(-1px);
}

.auth-btn--sm {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
}

.auth-btn[disabled],
.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* --- Separator --- */
.auth-separator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
}

.auth-separator::before,
.auth-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.auth-separator span {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
    white-space: nowrap;
}

/* --- Social Buttons --- */
.auth-social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--white);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.auth-social-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.auth-social-btn img {
    width: 20px;
    height: 20px;
}

.auth-social-btn i {
    font-size: 1.1rem;
}

.auth-social-btn--apple {
    background: #000;
    color: #fff;
    border-color: #000;
}

.auth-social-btn--apple:hover {
    background: #1d1d1f;
    border-color: #1d1d1f;
    color: #fff;
}

/* --- Footer Text --- */
.auth-footer-text {
    font-size: 0.85rem;
    color: var(--gray-600);
    text-align: center;
    margin-top: 1.25rem;
}

.auth-footer-text a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fast);
}

.auth-footer-text a:hover {
    color: var(--primary-dark);
}

/* --- Copyright Footer --- */
.auth-copyright {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    position: fixed;
    bottom: 0.5rem;
    left: 0;
    right: 0;
    z-index: 10;
}

.auth-copyright a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

/* --- Alerts --- */
.auth-alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-alert--danger {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.auth-alert--success {
    background: #F0FDF4;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.auth-alert--warning {
    background: #FFFBEB;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.auth-alert a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* --- Password Strength --- */
.auth-pwd-rules {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 1rem;
}

.auth-pwd-rules li {
    font-size: 0.78rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition-fast);
}

.auth-pwd-rules li i {
    font-size: 0.7rem;
    width: 14px;
    text-align: center;
}

.auth-pwd-rules li.valid {
    color: var(--success);
}

.auth-pwd-rules li.invalid {
    color: var(--danger);
}

.auth-pwd-strength-bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.auth-pwd-strength-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease, background 0.4s ease;
    width: 0%;
}

.auth-pwd-strength-fill.strength-0 { width: 0%; background: var(--gray-300); }
.auth-pwd-strength-fill.strength-1 { width: 20%; background: var(--danger); }
.auth-pwd-strength-fill.strength-2 { width: 40%; background: #FF8C42; }
.auth-pwd-strength-fill.strength-3 { width: 60%; background: var(--warning); }
.auth-pwd-strength-fill.strength-4 { width: 80%; background: #84CC16; }
.auth-pwd-strength-fill.strength-5 { width: 100%; background: var(--success); }

/* --- Checkbox Styled --- */
.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--gray-600);
    cursor: pointer;
    line-height: 1.4;
}

.auth-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.auth-checkbox a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

.auth-checkbox a:hover {
    text-decoration: underline;
}

/* --- Success Animation (Checkmark) --- */
.auth-success-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    animation: authSuccessPop 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.auth-success-icon i {
    font-size: 1.7rem;
    color: var(--white);
    animation: authCheckIn 0.4s ease 0.5s both;
}

@keyframes authSuccessPop {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes authCheckIn {
    from {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* --- Mail Animation (for registration success) --- */
.auth-mail-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    animation: authSuccessPop 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.auth-mail-icon i {
    font-size: 1.7rem;
    color: var(--white);
    animation: authMailBounce 2s ease-in-out 0.7s infinite;
}

@keyframes authMailBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* --- Lock Animation (for password recovery) --- */
.auth-lock-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warning) 0%, #F97316 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    animation: authSuccessPop 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.auth-lock-icon i {
    font-size: 1.7rem;
    color: var(--white);
}

/* --- 2FA Section --- */
.auth-2fa-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
}

.auth-2fa-icon i {
    font-size: 1.75rem;
    color: var(--white);
}

.auth-2fa-input {
    text-align: center;
    font-size: 2rem;
    letter-spacing: 12px;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    width: 220px;
    margin: 0 auto;
    display: block;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    outline: none;
    background: var(--white);
    color: var(--gray-900);
}

.auth-2fa-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 82, 212, 0.12);
}

/* --- Local Branding (Invitations) --- */
.auth-local-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}

.auth-local-brand img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gray-200);
    flex-shrink: 0;
}

.auth-local-brand h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    line-height: 1.3;
}

.auth-local-brand p {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin: 0;
}

/* --- Invitation Action Buttons --- */
.auth-invite-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.auth-invite-actions .auth-btn {
    flex: 1;
}

/* --- PWA Install Button --- */
.auth-pwa-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.auth-pwa-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* --- Info Text --- */
.auth-info {
    font-size: 0.85rem;
    color: var(--gray-600);
    text-align: center;
    line-height: 1.5;
}

.auth-info strong {
    color: var(--gray-800);
}

/* --- Validity dates (invitations) --- */
.auth-validity {
    font-size: 0.8rem;
    color: var(--gray-600);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-validity i {
    color: var(--warning);
}

/* --- Cancel badge --- */
.auth-cancel-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--danger);
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius-full);
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-fast);
    float: right;
    margin-bottom: 0.75rem;
}

.auth-cancel-badge:hover {
    background: #FEE2E2;
    color: var(--danger-dark);
}

/* --- Responsive --- */
@media (max-width: 500px) {
    .auth-card {
        padding: 1.5rem 1.25rem;
        border-radius: var(--radius);
        max-width: 100%;
    }

    .auth-bg {
        padding: 0.75rem;
        align-items: center;
        min-height: 100vh;
    }

    .auth-title {
        font-size: 1.3rem;
    }

    .auth-pwd-rules {
        grid-template-columns: 1fr;
    }

    .auth-invite-actions {
        flex-direction: column;
    }

    .g_id_signin {
        max-width: 100%;
        overflow: hidden;
    }

    .auth-shape--1 { width: 300px; height: 300px; }
    .auth-shape--2 { width: 250px; height: 250px; }
    .auth-shape--3 { width: 200px; height: 200px; }
}

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
    .auth-card {
        animation: none;
    }

    .auth-shape {
        animation: none !important;
    }

    .auth-success-icon,
    .auth-success-icon i,
    .auth-mail-icon i {
        animation: none;
    }

    .auth-pwd-strength-fill {
        transition: none;
    }
}
