/* ============================================================
   TGG CorePlatform — Auth UI (Google Identity-level)
   Used by: Login, LoginTwoFactor, ForgotPassword, ResetPassword,
            ForgotPasswordSuccess
   Depends on: Bootstrap 5.3 base + Material Symbols Rounded
   ============================================================ */

:root {
    /* Google-admin palette (aligned with google-admin-theme.css) */
    --auth-bg-page: #f0f2f5;
    --auth-bg-panel: #ffffff;
    --auth-bg-brand: linear-gradient(135deg, #0b3d91 0%, #1a73e8 55%, #4FC3F7 100%);
    --auth-border: #dadce0;
    --auth-border-hover: #c2c8d0;
    --auth-focus-ring: rgba(26, 115, 232, 0.32);
    --auth-heading: #202124;
    --auth-body: #3c4043;
    --auth-muted: #5f6368;
    --auth-primary: #1a73e8;
    --auth-primary-hover: #1557b0;
    --auth-primary-text: #ffffff;
    --auth-success: #1e8e3e;
    --auth-success-bg: #e6f4ea;
    --auth-success-border: #b5deb9;
    --auth-danger: #d93025;
    --auth-danger-bg: #fce8e6;
    --auth-danger-border: #f5c5c0;
    --auth-warning: #b06000;
    --auth-warning-bg: #fef7e0;
    --auth-card-shadow: 0 1px 2px rgba(60,64,67,.08), 0 2px 6px rgba(60,64,67,.12);
    --auth-font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --auth-radius: 12px;
    --auth-radius-input: 8px;
    --auth-input-h: 42px;
    --auth-btn-h: 42px;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body.auth-body {
    font-family: var(--auth-font);
    font-size: 14px;
    background: var(--auth-bg-page);
    color: var(--auth-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Page-level no-scroll on desktop where everything fits the viewport */
    overflow: hidden;
}

@media (max-width: 899.98px) {
    /* On phones / narrow tablets: allow vertical scroll if content overflows. */
    body.auth-body { overflow: auto; height: auto; min-height: 100vh; }
}

/* ---------- Material Symbols (critical: prevent ligature TEXT flash) ----------
   fonts-local.css ships only the @font-face declaration (no class rules).
   Without these rules the spans render as plain text ("account_circle",
   "mail") because the fallback font has no Material Symbols ligatures.
   Combined with font-display:block (in fonts-local.css) + a <link rel="preload">
   in _AuthLayout.cshtml, the glyph is invisible during the brief font
   download and then snaps in as the actual icon. */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 22px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
    min-width: 1em;
    min-height: 1em;
    text-align: center;
}

/* Belt-and-suspenders: if the icon font fails to load entirely (3s block
   period elapses → fallback), hide the ligature TEXT so the user never
   sees raw "account_circle" / "mail" spans. JS in the layout adds the
   .fonts-loaded class once document.fonts.ready resolves. */
html:not(.fonts-loaded) .material-symbols-rounded {
    visibility: hidden;
}

/* ---------- Layout: split brand / card ---------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 900px) {
    .auth-shell {
        height: 100vh;            /* hard-fit viewport on desktop */
        min-height: 0;
        grid-template-columns: minmax(340px, 1fr) minmax(400px, 520px);
    }
}

/* --- left brand panel (hidden on narrow screens) --- */
.auth-brand {
    display: none;
    position: relative;
    background: var(--auth-bg-brand);
    color: #fff;
    padding: 36px 40px;
    overflow: hidden;
    isolation: isolate;
}

@media (min-width: 900px) {
    .auth-brand { display: flex; flex-direction: column; }
}

/* Soft accent blooms (atmosphere) */
.auth-brand::before,
.auth-brand::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .55;
    z-index: 0;
    pointer-events: none;
}

.auth-brand::before {
    width: 560px; height: 560px;
    background: radial-gradient(circle, #79c0ff 0%, transparent 70%);
    top: -200px; right: -200px;
}

.auth-brand::after {
    width: 460px; height: 460px;
    background: radial-gradient(circle, #ffd54f 0%, transparent 70%);
    bottom: -160px; left: -160px;
    opacity: .22;
}

/* Inline SVG backdrop (honeycomb pattern + skyline silhouette) — sits
   between the gradient blooms and the foreground content. */
.auth-brand-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    user-select: none;
}

.auth-brand > * {
    position: relative;
    z-index: 2;
}

/* Subtle parallax breath on the skyline (respects reduced-motion below).
   Softened after switching to the landscape 1400x1000 viewBox — the larger
   canvas makes the old scale/translate values too pronounced. */
@keyframes auth-brand-breathe {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(0, -3px, 0) scale(1.005); }
    100% { transform: translate3d(0, 0, 0) scale(1); }
}

