/**
 * UNERA Authentication Enhancements - CSS
 * Complete stylesheet for Phase 1 & 2 UX Improvements
 * 
 * Features:
 * - Trust signals & social proof
 * - Email/Phone toggle
 * - Loading states
 * - Rate limiting UI
 * - Magic link styles
 * - Biometric modal
 * - Mobile optimizations
 * 
 * Usage: Include this CSS in login_2.html and signup_2.html
 * <link rel="stylesheet" href="auth-enhancements.css">
 */

/* ========================================
   TRUST SIGNALS & SOCIAL PROOF
   ======================================== */

.trust-signals {
    max-width: 700px;
    margin: 0 auto 3rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    text-align: center;
    padding: 0 1rem;
}

.trust-stat {
    padding: 1rem;
}

.trust-number {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #10B981 0%, #0EA5E9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.trust-label {
    font-size: 0.875rem;
    color: var(--stone-medium, #6B7280);
    font-weight: 500;
}

.security-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 0 auto 2.5rem;
    max-width: 600px;
    padding: 0 1rem;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 2rem;
    font-size: 0.813rem;
    color: var(--impact-green, #10B981);
    font-weight: 500;
    transition: all 0.2s;
}

.security-badge:hover {
    background: rgba(16, 185, 129, 0.12);
    transform: translateY(-2px);
}

.security-badge svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   EMAIL/PHONE TOGGLE
   ======================================== */

.input-toggle-group {
    margin-bottom: 1.5rem;
}

.toggle-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
    background: rgba(0, 0, 0, 0.03);
    padding: 0.3rem;
    border-radius: 0.875rem;
}

.toggle-btn {
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--stone-medium, #6B7280);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
}

.toggle-btn.active {
    background: white;
    color: var(--stone-dark, #1F2937);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

.toggle-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.02);
}

.toggle-btn svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   LOADING STATES
   ======================================== */

.btn-loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
}

