/**
 * Authentication Pages Styles
 * Modern, refined login experience
 */

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface-secondary);
    padding: var(--safe-area-inset-top) var(--safe-area-inset-right)
        var(--safe-area-inset-bottom) var(--safe-area-inset-left);
}

/* Subtle background pattern */
.auth-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(
            ellipse at 20% 0%,
            var(--color-primary-100) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse at 80% 100%,
            var(--color-accent-100) 0%,
            transparent 50%
        );
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AUTH CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: var(--container-sm);
    margin: auto;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    animation: fade-in var(--duration-slow) var(--ease-out);
}

@media (min-width: 640px) {
    .auth-container {
        padding: var(--space-10);
    }
}

/* Card variant for larger screens */
@media (min-width: 640px) {
    .auth-container--card {
        background: var(--surface-primary);
        border-radius: var(--radius-2xl);
        box-shadow: var(--shadow-xl);
        margin-top: var(--space-12);
        margin-bottom: var(--space-12);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGO & BRANDING
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-logo {
    text-align: center;
    margin-bottom: var(--space-10);
}

.auth-logo__crest {
    width: 200px;
    height: auto;
    margin: 0 auto var(--space-6);
    display: block;
}

.auth-logo__title {
    font-family: var(--font-serif);
    font-size: var(--text-3xl);
    font-weight: var(--weight-semibold);
    color: var(--color-primary-800);
    letter-spacing: var(--tracking-tight);
    margin-bottom: var(--space-1);
}

.auth-logo__subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WELCOME MESSAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-message {
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-message__title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.auth-message__text {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.auth-form__group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.auth-form__label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}

.auth-form__input {
    height: var(--height-input);
    padding: 0 var(--space-4);
    background: var(--surface-primary);
    border: var(--border-width-default) solid var(--border-default);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    color: var(--text-primary);
    transition: var(--transition-all);
}

.auth-form__input:hover:not(:disabled) {
    border-color: var(--border-strong);
}

.auth-form__input:focus {
    outline: none;
    border-color: var(--color-primary-500);
    box-shadow: var(--shadow-focus);
}

.auth-form__input--error {
    border-color: var(--color-error-500);
}

.auth-form__input--error:focus {
    box-shadow: var(--shadow-focus-error);
}

.auth-form__hint {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.auth-form__error {
    font-size: var(--text-sm);
    color: var(--color-error-600);
}

/* Password visibility toggle */
.auth-form__password-wrapper {
    position: relative;
}

.auth-form__password-wrapper .auth-form__input {
    width: 100%;
}

.auth-form__password-toggle {
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    width: var(--touch-target-sm);
    height: var(--touch-target-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    border-radius: var(--radius-md);
    transition: var(--transition-colors);
}

.auth-form__password-toggle:hover {
    color: var(--text-secondary);
    background: var(--surface-tertiary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SUBMIT BUTTON
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-form__submit {
    width: 100%;
    height: var(--height-button-lg);
    margin-top: var(--space-2);
    background: var(--color-primary-700);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: var(--transition-all);
}

.auth-form__submit:hover:not(:disabled) {
    background: var(--color-primary-800);
}

.auth-form__submit:active:not(:disabled) {
    background: var(--color-primary-900);
    transform: scale(0.98);
}

.auth-form__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading state */
.auth-form__submit--loading {
    position: relative;
    color: transparent;
}

.auth-form__submit--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;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
    animation: slide-up var(--duration-normal) var(--ease-out);
}

.auth-alert--error {
    background: var(--color-error-50);
    border: var(--border-width-thin) solid var(--color-error-100);
}

.auth-alert--success {
    background: var(--color-success-50);
    border: var(--border-width-thin) solid var(--color-success-100);
}

.auth-alert__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.auth-alert--error .auth-alert__icon {
    color: var(--color-error-500);
}

.auth-alert--success .auth-alert__icon {
    color: var(--color-success-500);
}

.auth-alert__message {
    font-size: var(--text-sm);
    line-height: var(--leading-snug);
}

.auth-alert--error .auth-alert__message {
    color: var(--color-error-700);
}

.auth-alert--success .auth-alert__message {
    color: var(--color-success-700);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LINKS & SECONDARY ACTIONS
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-links {
    margin-top: var(--space-6);
    text-align: center;
}

.auth-link {
    display: inline-block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-primary-600);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: var(--transition-colors);
}

.auth-link:hover {
    color: var(--color-primary-700);
    background: var(--color-primary-50);
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: var(--space-6) 0;
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: var(--border-width-thin);
    background: var(--border-subtle);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-footer {
    margin-top: auto;
    padding-top: var(--space-10);
    text-align: center;
}

.auth-footer__text {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    line-height: var(--leading-relaxed);
}

.auth-footer__tagline {
    font-style: italic;
    margin-top: var(--space-1);
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BACK LINK (for sub-pages)
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    padding: var(--space-2);
    margin: calc(-1 * var(--space-2));
    margin-bottom: var(--space-4);
    border-radius: var(--radius-md);
    transition: var(--transition-colors);
}

.auth-back:hover {
    color: var(--text-primary);
    background: var(--surface-tertiary);
}

.auth-back__icon {
    width: 16px;
    height: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger form fields */
.auth-form > * {
    animation: slide-up var(--duration-normal) var(--ease-out) backwards;
}

.auth-form > *:nth-child(1) {
    animation-delay: 50ms;
}
.auth-form > *:nth-child(2) {
    animation-delay: 100ms;
}
.auth-form > *:nth-child(3) {
    animation-delay: 150ms;
}
.auth-form > *:nth-child(4) {
    animation-delay: 200ms;
}
.auth-form > *:nth-child(5) {
    animation-delay: 250ms;
}