.auth-brand-backdrop {
    animation: auth-brand-breathe 14s ease-in-out infinite;
}

.auth-brand-logo {
    height: 36px;
    width: auto;
    filter: brightness(0) invert(1);
    margin-bottom: auto;
}

.auth-brand-body {
    max-width: 440px;
    margin-top: 16px;
}

.auth-brand-title {
    font-size: 26px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.2px;
    margin: 0 0 8px;
}

.auth-brand-tagline {
    font-size: 14px;
    line-height: 1.55;
    opacity: 0.88;
    margin: 0;
}

.auth-brand-footer {
    margin-top: 18px;
    font-size: 11.5px;
    opacity: 0.7;
    letter-spacing: 0.3px;
}

/* Subtle honeycomb / neural dots accent (SVG patterned) */
.auth-brand-accent {
    position: absolute;
    right: -40px; bottom: 40px;
    width: 280px; height: 280px;
    opacity: 0.18;
    pointer-events: none;
    z-index: -1;
}

/* --- right card panel --- */
.auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px 16px;
    background: var(--auth-bg-page);
}

@media (min-width: 600px) { .auth-panel { padding: 24px 28px; } }
@media (min-width: 900px) {
    .auth-panel {
        background: #fff;
        padding: 16px 32px;
        height: 100vh;
        overflow-y: auto;          /* card scrolls inside right column if needed */
        scrollbar-width: thin;
    }
    .auth-brand { overflow: hidden; height: 100vh; }
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--auth-bg-panel);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-card-shadow);
    padding: 24px 22px;
}

@media (min-width: 600px) {
    .auth-card { padding: 28px 30px 24px; }
}

@media (min-width: 900px) {
    .auth-card { border: none; box-shadow: none; background: transparent; padding: 12px 4px; }
}

/* Mobile logo header (shown only when brand panel hidden) */
.auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--auth-heading);
    font-size: 14px;
    letter-spacing: 0.2px;
}

@media (min-width: 900px) { .auth-mobile-brand { display: none; } }

.auth-mobile-brand img { height: 24px; width: auto; }

/* ---------- Typography ---------- */
.auth-title {
    font-size: 22px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--auth-heading);
    margin: 0 0 4px;
    letter-spacing: -0.1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-title .material-symbols-rounded {
    font-size: 26px;
    color: var(--auth-primary);
}

.auth-sub {
    color: var(--auth-muted);
    font-size: 13px;
    line-height: 1.45;
    margin: 0 0 14px;
}

.auth-section-divider {
    border: 0;
    border-top: 1px solid var(--auth-border);
    margin: 20px 0;
}

/* ---------- Alerts ---------- */
.auth-alert {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.auth-alert .material-symbols-rounded {
    font-size: 20px;
    flex: 0 0 auto;
    margin-top: 1px;
}

.auth-alert-danger { color: var(--auth-danger); background: var(--auth-danger-bg); border-color: var(--auth-danger-border); }
.auth-alert-success { color: var(--auth-success); background: var(--auth-success-bg); border-color: var(--auth-success-border); }
.auth-alert-warning { color: var(--auth-warning); background: var(--auth-warning-bg); border-color: #f6dfa6; }
.auth-alert-info    { color: #174ea6; background: #e8f0fe; border-color: #c4d8fb; }

/* ---------- Form fields (floating-icon pattern) ---------- */
.auth-field {
    margin-bottom: 12px;
}

.auth-field-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--auth-body);
    margin-bottom: 4px;
    letter-spacing: 0.1px;
}

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-wrap > .material-symbols-rounded.prefix {
    position: absolute;
    left: 14px;
    font-size: 20px;
    color: var(--auth-muted);
    pointer-events: none;
    line-height: 1;
}

.auth-input {
    width: 100%;
    height: var(--auth-input-h);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-input);
    padding: 0 14px 0 40px;
    font-size: 14px;
    font-family: inherit;
    color: var(--auth-heading);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.auth-input::placeholder { color: var(--auth-muted); opacity: 1; }
.auth-input:hover { border-color: var(--auth-border-hover); }
.auth-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px var(--auth-focus-ring);
}

