/**
 * Login / signup / auth flows — aligned with marketing site (site/assets/site.css)
 */

/* ============================================
   Brand tokens (match Documenzo marketing)
   ============================================ */

:root {
    --auth-bg: #030712;
    --auth-bg-subtle: #0a0f1a;
    --auth-text: #f8fafc;
    --auth-muted: #94a3b8;
    --auth-muted2: #64748b;
    --auth-accent: #6366f1;
    --auth-accent-hover: #4f46e5;
    --auth-violet: #8b5cf6;
    --auth-accent-soft: rgba(99, 102, 241, 0.12);
    --auth-border: rgba(148, 163, 184, 0.1);
    --auth-border-strong: rgba(148, 163, 184, 0.18);
    --auth-surface: rgba(30, 41, 59, 0.45);
    --auth-surface-input: rgba(15, 23, 42, 0.65);
    --auth-font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
    --auth-display: "Outfit", var(--auth-font);
    --auth-radius: 14px;
    --auth-radius-sm: 10px;
    --auth-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --auth-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ============================================
   Page shell (marketing-style dark backdrop)
   ============================================ */

html.auth-page,
html:has(body.login-page) {
    min-height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    background-color: var(--auth-bg);
    background-image:
        radial-gradient(ellipse 100% 80% at 50% -30%, rgba(99, 102, 241, 0.22), transparent 55%),
        radial-gradient(ellipse 70% 50% at 100% 10%, rgba(139, 92, 246, 0.1), transparent 50%),
        radial-gradient(ellipse 60% 40% at 0% 50%, rgba(99, 102, 241, 0.06), transparent 45%),
        var(--auth-bg);
    background-repeat: no-repeat;
    background-size: 100% 100%, 100% 100%, 100% 100%, auto;
}

body.login-page {
    background: transparent;
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    margin: 0;
    position: relative;
    font-family: var(--auth-font);
    font-size: 16px;
    line-height: 1.65;
    color: var(--auth-text);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-font-smoothing: antialiased;
}

/* Subtle noise (same idea as marketing .site-bg::after) */
body.login-page::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    opacity: 1;
}

/* ============================================
   Auth container & card
   ============================================ */

.auth-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.auth-box {
    background: var(--auth-surface);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border-radius: var(--auth-radius);
    border: 1px solid var(--auth-border);
    box-shadow: var(--auth-shadow-lg);
    overflow: visible;
    padding: 2rem 1.75rem;
    position: relative;
    width: 100%;
    animation: authSlideUp 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-box > h2 {
    margin: 0 0 1.25rem;
    font-family: var(--auth-display);
    font-weight: 600;
    font-size: 1.35rem;
    letter-spacing: -0.03em;
    text-align: center;
    color: var(--auth-text);
}

@keyframes authSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (hover: hover) and (pointer: fine) {
    .auth-box:hover {
        border-color: var(--auth-border-strong);
    }
}

/* ============================================
   Header & logo
   ============================================ */

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo {
    margin-bottom: 1rem;
    animation: authFadeInDown 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo img {
    max-width: 160px;
    height: auto;
    filter: drop-shadow(0 4px 20px rgba(99, 102, 241, 0.25));
    transition: transform 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
    .logo img:hover {
        transform: scale(1.03);
    }
}

.auth-tagline {
    margin: 0 0 1rem;
    padding: 0 0.25rem;
    font-size: clamp(0.8125rem, 2.8vw, 0.9375rem);
    line-height: 1.5;
    color: var(--auth-muted);
    max-width: 26rem;
    margin-left: auto;
    margin-right: auto;
}

.verify-title,
.title.verify-title {
    font-family: var(--auth-display);
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
    color: var(--auth-text);
    margin: 0.5rem 0 0;
}

@keyframes authFadeInDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Tabs (sign in / sign up)
   ============================================ */

.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--auth-radius-sm);
    padding: 4px;
    gap: 4px;
    border: 1px solid var(--auth-border);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--auth-font);
    color: var(--auth-muted);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    border-radius: 8px;
    flex: 1;
    z-index: 1;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn:hover {
    color: var(--auth-text);
    background: rgba(255, 255, 255, 0.06);
}

