/* ============================================================================
   AUTHENTICATION STYLES
   ============================================================================ */

.auth-container {
    display: none; /* Hidden by default, shown after auth check */
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    padding: var(--space-4);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2);
    border: 1px solid var(--border-light);
    padding: var(--space-8);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}

.auth-logo-text {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

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

.auth-title {
    font-size: var(--font-size-22);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}

.auth-subtitle {
    font-size: var(--font-size-14);
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
}

/* Offline banner shown above the sign-in / sign-up forms when
   navigator.onLine is false. Cadeo's first-time login requires
   network (Supabase has to mint the access token). For returning
   users the cached session is used at cold launch; this banner
   only appears on the auth view itself. */
.auth-offline-banner {
    display: none;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    margin: 0 0 var(--space-3) 0;
    background: rgba(74, 144, 217, 0.08);
    border: 1px solid rgba(74, 144, 217, 0.25);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    line-height: 1.4;
}
.auth-offline-banner.visible { display: flex; }
.auth-offline-banner svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #4A90D9;
}

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

.auth-field label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.auth-field input {
    padding: var(--space-3) var(--space-3-5);
    font-size: var(--font-size-base);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--duration-normal) var(--ease-in-out), box-shadow var(--duration-normal) var(--ease-in-out);
}

.auth-field input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(53, 122, 189, 0.15);
}

.auth-field input::placeholder {
    color: var(--text-tertiary);
}

.auth-error {
    font-size: var(--font-size-sm);
    color: var(--color-red-text);
    min-height: 20px;
    text-align: center;
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    min-height: 44px;
    font-size: var(--font-size-base);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.auth-btn:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
}

.auth-btn-primary {
    background: var(--accent-fill);
    color: white;
}

.auth-btn-primary:hover {
    background: var(--accent-fill-hover);
}

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

.auth-btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.auth-btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
}

.auth-btn-google {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.auth-btn-google:hover {
    background: var(--bg-secondary);
    border-color: var(--border-secondary);
}

.auth-btn-apple {
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
}

.auth-btn-apple:hover {
    background: #1a1a1a;
}

.auth-btn-apple:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
}

[data-theme="dark"] .auth-btn-apple {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

[data-theme="dark"] .auth-btn-apple:hover {
    background: #e8e8e8;
}

.auth-btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-btn-loading .spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.auth-btn-loading .spinner circle {
    stroke-dasharray: 30 70;
    stroke-linecap: round;
}

/* Uses @keyframes spin defined earlier */

.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
}

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

.auth-switch {
    font-size: var(--font-size-14);
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

.auth-switch a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-consent {
    font-size: var(--font-size-12);
    line-height: 1.4;
    color: var(--text-secondary);
    text-align: center;
    margin: 12px 0 16px;
}

.auth-consent a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.auth-consent a:hover {
    text-decoration: underline;
}

.auth-password-wrap {
    position: relative;
}

.auth-password-wrap input {
    /* leave room for the toggle button on the right */
    padding-right: 40px;
}

.auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-in-out), color var(--duration-fast) var(--ease-in-out);
}

.auth-password-toggle:hover {
    background: var(--surface-hover, rgba(0,0,0,0.05));
    color: var(--text-primary);
}

.auth-password-toggle:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
}

.auth-field-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.auth-forgot-link {
    font-size: var(--font-size-sm);
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.auth-forgot-link:hover {
    text-decoration: underline;
}

.auth-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-4);
}

.auth-message-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-circle);
    background: rgba(53, 122, 189, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-message-icon svg {
    width: 32px;
    height: 32px;
    color: var(--accent-blue);
}

/* Loading overlay for auth */
.auth-loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: calc(var(--z-layer-modal) - 1);
}

.auth-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-blue);
    border-radius: var(--radius-circle);
    animation: spin 0.8s linear infinite;
}