.auth-input[readonly] { background: #f8f9fa; cursor: default; }
.auth-input.is-invalid {
    border-color: var(--auth-danger);
    box-shadow: 0 0 0 3px rgba(217,48,37,.18);
}

/* Password show/hide toggle */
.auth-input-wrap.with-toggle .auth-input { padding-right: 44px; }

.auth-toggle-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--auth-muted);
    cursor: pointer;
    transition: background .15s ease;
}

.auth-toggle-btn:hover { background: rgba(60,64,67,0.08); color: var(--auth-body); }
.auth-toggle-btn:focus-visible { outline: 2px solid var(--auth-primary); outline-offset: 1px; }
.auth-toggle-btn .material-symbols-rounded { font-size: 20px; }

/* Numeric OTP input (LoginTwoFactor) */
.auth-otp-input {
    text-align: center;
    letter-spacing: 0.5em;
    font-size: 20px;
    font-weight: 500;
    padding-left: 14px !important;
    font-variant-numeric: tabular-nums;
}

/* Field-level error text */
.auth-field-error {
    font-size: 12.5px;
    color: var(--auth-danger);
    margin: 6px 0 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.auth-field-hint {
    font-size: 12.5px;
    color: var(--auth-muted);
    margin: 6px 0 0;
}

/* ---------- Checkbox row ---------- */
.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    color: var(--auth-body);
}

.auth-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--auth-primary);
    cursor: pointer;
}

.auth-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.auth-link:hover { color: var(--auth-primary-hover); text-decoration: underline; }
.auth-link .material-symbols-rounded { font-size: 18px; }

/* ---------- Button ---------- */
.auth-btn {
    width: 100%;
    min-height: var(--auth-btn-h);
    border: none;
    border-radius: var(--auth-radius-input);
    font-size: 14.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 20px;
    letter-spacing: 0.1px;
    transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
}

.auth-btn .material-symbols-rounded { font-size: 18px; }

.auth-btn-primary { background: var(--auth-primary); color: var(--auth-primary-text); }
.auth-btn-primary:hover { background: var(--auth-primary-hover); }
.auth-btn-primary:active { transform: translateY(1px); }
.auth-btn-primary:focus-visible { outline: 3px solid var(--auth-focus-ring); outline-offset: 2px; }
.auth-btn-primary:disabled {
    background: #e0e0e0;
    color: #9aa0a6;
    cursor: not-allowed;
}

.auth-btn-ghost {
    background: transparent;
    color: var(--auth-primary);
    border: 1px solid var(--auth-border);
}

.auth-btn-ghost:hover { background: rgba(26,115,232,0.06); border-color: var(--auth-primary); }

.auth-btn-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

/* Button loading spinner */
.auth-btn[data-loading="true"] {
    pointer-events: none;
    opacity: 0.85;
}

.auth-btn[data-loading="true"] .auth-btn-label { visibility: hidden; }
.auth-btn[data-loading="true"]::after {
    content: "";
    position: absolute;
    width: 18px; height: 18px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: auth-spin .6s linear infinite;
}

.auth-btn { position: relative; }

@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */
.auth-foot {
    margin-top: 12px;
    text-align: center;
}

.auth-foot .auth-foot-row {
    font-size: 12px;
    color: var(--auth-muted);
    margin: 0;
}

.auth-back {
    margin-top: 12px;
    text-align: center;
}

/* Turnstile widget centering */
.auth-turnstile {
    margin: 2px 0 10px;
    display: flex;
    justify-content: center;
    min-height: 65px;
}
.auth-turnstile .cf-turnstile {
    transform: scale(0.92);
    transform-origin: center;
}

/* ---------- RTL ---------- */
html[dir="rtl"] .auth-input { padding: 0 44px 0 14px; }
html[dir="rtl"] .auth-input-wrap > .material-symbols-rounded.prefix { left: auto; right: 14px; }
html[dir="rtl"] .auth-input-wrap.with-toggle .auth-input { padding-left: 44px; padding-right: 44px; }
html[dir="rtl"] .auth-toggle-btn { right: auto; left: 6px; }
html[dir="rtl"] .auth-otp-input { padding-right: 14px !important; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .auth-btn, .auth-input, .auth-toggle-btn { transition: none !important; }
    .auth-btn[data-loading="true"]::after { animation: none; }
}

/* ---------- Print (shouldn't happen, but keep it clean) ---------- */
@media print {
    .auth-brand, .auth-turnstile, .auth-btn { display: none; }
}
