/* ============================================================
   TrustMemory Auth Pages — Login, Signup, Callback
   ============================================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #0f0f18;
    --bg-card: #141420;
    --bg-input: #1a1a2e;
    --border: #1e1e32;
    --border-hover: #2a2a45;
    --border-focus: #6366f1;

    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #606078;

    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-gradient: linear-gradient(135deg, #6366f1, #a78bfa);

    --success: #10b981;
    --danger: #ef4444;

    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

/* ---- Auth Container ---- */

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 24px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
}

/* ---- Auth Header ---- */

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    margin-bottom: 24px;
}

.auth-logo-img {
    height: 32px;
    width: auto;
    max-width: 100%;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---- Social Buttons ---- */

.social-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    min-height: 48px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
}

.btn-social svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-social:hover {
    border-color: var(--border-hover);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

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

.btn-github:hover {
    border-color: #8b949e;
}

.btn-google:hover {
    border-color: #4285F4;
}

.btn-social:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ---- Divider ---- */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

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

.auth-divider span {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ---- Form ---- */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 14px 14px;
    min-height: 48px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-group input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* ---- Submit Button ---- */

.btn-auth {
    width: 100%;
    padding: 14px;
    min-height: 48px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    margin-top: 8px;
}

.btn-auth:hover {
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

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

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

/* ---- Error ---- */

.auth-error {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ---- Auth Footer ---- */

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.auth-footer p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

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

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

.back-link {
    font-size: 0.8rem;
    color: var(--text-muted) !important;
}

.back-link:hover {
    color: var(--text-secondary) !important;
}

/* ---- Free Badge ---- */

.auth-free-badge {
    text-align: center;
    margin-top: 16px;
    padding: 10px;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-sm);
}

.auth-free-badge span {
    font-size: 0.8rem;
    color: var(--accent-light);
}

/* ---- Callback Spinner ---- */

.callback-status {
    padding: 40px 0;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.callback-status p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---- Forgot Password Link ---- */

.forgot-link {
    display: block;
    text-align: right;
    font-size: 0.8rem;
    color: var(--accent-light);
    text-decoration: none;
    margin-top: 6px;
    transition: color 0.2s;
}

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

/* ---- Success Message ---- */

.auth-success {
    text-align: center;
    padding: 24px 0;
}

.success-icon {
    width: 56px;
    height: 56px;
    line-height: 56px;
    text-align: center;
    font-size: 1.5rem;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    border: 2px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    margin: 0 auto 16px;
}

.auth-success h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.auth-success p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 8px;
}

.success-note {
    font-size: 0.8rem !important;
    color: var(--text-muted) !important;
    margin-top: 12px !important;
}

/* ---- Error Block (invalid token, etc.) ---- */

.auth-error-block {
    text-align: center;
    padding: 24px 0;
}

.auth-error-block h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--danger);
}

.auth-error-block p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding-top: 5vh;
        padding-bottom: 5vh;
    }

    .form-group input {
        font-size: 16px; /* Prevents iOS Safari auto-zoom on focus */
    }
}

@media (min-height: 700px) and (max-width: 768px) {
    body {
        align-items: center;
        padding-top: 0;
        padding-bottom: 0;
    }
}

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

    .auth-card {
        padding: 28px 20px;
    }

    .auth-header h1 {
        font-size: 1.3rem;
    }

    .auth-free-badge span {
        font-size: 0.85rem;
        line-height: 1.4;
    }
}

@media (max-width: 360px) {
    .auth-container {
        padding: 8px;
    }

    .auth-card {
        padding: 20px 16px;
    }

    .auth-divider span {
        white-space: normal;
        text-align: center;
    }

    .auth-divider {
        gap: 8px;
    }
}