.btn-loading .btn-text {
    opacity: 0;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.social-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.social-btn .btn-spinner {
    display: none;
    margin-right: 0.5rem;
}

.social-btn.loading .btn-spinner {
    display: inline-block;
}

/* ========================================
   RATE LIMITING / LOCKOUT
   ======================================== */

.lockout-banner {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1.5px solid rgba(239, 68, 68, 0.25);
    border-radius: 0.875rem;
    margin-bottom: 1.5rem;
    animation: slideDown 0.3s ease-out;
}

.lockout-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.lockout-content {
    flex: 1;
}

.lockout-title {
    font-weight: 600;
    color: #EF4444;
    margin-bottom: 0.375rem;
    font-size: 0.938rem;
}

.lockout-message {
    font-size: 0.875rem;
    color: var(--stone-dark, #1F2937);
    line-height: 1.5;
}

.lockout-timer {
    font-weight: 600;
    color: #F59E0B;
}

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

/* ========================================
   MAGIC LINK
   ======================================== */

.or-divider {
    text-align: center;
    margin: 1.75rem 0;
    position: relative;
}

.or-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    z-index: 0;
}

.or-divider span {
    position: relative;
    background: white;
    padding: 0 1.25rem;
    font-size: 0.813rem;
    color: var(--stone-medium, #6B7280);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 1;
}

.magic-link-btn {
    width: 100%;
    padding: 0.938rem 1.25rem;
    border: 1.5px dashed var(--impact-green, #10B981);
    border-radius: 0.875rem;
    background: rgba(16, 185, 129, 0.05);
    color: var(--impact-green, #10B981);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    font-family: var(--font-body, 'Inter', sans-serif);
}

.magic-link-btn:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.1);
    border-style: solid;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.magic-link-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.magic-link-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   BIOMETRIC MODAL
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.modal-content {
    background: white;
    border-radius: 1.5rem;
    padding: 2.5rem 2rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: scaleIn 0.3s ease-out;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.biometric-icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

.modal-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--stone-dark, #1F2937);
}

.modal-content p {
    color: var(--stone-medium, #6B7280);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.modal-footer {
    margin-top: 1.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-footer label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    font-size: 0.875rem;
    color: var(--stone-medium, #6B7280);
    cursor: pointer;
}

.modal-footer input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 0.875rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10003;
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    max-width: 420px;
    min-width: 300px;
    border-left: 4px solid var(--neutral-400, #D1D5DB);
    animation: slideInRight 0.3s ease-out;
    font-family: var(--font-body, 'Space Grotesk', sans-serif);
}

.toast-notification.slideOut {
    animation: slideOutRight 0.3s ease-out forwards;
}

.toast-notification.toast-success {
    border-left-color: var(--primary-green, var(--impact-green, #10B981));
}

.toast-notification.toast-error {
    border-left-color: var(--error, #EF4444);
}

.toast-notification.toast-warning {
    border-left-color: var(--warning, #F59E0B);
}

.toast-notification.toast-info {
    border-left-color: var(--primary-blue, #0EA5E9);
}

.toast-notification .toast-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.toast-notification.toast-success .toast-icon {
    color: var(--primary-green, var(--impact-green, #10B981));
}

.toast-notification.toast-error .toast-icon {
    color: var(--error, #EF4444);
}

.toast-notification.toast-warning .toast-icon {
    color: var(--warning, #F59E0B);
}

.toast-notification.toast-info .toast-icon {
    color: var(--primary-blue, #0EA5E9);
}

.toast-notification .toast-text {
    flex: 1;
    min-width: 0;
    color: var(--neutral-900, #1F2937);
}

.toast-notification .toast-title {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
    color: var(--neutral-900, #1F2937);
}

.toast-notification .toast-body {
    font-size: 0.875rem;
    color: var(--neutral-700, #4B5563);
    line-height: 1.45;
}

.toast-notification .toast-message-plain {
    font-size: 0.9375rem;
    line-height: 1.45;
    color: var(--neutral-900, #1F2937);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
    /* Trust signals responsive */
    .trust-signals {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    .trust-number {
        font-size: 2rem;
    }

    /* Security badges stack on mobile */
    .security-badges {
        flex-direction: column;
        align-items: center;
    }

    .security-badge {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }

    /* Sticky CTA on mobile */
    .submit-btn.sticky-cta {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0 !important;
        border-radius: 0 !important;
        z-index: 100;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15) !important;
        padding: 1.125rem !important;
    }

    /* Add padding to prevent content hiding under sticky button */
    .auth-panel.has-sticky {
        padding-bottom: 100px;
    }

    /* Toast notifications on mobile */
    .toast-notification {
        top: auto;
        bottom: 2rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    /* Modal content on mobile */
    .modal-content {
        padding: 2rem 1.5rem;
        margin: 1rem;
    }

    /* Lockout banner on mobile */
    .lockout-banner {
        flex-direction: column;
        text-align: center;
    }

    /* Toggle buttons more thumb-friendly */
    .toggle-btn {
        min-height: 48px;
        padding: 0.875rem 1rem;
    }

    /* Magic link button larger tap target */
    .magic-link-btn {
        min-height: 52px;
        padding: 1rem 1.25rem;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus visible for keyboard navigation */
.toggle-btn:focus-visible,
.magic-link-btn:focus-visible,
.security-badge:focus-visible {
    outline: 3px solid var(--impact-green, #10B981);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .trust-number {
        -webkit-text-fill-color: var(--impact-green, #10B981);
    }

    .security-badge {
        border-width: 2px;
    }

    .toggle-btn.active {
        border: 2px solid var(--impact-green, #10B981);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .biometric-icon {
        animation: none;
    }

    .spinner {
        animation: none;
        border: 2px solid currentColor;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .trust-signals,
    .security-badges,
    .lockout-banner,
    .toast-notification,
    .modal {
        display: none !important;
    }
}

/* ========================================
   DARK MODE SUPPORT (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed in future */
    .modal-content {
        background: #1F2937;
        color: white;
    }

    .toggle-btn.active {
        background: rgba(255, 255, 255, 0.1);
    }
}