.tab-btn.active {
    color: #fff;
    font-weight: 600;
    background: linear-gradient(135deg, var(--auth-accent) 0%, var(--auth-violet) 100%);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* ============================================
   Forms — index uses #auth-panel to toggle; other pages use visible single form
   ============================================ */

.auth-box > form.auth-form {
    display: block;
    opacity: 1;
    transform: none;
    width: 100%;
}

main#auth-panel.auth-box > form.auth-form {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.28s ease, transform 0.28s ease;
}

main#auth-panel.auth-box > form.auth-form.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group:last-of-type {
    margin-bottom: 0.75rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--auth-border-strong);
    border-radius: var(--auth-radius-sm);
    padding: 0 0.875rem;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    background-color: var(--auth-surface-input);
    margin-bottom: 0;
    min-height: 48px;
    height: 48px;
}

.input-group:hover {
    border-color: rgba(148, 163, 184, 0.28);
}

.input-group:focus-within {
    outline: none;
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px var(--auth-accent-soft);
}

.input-group i {
    color: var(--auth-muted2);
    font-size: 1rem;
    width: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 0.5rem;
    transition: color 0.2s ease;
}

.input-group:focus-within i {
    color: #a5b4fc;
}

.input-group input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9375rem;
    color: var(--auth-text);
    background: none;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: var(--auth-font);
    font-weight: 400;
}

.input-group input::placeholder {
    color: transparent;
}

.input-group .toggle-password {
    color: var(--auth-muted2);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    padding: 0.25rem;
    border-radius: 6px;
    margin-left: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    width: 28px;
    background: none;
    border: none;
}

.input-group .toggle-password:hover {
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.12);
}

.input-group .toggle-password i {
    font-size: 1rem;
    width: auto;
    margin: 0;
}

.input-group label {
    position: absolute;
    left: 3.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--auth-muted);
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    font-size: 0.9375rem;
    padding: 0 0.25rem;
    font-weight: 400;
    z-index: 1;
    background: transparent;
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
    top: -0.5rem;
    left: 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #c7d2fe;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 55%, transparent 55%);
    padding: 0 0.35rem;
    transform: translateY(0);
}

.input-group.valid {
    border-color: rgba(34, 197, 94, 0.55);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15);
}

.input-group.valid i {
    color: #4ade80;
}

.input-group.invalid {
    border-color: rgba(248, 113, 113, 0.65);
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.12);
}

.input-group.invalid i {
    color: #f87171;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.input-group.error {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
    border-color: #f87171;
}

/* ============================================
   Form options & links
   ============================================ */

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.875rem 0 1rem;
    font-size: 0.8125rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--auth-muted);
    cursor: pointer;
    user-select: none;
}

.remember-me input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--auth-accent);
}

.forgot-password {
    color: #a5b4fc;
    text-decoration: none;
    transition: color 0.18s ease;
    font-weight: 500;
}

.forgot-password:hover {
    color: #c4b5fd;
    text-decoration: underline;
}

.auth-legal-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.8125rem;
    color: var(--auth-muted2);
}

.auth-legal-footer a {
    color: #a5b4fc;
    text-decoration: none;
}

.auth-legal-footer a:hover {
    color: #c4b5fd;
    text-decoration: underline;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--auth-font);
    border-radius: var(--auth-radius-sm);
    border: none;
    cursor: pointer;
    transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
    text-decoration: none;
    line-height: 1.5;
    box-sizing: border-box;
}

