/**
 * Authentication Pages Stylesheet
 * VoiceQuiz Platform - Award-Winning Design
 *
 * Creates a memorable first impression with:
 * - Split-screen layout with animated gradient
 * - Glassmorphism card effects
 * - Smooth micro-interactions
 * - Premium form styling
 */

/* ============================================
   Auth Page Layout
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    background: var(--ve-gray-50);
    position: relative;
    overflow: hidden;
}

/* Animated Background Gradient */
.auth-page::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 55%;
    height: 100%;
    background: linear-gradient(135deg,
        var(--ve-primary) 0%,
        var(--ve-primary-dark) 50%,
        var(--ve-primary-900) 100%);
    clip-path: polygon(15% 0, 100% 0, 100% 100%, 0% 100%);
    z-index: 0;
}

/* Floating Shapes */
.auth-page::after {
    content: '';
    position: absolute;
    top: -20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: floatBubble 20s ease-in-out infinite;
    z-index: 1;
}

@keyframes floatBubble {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(-30px, 30px) scale(1.05); }
    50% { transform: translate(-20px, -20px) scale(0.95); }
    75% { transform: translate(30px, 20px) scale(1.02); }
}

/* ============================================
   Auth Container - Centered Card
   ============================================ */
.auth-container {
    position: relative;
    z-index: 10;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: var(--ve-space-8);
}

/* ============================================
   Auth Card - Glassmorphism Effect
   ============================================ */
.auth-card {
    width: 100%;
    max-width: 480px;
    margin-left: 8%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--ve-radius-2xl);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.8);
    padding: var(--ve-space-10);
    animation: cardSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   Auth Header - Logo & Title
   ============================================ */
.auth-header {
    text-align: center;
    margin-bottom: var(--ve-space-8);
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--ve-primary), var(--ve-primary-dark));
    border-radius: var(--ve-radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--ve-space-5);
    box-shadow: var(--ve-shadow-lg), var(--ve-shadow-primary);
    animation: logoFloat 3s ease-in-out infinite;
}

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

.auth-logo i {
    font-size: 1.75rem;
    color: white;
}

.auth-header h1 {
    font-size: var(--ve-text-2xl);
    font-weight: 700;
    color: var(--ve-text-primary);
    margin-bottom: var(--ve-space-2);
    letter-spacing: -0.025em;
}

.auth-header p {
    color: var(--ve-text-muted);
    font-size: var(--ve-text-sm);
    margin-bottom: 0;
}

/* ============================================
   Auth Form
   ============================================ */
.auth-form {
    margin-bottom: var(--ve-space-6);
}

.auth-form .form-group {
    margin-bottom: var(--ve-space-5);
}

.auth-form .form-label {
    font-size: var(--ve-text-sm);
    font-weight: 500;
    color: var(--ve-text-primary);
    margin-bottom: var(--ve-space-2);
}

.auth-form .form-control {
    height: auto;
    padding: 0.875rem 1.125rem;
    font-size: var(--ve-text-base);
    border: 2px solid var(--ve-gray-200);
    border-radius: var(--ve-radius-lg);
    background: var(--ve-surface);
    transition: all var(--ve-transition-fast);
}

.auth-form .form-control:hover {
    border-color: var(--ve-gray-300);
}

.auth-form .form-control:focus {
    border-color: var(--ve-primary);
    box-shadow: 0 0 0 4px var(--ve-primary-100);
    background: white;
}

.auth-form .form-control::placeholder {
    color: var(--ve-text-muted);
}

/* Submit Button */
.auth-form .btn-primary {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: var(--ve-text-base);
    font-weight: 600;
    border-radius: var(--ve-radius-lg);
    background: linear-gradient(135deg, var(--ve-primary), var(--ve-primary-dark));
    box-shadow: var(--ve-shadow-md), var(--ve-shadow-primary);
    position: relative;
    overflow: hidden;
}

.auth-form .btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.auth-form .btn-primary:hover::before {
    left: 100%;
}

.auth-form .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--ve-shadow-lg), var(--ve-shadow-primary);
}

.auth-form .btn-primary:active {
    transform: translateY(0);
}

/* ============================================
   Password Field with Toggle
   ============================================ */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--ve-text-muted);
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--ve-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--ve-primary);
}

.password-wrapper .form-control {
    padding-right: 3rem;
}

/* ============================================
   Social Login
   ============================================ */
