/**
 * Authentication Pages — MyNamCycling
 * Immersive split-panel design for Login & Register
 */

/* ============================================
   PAGE LAYOUT
   ============================================ */
.auth-page {
    min-height: 100vh;
    background: var(--surface-50);
}

.auth-split {
    display: grid;
    grid-template-columns: 55fr 45fr;
    min-height: 100vh;
}

/* ============================================
   HERO PANEL (Left Side)
   ============================================ */
.auth-hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    padding: var(--space-10);
    overflow: hidden;
}

.auth-hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 20s ease;
}

.auth-hero:hover .auth-hero-bg {
    transform: scale(1.03);
}

.auth-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 50, 38, 0.92) 0%,
        rgba(0, 80, 60, 0.7) 40%,
        rgba(0, 122, 94, 0.4) 70%,
        rgba(0, 122, 94, 0.25) 100%
    );
}

.auth-hero-overlay--register {
    background: linear-gradient(
        to top,
        rgba(15, 23, 42, 0.92) 0%,
        rgba(0, 50, 38, 0.7) 40%,
        rgba(0, 122, 94, 0.4) 70%,
        rgba(0, 122, 94, 0.25) 100%
    );
}

.auth-hero-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 520px;
    animation: heroFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes heroFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero Logo */
.auth-hero-logo {
    margin-bottom: var(--space-10);
}

.auth-hero-logo img {
    width: 280px;
    height: auto;
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

/* Hero Text */
.auth-hero-title {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    font-weight: 800;
    color: #ffffff;
    line-height: 1.15;
    margin-bottom: var(--space-4);
    letter-spacing: -0.025em;
}

.auth-hero-subtitle {
    font-size: var(--text-lg);
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.6;
    margin-bottom: var(--space-8);
    max-width: 440px;
}

/* Hero Feature Chips (Login) */
.auth-hero-features {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}

.auth-hero-feature {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 100px;
    color: #ffffff;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-base);
}

.auth-hero-feature:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.auth-hero-feature i {
    font-size: var(--text-base);
    color: var(--accent-500);
}

/* Hero Benefits List (Register) */
.auth-hero-benefits {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.auth-hero-benefit {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.auth-hero-benefit:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateX(4px);
}

.auth-hero-benefit-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-500), var(--accent-400));
    border-radius: var(--radius-sm);
    color: var(--ink-900);
    font-size: var(--text-xl);
}

.auth-hero-benefit strong {
    display: block;
    color: #ffffff;
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: 2px;
}

.auth-hero-benefit p {
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--text-sm);
    margin: 0;
    line-height: 1.4;
}

/* Hero Trust Badges */
.auth-hero-trust {
    display: flex;
    gap: var(--space-4);
    padding-top: var(--space-6);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.auth-hero-trust span {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--text-sm);
    font-weight: 500;
}

.auth-hero-trust i {
    color: var(--accent-500);
    font-size: var(--text-base);
}

/* ============================================
   FORM PANEL (Right Side)
   ============================================ */
.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-8);
    background: var(--surface-0);
    overflow-y: auto;
}

.auth-form-wrapper {
    width: 100%;
    max-width: 420px;
}

/* Mobile Logo (hidden on desktop) */
.auth-mobile-logo {
    display: none;
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-mobile-logo img {
    width: 220px;
    height: auto;
}

/* Form Header */
.auth-form-header {
    margin-bottom: var(--space-8);
}

.auth-title {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    font-weight: 700;
    color: var(--ink-900);
    line-height: 1.2;
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-size: var(--text-base);
    color: var(--ink-500);
    margin: 0;
}

/* ============================================
   ALERT
   ============================================ */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
    font-size: var(--text-sm);
    line-height: 1.5;
    animation: alertSlideIn 0.3s ease-out;
}

.auth-alert i {
    flex-shrink: 0;
    font-size: var(--text-lg);
    margin-top: 1px;
}

.auth-alert-error {
    background: var(--color-error-light);
    color: #991B1B;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-alert-error i {
    color: var(--color-error);
}

@keyframes alertSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   FORM
   ============================================ */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

/* Staggered entrance animation */
.auth-field,
.auth-field-row,
.auth-submit {
    animation: fieldFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--delay, 0) * 80ms + 200ms);
}

@keyframes fieldFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Field Row (side-by-side) */
.auth-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* Labels */
.auth-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink-900);
    margin-bottom: var(--space-2);
    letter-spacing: 0.01em;
}

.auth-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.auth-forgot-link {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--brand-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-forgot-link:hover {
    color: var(--brand-500);
    text-decoration: underline;
}

/* Input Wrapper */
.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: var(--space-4);
    color: var(--ink-500);
    font-size: var(--text-lg);
    pointer-events: none;
    z-index: 1;
    transition: color var(--transition-fast);
}

/* Input */
.auth-input {
    width: 100%;
    padding: 14px var(--space-4);
    border: 2px solid var(--surface-100);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: var(--font-family);
    color: var(--ink-900);
    background-color: var(--surface-0);
    transition: all var(--transition-fast);
    outline: none;
}

.auth-input-wrap .auth-input {
    padding-left: 48px;
}

.auth-input::placeholder {
    color: var(--ink-500);
    opacity: 0.6;
}

.auth-input:hover {
    border-color: var(--brand-200);
}

.auth-input:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(0, 122, 94, 0.12);
}

.auth-input:focus ~ .auth-input-icon,
.auth-input-wrap:focus-within .auth-input-icon {
    color: var(--brand-600);
}

/* Validation error state */
.auth-input.input-validation-error {
    border-color: var(--color-error);
}

.auth-input.input-validation-error:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.auth-field-error {
    display: none;
    font-size: var(--text-sm);
    color: var(--color-error);
    margin-top: var(--space-2);
    font-weight: 500;
}

