/* Whole-page scroll: the document scrolls, not an inner container. Chatbot_UI.css
   sets html/body height:100% and body overflow:hidden for the chat app, so override
   them here for the login page only. */
html {
    height: auto;
}

body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 0.5rem;
    position: relative;
    z-index: 10;
}

.login-container {
    background: transparent;
    border: none;
    padding: 0;
    width: 100%;
    max-width: 440px;
    text-align: center;
    flex-shrink: 0;
    /* centers when content fits; auto margins collapse so tall forms start at the
       top and the document scrolls instead of clipping */
    margin: auto;
}


.login-header {
    margin-bottom: 1rem;
}

.login-header .logo-pill {
    margin: 0 auto 1.5rem;
    display: inline-flex;
}

.login-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    visibility: visible;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    visibility: visible;
}

.login-methods {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ponytail: Clerk bundle can take a moment; show a spinner until it mounts */
.clerk-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.9rem;
}

.clerk-loader[hidden] {
    display: none;
}

.clerk-spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #ffd700;
    animation: clerkSpin 0.8s linear infinite;
}

.clerk-loader-error {
    color: #fca5a5;
}

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

@media (prefers-reduced-motion: reduce) {
    .clerk-spinner { animation-duration: 2s; }
}

/* Post-login success check, shown while redirecting into the app. */
.login-success {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    background: rgba(3, 6, 17, 0.88);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.login-success[hidden] { display: none; }
.login-success.active { opacity: 1; }

.login-success-check { width: 84px; height: 84px; }
.login-success-circle {
    stroke: #22c55e;
    stroke-width: 3;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
}
.login-success-path {
    stroke: #22c55e;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 34;
    stroke-dashoffset: 34;
}
.login-success.active .login-success-circle { animation: successCircle 0.5s ease forwards; }
.login-success.active .login-success-path { animation: successCheck 0.35s 0.45s ease forwards; }
.login-success-text {
    color: #e5e7eb;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

@keyframes successCircle { to { stroke-dashoffset: 0; } }
@keyframes successCheck { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
    .login-success.active .login-success-circle,
    .login-success.active .login-success-path {
        animation-duration: 0.01s;
        animation-delay: 0s;
    }
}

/* ponytail: Clerk stable classes - keep legal/consent text readable on the dark page */
#sign-in-container .cl-formFieldLabel,
#sign-in-container .cl-formFieldLabelText,
#sign-in-container .cl-formFieldHintText,
#sign-in-container .cl-footerAction,
#sign-in-container .cl-footerActionText {
    color: #ffffff;
}

#sign-in-container .cl-formFieldAction,
#sign-in-container .cl-footerActionLink {
    color: #ffd700;
}

.google-signin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-signin-btn:hover {
    background: var(--surface-3);
    border-color: var(--border-focus);
    transform: translateY(-1px);
}

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

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}

.divider span {
    padding: 0 1rem;
}

.magic-link-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group input {
    padding: 0.875rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.primary-btn {
    background: var(--primary-accent);
    color: white;
    border: none;
    padding: 0.875rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-message {
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.login-message.success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.login-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.login-footer {
    margin-top: 2rem;
    padding-bottom: 1.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

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

/* Spinner for button */
.spinner {
    animation: rotate 2s linear infinite;
    z-index: 2;
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

.spinner .path {
    stroke: white;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}
