/**
 * Auth Page Styles
 * Uses design system variables from base/variables.css
 * Base reset and typography now inherited from base/index.css
 */

/* ============================================
   Page Layout
   ============================================ */

html {
    background: var(--bg-base);
    touch-action: manipulation;
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: var(--space-md) 0;
}

/* Ensure no white flash during redirects */
body.loading {
    opacity: 1;
    background: var(--bg-base);
}

/* Animated background */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(var(--accent-rgb), 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(var(--accent-rgb), 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(var(--accent-rgb), 0.05) 0%, transparent 50%);
    z-index: var(--z-behind);
    pointer-events: none;
}

/* ============================================
   Auth Container
   ============================================ */

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: var(--space-xl);
    animation: fadeInUp 0.6s ease-out;
}

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

/* ============================================
   Logo
   ============================================ */

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

.auth-logo .logo-icon {
    width: 64px !important;
    height: 64px !important;
    display: block;
    margin: 0 auto var(--space-xs) auto;
    object-fit: contain;
}

.logo-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

/* ============================================
   Auth Card
   ============================================ */

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
}

.auth-title {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    text-align: center;
    margin-bottom: var(--space-xs);
}

.auth-subtitle {
    color: var(--text-tertiary);
    text-align: center;
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
}

/* ============================================
   Tabs
   ============================================ */

.auth-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    background: var(--gray-2);
    padding: 0.25rem;
    border-radius: var(--radius-lg);
}

.tab-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--gray-3);
    color: var(--text-primary);
}

.tab-btn:hover:not(.active) {
    color: var(--text-secondary);
}

/* ============================================
   Form
   ============================================ */

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.625rem var(--space-md);
    background: var(--gray-2);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    outline: none;
    transition: all 0.2s ease;
}

.form-input:focus {
    background: var(--gray-3);
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.form-input::placeholder {
    color: var(--text-quaternary);
}

.form-hint {
    margin-top: var(--space-xs, 4px);
    font-size: var(--font-size-xs, 12px);
    color: var(--text-tertiary);
}

/* ============================================
   Password show/hide toggle
   ============================================ */
.password-field {
    position: relative;
}

/* Reserve room on the right so the typed password never slides under the
   eye button. The input keeps all its other .form-input styles. */
.password-field .form-input {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transition: color 0.2s ease;
}

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

.password-toggle:focus-visible {
    outline: none;
    color: var(--accent);
    box-shadow: var(--focus-ring);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Form Options (Remember me & Forgot)
   ============================================ */

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.forgot-link {
    font-size: var(--font-size-sm);
    color: var(--accent-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.forgot-link:hover {
    color: var(--accent-hover);
}

/* ============================================
   Buttons
   ============================================ */

.submit-btn {
    width: 100%;
    padding: 0.625rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.submit-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.submit-btn:active {
    transform: translateY(0);
}

/* ============================================
   Divider
   ============================================ */

.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-md) 0;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--border-medium);
}

.divider-text {
    font-size: var(--font-size-sm);
    color: var(--text-quaternary);
}

/* ============================================
   Social Buttons
   ============================================ */

.social-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 0.625rem;
    background: var(--gray-2);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.social-btn:hover {
    background: var(--gray-3);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.social-icon {
    width: 20px;
    height: 20px;
}

/* Google Sign-In button styling */
#googleButtonDiv {
    display: flex;
    justify-content: center;
    width: 100%;
}

#googleButtonDiv > div {
    width: 100% !important;
    max-width: 370px;
    margin: 0 auto;
}

/* Override Google button styles */
.nsm7Bb-HzV7m-LgbsSe {
    width: 100% !important;
    height: 48px !important;
    font-family: inherit !important;
}

.nsm7Bb-HzV7m-LgbsSe:hover {
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3) !important;
}

/* Capitalize each word in Google button text */
.nsm7Bb-HzV7m-LgbsSe-V67aGc {
    text-transform: capitalize !important;
}

/* ============================================
   Footer
   ============================================ */

.auth-footer {
    text-align: center;
    margin-top: var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
}

.auth-footer a {
    color: var(--accent-text);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: color 0.2s ease;
}

.auth-footer a:hover {
    color: var(--accent-hover);
}

/* ============================================
   Auth Loading (shown while checking auth state)
   ============================================ */

.auth-loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    background: var(--bg-base);
    z-index: var(--z-modal, 100);
}

.auth-loading__logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.auth-loading__spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-full);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

/* ============================================
   Loading State
   ============================================ */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    border-top-color: var(--text-primary);
    animation: spin 0.8s linear infinite;
}

/* Mobile performance optimization */
.no-animations,
.no-animations * {
    animation: none !important;
    transition: none !important;
    transform: none !important;
}

/* Auth loading spinner must always animate, even on mobile */
#authSpinner {
    animation: spin 0.8s linear infinite !important;
}

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

/* ============================================
   Messages
   ============================================ */

.error-message {
    display: none;
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-danger-light);
    border: 1px solid rgba(var(--accent-danger-rgb), 0.3);
    border-radius: var(--radius-md);
    color: var(--accent-danger);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
}

.error-message.show {
    display: block;
}

.success-message {
    display: none;
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-success-light);
    border: 1px solid rgba(var(--accent-success-rgb), 0.3);
    border-radius: var(--radius-md);
    color: var(--accent-success);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
}

.success-message.show {
    display: block;
}