.btn-primary {
    background: linear-gradient(135deg, var(--auth-accent) 0%, var(--auth-violet) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--auth-accent-hover) 0%, #6d28d9 100%);
    box-shadow: 0 6px 22px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-block {
    width: 100%;
    min-height: 44px;
}

/* ============================================
   Google / social
   ============================================ */

.social-login {
    margin-top: 1rem;
    text-align: center;
}

.social-login p {
    color: var(--auth-muted2);
    margin-bottom: 0.875rem;
    position: relative;
    font-size: 0.8125rem;
}

.social-login p::before,
.social-login p::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 32%;
    height: 1px;
    background: var(--auth-border-strong);
}

.social-login p::before {
    left: 0;
}

.social-login p::after {
    right: 0;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 1rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--auth-border-strong);
    border-radius: var(--auth-radius-sm);
    color: var(--auth-text);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--auth-font);
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
    text-decoration: none;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.google-btn:hover {
    background: rgba(30, 41, 59, 0.65);
    border-color: rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.google-btn img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ============================================
   Password requirements
   ============================================ */

.password-requirements {
    margin: 0.5rem 0 0;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.4);
    border-radius: var(--auth-radius-sm);
    border: 1px solid var(--auth-border);
}

.password-requirements small {
    display: block;
    color: var(--auth-muted);
    font-size: 0.75rem;
    margin: 0.25rem 0;
    transition: color 0.2s ease;
}

.password-requirements small.requirement {
    position: relative;
    padding-left: 1.25rem;
}

.password-requirements small.requirement::before {
    content: "○";
    position: absolute;
    left: 0;
    color: var(--auth-muted2);
}

.password-requirements small.requirement.met {
    color: #86efac;
}

.password-requirements small.requirement.met::before {
    content: "✓";
    color: #4ade80;
}

/* ============================================
   Verify email & misc
   ============================================ */

.verification-info {
    text-align: center;
    margin-bottom: 1.25rem;
}

.verification-info-text {
    color: var(--auth-muted);
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
}

.verification-email {
    font-weight: 600;
    color: var(--auth-text);
    word-break: break-all;
}

/* ============================================
   Alerts (inline)
   ============================================ */

.alert-container {
    margin-bottom: 1rem;
    width: 100%;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--auth-radius-sm);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8125rem;
    border: 1px solid;
    backdrop-filter: blur(8px);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(74, 222, 128, 0.35);
    color: #bbf7d0;
}

.alert i {
    font-size: 0.9375rem;
    flex-shrink: 0;
}

.alert-link {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .auth-container {
        max-width: 100%;
    }

    .auth-box {
        padding: 1.5rem 1.25rem;
        border-radius: var(--auth-radius-sm);
    }

    .logo img {
        max-width: 140px;
    }

    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }

    .input-group {
        padding: 0 0.75rem;
    }

    .input-group input {
        font-size: 16px;
    }

    .input-group label {
        left: 3rem;
        font-size: 0.8125rem;
    }

    .input-group input:focus + label,
    .input-group input:not(:placeholder-shown) + label {
        font-size: 0.625rem;
        left: 0.65rem;
    }
}

@media (max-width: 480px) {
    body.login-page {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    .auth-box {
        padding: 1.25rem 1rem;
    }

    .logo img {
        max-width: 120px;
    }

    .form-options {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .forgot-password {
        align-self: flex-end;
    }

    .social-login p::before,
    .social-login p::after {
        width: 26%;
    }
}

/* ============================================
   Reduced motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .auth-box,
    .logo,
    main#auth-panel.auth-box > form.auth-form {
        animation: none !important;
        transition: none !important;
    }

    .tab-btn,
    .btn-primary,
    .google-btn,
    .input-group {
        transition: none !important;
    }
}

/* Privacy checkbox row on signup */
.auth-box label[style*="display:flex"] {
    color: var(--auth-muted) !important;
    font-size: 0.8125rem !important;
    line-height: 1.5;
}

.auth-box label[style*="display:flex"] a {
    color: #a5b4fc;
}

.auth-box label[style*="display:flex"] a:hover {
    color: #c4b5fd;
}