.auth-field-error:not(:empty) {
    display: block;
}

/* Password Toggle */
.auth-password-toggle {
    position: absolute;
    right: var(--space-3);
    background: none;
    border: none;
    color: var(--ink-500);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.auth-password-toggle:hover {
    color: var(--brand-600);
    background-color: var(--brand-50);
}

.auth-password-toggle:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

/* ============================================
   CHECKBOX
   ============================================ */
.auth-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--ink-700);
    line-height: 1.5;
    user-select: none;
}

.auth-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.auth-checkmark {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--surface-100);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    background: var(--surface-0);
}

.auth-checkmark::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transform: rotate(-45deg) scale(0);
    transition: all 0.15s ease;
    margin-top: -2px;
}

.auth-checkbox input:checked + .auth-checkmark {
    background: var(--brand-600);
    border-color: var(--brand-600);
}

.auth-checkbox input:checked + .auth-checkmark::after {
    border-color: #ffffff;
    transform: rotate(-45deg) scale(1);
}

.auth-checkbox input:focus-visible + .auth-checkmark {
    box-shadow: 0 0 0 3px rgba(0, 122, 94, 0.2);
}

.auth-checkbox--terms {
    align-items: flex-start;
}

.auth-checkbox--terms .auth-checkmark {
    margin-top: 2px;
}

/* ============================================
   SUBMIT BUTTON
   ============================================ */
.auth-submit {
    width: 100%;
    padding: 16px var(--space-6);
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-500) 100%);
    color: #ffffff !important;
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 122, 94, 0.25);
}

.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 122, 94, 0.35);
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-400) 100%);
}

.auth-submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 122, 94, 0.25);
}

.auth-submit:focus-visible {
    outline: 2px solid var(--brand-300);
    outline-offset: 2px;
}

/* Loading state */
.auth-submit-loader {
    display: none;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.auth-submit.loading .auth-submit-text {
    display: none;
}

.auth-submit.loading .auth-submit-loader {
    display: flex;
}

.auth-submit.loading {
    opacity: 0.85;
    cursor: not-allowed;
    pointer-events: none;
}

.auth-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   PASSWORD STRENGTH
   ============================================ */
.auth-strength {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.auth-strength-track {
    flex: 1;
    height: 4px;
    background: var(--surface-100);
    border-radius: 2px;
    overflow: hidden;
}

.auth-strength-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.strength-0 { width: 0%; background: var(--surface-100); }
.strength-1 { background: #EF4444; }
.strength-2 { background: #F97316; }
.strength-3 { background: #EAB308; }
.strength-4 { background: var(--brand-500); }

.auth-strength-text {
    font-size: var(--text-xs);
    color: var(--ink-500);
    font-weight: 500;
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}

/* Requirements List */
.auth-requirements {
    list-style: none;
    padding: 0;
    margin: var(--space-3) 0 0 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-1) var(--space-4);
}

.auth-requirements li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--ink-500);
    transition: color 0.2s ease;
}

.auth-requirements li i {
    font-size: 12px;
    transition: all 0.2s ease;
}

.auth-requirements li.met {
    color: var(--brand-600);
}

.auth-requirements li.met i {
    color: var(--brand-600);
}

/* ============================================
   LINKS & SWITCHES
   ============================================ */
.auth-link {
    color: var(--brand-600);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-link:hover {
    color: var(--brand-500);
}

.auth-switch {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--ink-500);
    margin-top: var(--space-6);
}

.auth-switch a {
    color: var(--brand-600);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ============================================
   PANEL FOOTER
   ============================================ */
.auth-panel-footer {
    margin-top: var(--space-10);
    padding-top: var(--space-6);
    border-top: 1px solid var(--surface-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.auth-panel-footer small {
    color: var(--ink-500);
    font-size: var(--text-xs);
}

.auth-panel-footer-links {
    display: flex;
    gap: var(--space-4);
}

.auth-panel-footer-links a {
    color: var(--ink-500);
    font-size: var(--text-xs);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-panel-footer-links a:hover {
    color: var(--brand-600);
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .auth-split {
        grid-template-columns: 1fr 1fr;
    }

    .auth-hero {
        padding: var(--space-8);
    }

    .auth-form-panel {
        padding: var(--space-8) var(--space-6);
    }
}

/* Mobile — collapse to single column */
@media (max-width: 768px) {
    .auth-split {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .auth-hero {
        display: none;
    }

    .auth-mobile-logo {
        display: block;
        text-align: center;
    }

    .auth-form-panel {
        min-height: 100vh;
        padding: var(--space-8) var(--space-6);
        background: linear-gradient(180deg, var(--brand-50) 0%, var(--surface-0) 30%);
    }

    .auth-form-wrapper {
        max-width: 100%;
    }

    .auth-title {
        text-align: center;
    }

    .auth-subtitle {
        text-align: center;
    }

    .auth-field-row {
        grid-template-columns: 1fr;
        gap: var(--space-5);
    }

    .auth-requirements {
        grid-template-columns: 1fr;
    }

    .auth-panel-footer {
        flex-direction: column;
        text-align: center;
    }
}

/* Small mobile */
@media (max-width: 400px) {
    .auth-form-panel {
        padding: var(--space-6) var(--space-4);
    }

    .auth-input {
        padding: 12px var(--space-3);
    }

    .auth-input-wrap .auth-input {
        padding-left: 40px;
    }

    .auth-input-icon {
        left: var(--space-3);
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .auth-hero-content,
    .auth-field,
    .auth-field-row,
    .auth-submit {
        animation: none;
    }

    .auth-hero-bg {
        transition: none;
    }
}
