/* Modern auth / message pages — gated by .modern-theme (UseModernTheme surveys only).
   Color tokens are NOT defined here — they are injected from survey theme SettingsJSON
   (PrimaryColor, etc.) via ModernAuthThemeModel.GetCssVariablesStyle() on the root element. */

.modern-theme {
    --survey-rendering-overlay: rgba(0, 0, 0, 0.1);

    box-sizing: border-box;
    width: 100%;
    min-height: 100vh;
    margin: 0;
    background: var(--survey-page-background);
    color: var(--survey-foreground);
    font-family: var(--survey-font-family, "Open Sans");
    font-size: var(--survey-base-font-size);
    line-height: 1.45;
    overflow-y: auto;
}

.modern-theme *,
.modern-theme *::before,
.modern-theme *::after {
    box-sizing: border-box;
}

.modern-theme .modern-auth-shell {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    min-height: calc(100vh - 6rem);
    margin: 0 auto;
    max-width: 42rem;
    padding: 3rem;
}

.modern-theme .modern-auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.modern-theme .modern-auth-logo {
    max-height: 3rem;
    width: auto;
    object-fit: contain;
}

.modern-theme .modern-auth-content {
    width: 100%;
    max-width: 28rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem 0;
    justify-content: flex-start;
}

.modern-theme .modern-auth-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    margin-top: auto;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--survey-muted-foreground);
    letter-spacing: -0.01em;
}

.modern-theme .modern-auth-form,
.modern-theme .modern-auth-content form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.modern-theme .modern-auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modern-theme .modern-auth-field label {
    font-size: var(--survey-base-font-size);
    font-weight: 400;
    color: var(--survey-foreground);
}

/* TextAnswer / global input chrome: rest, hover, focus, error */
.modern-theme .modern-auth-field input[type="text"],
.modern-theme .modern-auth-field input[type="password"] {
    height: var(--survey-input-height);
    width: 100%;
    padding: 0.25rem 1rem;
    border: var(--survey-border-width, 1px) solid var(--survey-control-border);
    border-radius: var(--survey-border-radius);
    background: var(--survey-input-background);
    color: var(--survey-foreground);
    font-size: var(--survey-base-font-size);
    font-family: inherit;
    outline: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, border-width 0.15s ease;
}