.social-login {
    display: flex;
    flex-direction: column;
    gap: var(--ve-space-3);
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--ve-space-3);
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--ve-text-sm);
    font-weight: 500;
    color: var(--ve-text-primary);
    background: var(--ve-surface);
    border: 2px solid var(--ve-gray-200);
    border-radius: var(--ve-radius-lg);
    transition: all var(--ve-transition-fast);
    cursor: pointer;
}

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

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

.btn-social.google i { color: #4285f4; }
.btn-social.microsoft i { color: #00a4ef; }
.btn-social.apple i { color: #000; }

/* ============================================
   Divider
   ============================================ */
.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--ve-space-4);
    margin: var(--ve-space-6) 0;
}

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

.auth-divider span {
    font-size: var(--ve-text-xs);
    font-weight: 500;
    color: var(--ve-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   Remember Me & Forgot Password
   ============================================ */
.remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--ve-space-6);
}

.remember-forgot .form-check {
    margin-bottom: 0;
}

.remember-forgot .form-check-input {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--ve-gray-300);
    border-radius: var(--ve-radius-sm);
}

.remember-forgot .form-check-input:checked {
    background-color: var(--ve-primary);
    border-color: var(--ve-primary);
}

.remember-forgot .form-check-label {
    font-size: var(--ve-text-sm);
    color: var(--ve-text-secondary);
}

.remember-forgot a {
    font-size: var(--ve-text-sm);
    font-weight: 500;
    color: var(--ve-primary);
}

.remember-forgot a:hover {
    color: var(--ve-primary-dark);
    text-decoration: underline;
}

/* ============================================
   Auth Footer
   ============================================ */
.auth-footer {
    text-align: center;
    padding-top: var(--ve-space-6);
    border-top: 1px solid var(--ve-gray-100);
}

.auth-footer p {
    margin-bottom: 0;
    font-size: var(--ve-text-sm);
    color: var(--ve-text-muted);
}

.auth-footer a {
    font-weight: 600;
    color: var(--ve-primary);
}

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

/* ============================================
   Role Selection (Registration)
   ============================================ */
.role-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--ve-space-4);
    margin-bottom: var(--ve-space-6);
}

.role-option {
    position: relative;
}

.role-option input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.role-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--ve-space-6) var(--ve-space-4);
    background: var(--ve-surface);
    border: 2px solid var(--ve-gray-200);
    border-radius: var(--ve-radius-xl);
    cursor: pointer;
    transition: all var(--ve-transition-base);
}

.role-option label:hover {
    border-color: var(--ve-primary-200);
    background: var(--ve-primary-50);
}

.role-option input:checked + label {
    border-color: var(--ve-primary);
    background: var(--ve-primary-50);
    box-shadow: 0 0 0 4px var(--ve-primary-100);
}

.role-option .role-icon {
    width: 56px;
    height: 56px;
    background: var(--ve-gray-100);
    border-radius: var(--ve-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--ve-space-3);
    transition: all var(--ve-transition-base);
}

.role-option .role-icon i {
    font-size: 1.5rem;
    color: var(--ve-text-secondary);
    transition: color var(--ve-transition-base);
}

.role-option input:checked + label .role-icon {
    background: linear-gradient(135deg, var(--ve-primary), var(--ve-primary-dark));
    box-shadow: var(--ve-shadow-primary);
}

.role-option input:checked + label .role-icon i {
    color: white;
}

.role-option .role-title {
    font-size: var(--ve-text-sm);
    font-weight: 600;
    color: var(--ve-text-primary);
    margin-bottom: var(--ve-space-1);
}

.role-option .role-desc {
    font-size: var(--ve-text-xs);
    color: var(--ve-text-muted);
    text-align: center;
}

/* ============================================
   Magic Link Mode
   ============================================ */
.magic-link-info {
    display: flex;
    align-items: flex-start;
    gap: var(--ve-space-3);
    padding: var(--ve-space-4);
    background: var(--ve-primary-50);
    border-radius: var(--ve-radius-lg);
    margin-bottom: var(--ve-space-5);
}

.magic-link-info i {
    font-size: 1.25rem;
    color: var(--ve-primary);
    flex-shrink: 0;
}

.magic-link-info p {
    font-size: var(--ve-text-sm);
    color: var(--ve-primary-dark);
    margin: 0;
    line-height: var(--ve-leading-relaxed);
}

/* ============================================
   Success State (Email Sent)
   ============================================ */
.auth-success {
    text-align: center;
    padding: var(--ve-space-8) 0;
}