.modern-theme .modern-auth-field input[type="text"]:hover:not(:disabled):not(:focus),
.modern-theme .modern-auth-field input[type="password"]:hover:not(:disabled):not(:focus) {
    background: var(--survey-muted-background, #F0EFEF);
}

/* Active / focus — primary 2px border while editing (mouse or keyboard). */
.modern-theme .modern-auth-field input[type="text"]:focus,
.modern-theme .modern-auth-field input[type="password"]:focus {
    border: 2px solid var(--survey-primary);
    background: var(--survey-input-background);
    box-shadow: none;
}

/* Keyboard/tab focus only — class set by modern-auth keyboard-focus script
   (browsers match :focus-visible on text inputs for pointer focus too). */
.modern-theme .modern-auth-field input[type="text"].is-keyboard-focus:focus,
.modern-theme .modern-auth-field input[type="password"].is-keyboard-focus:focus {
    box-shadow:
        0 0 0 2px var(--survey-white),
        0 0 0 4px var(--survey-focus-ring);
}

.modern-theme .modern-auth-field input[type="text"]:disabled,
.modern-theme .modern-auth-field input[type="password"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modern-theme .modern-auth-content form.is-invalid .modern-auth-field input[type="text"],
.modern-theme .modern-auth-content form.is-invalid .modern-auth-field input[type="password"],
.modern-theme .modern-auth-field.is-invalid input[type="text"],
.modern-theme .modern-auth-field.is-invalid input[type="password"] {
    border-color: var(--survey-error);
}

.modern-theme .modern-auth-content form.is-invalid .modern-auth-field input[type="text"]:focus,
.modern-theme .modern-auth-content form.is-invalid .modern-auth-field input[type="password"]:focus,
.modern-theme .modern-auth-field.is-invalid input[type="text"]:focus,
.modern-theme .modern-auth-field.is-invalid input[type="password"]:focus {
    border-color: var(--survey-error);
    box-shadow: none;
}

.modern-theme .modern-auth-content form.is-invalid .modern-auth-field input[type="text"].is-keyboard-focus:focus,
.modern-theme .modern-auth-content form.is-invalid .modern-auth-field input[type="password"].is-keyboard-focus:focus,
.modern-theme .modern-auth-field.is-invalid input[type="text"].is-keyboard-focus:focus,
.modern-theme .modern-auth-field.is-invalid input[type="password"].is-keyboard-focus:focus {
    box-shadow:
        0 0 0 2px var(--survey-white),
        0 0 0 4px var(--survey-error);
}

.modern-theme .modern-auth-error {
    color: var(--survey-error);
    background: var(--survey-error-background);
    font-size: 0.875rem;
    font-weight: 400;
    padding: 0.75rem;
    border-radius: var(--survey-border-radius);
}

.modern-theme .modern-auth-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.modern-theme .modern-auth-primary-button {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.5rem;
    padding: 0 2rem;
    border: none;
    border-radius: var(--survey-border-radius);
    background: var(--survey-button-background);
    color: var(--survey-button-foreground);
    font-size: var(--survey-base-font-size);
    font-family: inherit;
    font-weight: 400;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    outline: none;
    transition: box-shadow 0.15s ease;
}

.modern-theme .modern-auth-primary-button::after {
    content: "";
    position: absolute;
    inset: 0;
    background: transparent;
    transition: background-color 0.15s ease;
    pointer-events: none;
    border-radius: inherit;
}

.modern-theme .modern-auth-primary-button:hover:not(:disabled)::after {
    background: var(--survey-rendering-overlay);
}

.modern-theme .modern-auth-primary-button:active:not(:disabled)::after {
    background: rgba(0, 0, 0, 0.16);
}

/* Primary button focus-visible — inset + white gap + outer halo (SurveyEngineJS modernButtonFocus) */
.modern-theme .modern-auth-primary-button:focus-visible {
    box-shadow:
        0 0 0 var(--survey-border-width, 1px) var(--survey-focus-ring) inset,
        0 0 0 2px var(--survey-white),
        0 0 0 4px var(--survey-focus-ring);
}

.modern-theme .modern-auth-primary-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.modern-theme .modern-auth-primary-button:disabled::after {
    display: none;
}

.modern-theme .modern-auth-message {
    color: var(--survey-foreground);
    font-size: var(--survey-base-font-size);
}

/* Bot prevention (recaptcha) under modern theme — class is on the verification root itself */
.modern-theme.recaptcha-verification,
.modern-theme .recaptcha-verification {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 3rem 1rem;
    box-sizing: border-box;
}

.modern-theme.recaptcha-verification .recaptcha-message,
.modern-theme .recaptcha-verification .recaptcha-message {
    width: 100%;
    max-width: 42rem;
    margin: 0 auto;
}

.modern-theme.recaptcha-verification .recaptcha-message-text,
.modern-theme .recaptcha-message .recaptcha-message-text {
    font-size: var(--survey-base-font-size);
    color: var(--survey-foreground);
    font-family: inherit;
    font-weight: 400;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--survey-control-border);
}

.modern-theme.recaptcha-verification .continue-button,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button {
    position: relative;
    overflow: hidden;
    background-color: var(--survey-button-background);
    color: var(--survey-button-foreground);
    border: none;
    border-radius: var(--survey-border-radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 0.625rem 4.5rem;
    font-family: inherit;
}

.modern-theme.recaptcha-verification .continue-button::after,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button::after {
    content: "";
    position: absolute;
    inset: 0;
    background: transparent;
    transition: background-color 0.15s ease;
    pointer-events: none;
}

.modern-theme.recaptcha-verification .continue-button:hover,
.modern-theme.recaptcha-verification .continue-button:active,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button:hover,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button:active {
    background-color: var(--survey-button-background);
    color: var(--survey-button-foreground);
}

.modern-theme.recaptcha-verification .continue-button:hover::after,
.modern-theme.recaptcha-verification .continue-button:active::after,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button:hover::after,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button:active::after {
    background: var(--survey-rendering-overlay);
}

.modern-theme.recaptcha-verification .continue-button:active:not(:disabled)::after,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button:active:not(:disabled)::after {
    background: rgba(0, 0, 0, 0.16);
}

.modern-theme.recaptcha-verification .continue-button:focus-visible,
.modern-theme .recaptcha-message .recaptcha-message-button .continue-button:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 var(--survey-border-width, 1px) var(--survey-focus-ring) inset,
        0 0 0 2px var(--survey-white),
        0 0 0 4px var(--survey-focus-ring);
}

.modern-theme.recaptcha-verification .recaptcha-legal,
.modern-theme .recaptcha-legal {
    width: 100%;
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
    margin-top: 12px;
    color: var(--survey-muted-foreground);
    text-align: center;
}

.modern-theme.recaptcha-verification .recaptcha-legal a,
.modern-theme .recaptcha-legal a {
    color: var(--survey-foreground);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: color-mix(in srgb, var(--survey-primary) 30%, transparent);
    font-weight: 600;
}

.modern-theme.recaptcha-verification .recaptcha-legal a:hover,
.modern-theme .recaptcha-legal a:hover {
    color: var(--survey-primary);
    text-decoration-color: var(--survey-primary);
}

@media (max-width: 768px) {
    .modern-theme .modern-auth-shell {
        padding: 1.5rem 1rem;
        min-height: 100vh;
        gap: 3rem;
    }

    .modern-theme .modern-auth-content {
        max-width: 24rem;
        margin: 0 auto;
        align-items: stretch;
    }

    .modern-theme .modern-auth-actions {
        justify-content: stretch;
    }

    .modern-theme .modern-auth-primary-button {
        width: 100%;
    }

    .modern-theme.recaptcha-verification .continue-button,
    .modern-theme .recaptcha-message .recaptcha-message-button .continue-button {
        width: 100%;
        padding: 0.625rem 1rem;
    }
}