.auth-success-icon {
    width: 80px;
    height: 80px;
    background: var(--ve-success-50);
    border-radius: var(--ve-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--ve-space-6);
    animation: successPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.auth-success-icon i {
    font-size: 2.5rem;
    color: var(--ve-success);
}

.auth-success h2 {
    font-size: var(--ve-text-xl);
    margin-bottom: var(--ve-space-2);
}

.auth-success p {
    color: var(--ve-text-muted);
    max-width: 300px;
    margin: 0 auto;
}

/* ============================================
   Terms Agreement
   ============================================ */
.terms-agreement {
    font-size: var(--ve-text-xs);
    color: var(--ve-text-muted);
    text-align: center;
    margin-top: var(--ve-space-4);
    line-height: var(--ve-leading-relaxed);
}

.terms-agreement a {
    color: var(--ve-primary);
    font-weight: 500;
}

.terms-agreement a:hover {
    text-decoration: underline;
}

/* ============================================
   Error State
   ============================================ */
.auth-form .is-invalid {
    border-color: var(--ve-danger);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.auth-form .invalid-feedback {
    display: none;
    font-size: var(--ve-text-xs);
    color: var(--ve-danger);
    margin-top: var(--ve-space-2);
}

.auth-form .is-invalid ~ .invalid-feedback,
.auth-form .is-invalid + .invalid-feedback {
    display: block;
}

/* ============================================
   Loading State
   ============================================ */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   Brand Sidebar (Desktop Only)
   ============================================ */
.auth-brand {
    position: absolute;
    top: 50%;
    right: 12%;
    transform: translateY(-50%);
    z-index: 5;
    color: white;
    max-width: 400px;
    animation: brandFadeIn 0.8s ease 0.3s both;
}

@keyframes brandFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.auth-brand h2 {
    font-size: var(--ve-text-4xl);
    font-weight: 800;
    color: white;
    line-height: var(--ve-leading-tight);
    margin-bottom: var(--ve-space-4);
}

.auth-brand p {
    font-size: var(--ve-text-lg);
    color: rgba(255, 255, 255, 0.8);
    line-height: var(--ve-leading-relaxed);
    margin-bottom: var(--ve-space-8);
}

.auth-brand-features {
    display: flex;
    flex-direction: column;
    gap: var(--ve-space-4);
}

.auth-brand-feature {
    display: flex;
    align-items: center;
    gap: var(--ve-space-3);
}

.auth-brand-feature i {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--ve-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.auth-brand-feature span {
    font-size: var(--ve-text-sm);
    font-weight: 500;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1200px) {
    .auth-brand {
        display: none;
    }

    .auth-page::before {
        width: 45%;
        clip-path: polygon(30% 0, 100% 0, 100% 100%, 0% 100%);
    }
}

@media (max-width: 768px) {
    .auth-page::before {
        width: 100%;
        height: 40%;
        clip-path: none;
        position: fixed;
        top: 0;
    }

    .auth-page::after {
        top: -10%;
        right: -20%;
        width: 300px;
        height: 300px;
    }

    .auth-container {
        padding: var(--ve-space-4);
        justify-content: center;
        padding-top: 30vh;
    }

    .auth-card {
        margin-left: 0;
        padding: var(--ve-space-6);
        max-width: 100%;
    }

    .auth-header {
        margin-bottom: var(--ve-space-6);
    }

    .auth-logo {
        width: 56px;
        height: 56px;
    }

    .auth-logo i {
        font-size: 1.5rem;
    }

    .auth-header h1 {
        font-size: var(--ve-text-xl);
    }

    .role-selection {
        grid-template-columns: 1fr;
    }

    .role-option label {
        flex-direction: row;
        padding: var(--ve-space-4);
        gap: var(--ve-space-4);
    }

    .role-option .role-icon {
        margin-bottom: 0;
        width: 48px;
        height: 48px;
    }

    .role-option .role-text {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding-top: 25vh;
    }

    .auth-card {
        padding: var(--ve-space-5);
        border-radius: var(--ve-radius-xl);
    }

    .auth-form .form-control {
        padding: 0.75rem 1rem;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .auth-card,
    .auth-brand,
    .auth-logo,
    .auth-success-icon {
        animation: none;
    }

    .auth-page::after {
        animation: none;
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
    .auth-card {
        background: white;
        border: 2px solid var(--ve-text-primary);
    }

    .auth-form .form-control {
        border-width: 2px;
    }
}
