/* Login page only (index.html). login.css stays the shared base for dashboard.html,
   so everything here is scoped under body.auth. */

body.auth {
    --bg: #0b1020;
    --glass: rgba(20, 27, 46, .72);
    --glass-line: rgba(140, 160, 210, .16);
    --field: rgba(8, 12, 26, .72);
    --grad: linear-gradient(135deg, #4f8cff 0%, #7c5cff 50%, #2ecc71 100%);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.auth .ic {
    width: 18px; height: 18px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Background ---------- */
.auth-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55;
    animation: drift 22s ease-in-out infinite alternate;
}
.blob--a { width: 520px; height: 520px; background: #3b6dff; top: -160px; left: -120px; }
.blob--b { width: 460px; height: 460px; background: #7c3aed; bottom: -180px; right: 8%; animation-delay: -7s; opacity: .4; }
.blob--c { width: 380px; height: 380px; background: #10b981; top: 40%; left: 38%; animation-delay: -13s; opacity: .22; }
.auth-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 50% 40%, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 30%, transparent 75%);
}
@keyframes drift {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(60px, 40px) scale(1.08); }
    100% { transform: translate(-40px, 70px) scale(.95); }
}

/* ---------- Layout ---------- */
.auth-shell {
    position: relative; z-index: 1;
    min-height: 100vh; max-width: 1180px; margin: 0 auto;
    padding: 40px 32px;
    display: grid; grid-template-columns: 1.1fr minmax(360px, 440px);
    gap: 56px; align-items: center;
}

/* ---------- Hero ---------- */
.auth-hero { max-width: 560px; animation: rise .6s ease both; }
.auth-hero .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.auth-hero .brand__logo { width: 44px; height: 44px; filter: drop-shadow(0 6px 18px rgba(79,140,255,.45)); }
.auth-hero .brand__txt { display: flex; flex-direction: column; }
.auth-hero .brand__txt strong { font-size: 16px; letter-spacing: .2px; }
.auth-hero .brand__txt span { font-size: 12px; color: var(--text-dim); }

.hero-title {
    margin: 0 0 16px; font-size: clamp(30px, 3.6vw, 44px); line-height: 1.12;
    font-weight: 800; letter-spacing: -.8px;
}
.hero-title .grad {
    background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lead { margin: 0 0 28px; color: var(--text-dim); font-size: 15px; line-height: 1.65; max-width: 500px; }

.hero-chat {
    background: var(--glass); border: 1px solid var(--glass-line); border-radius: 16px;
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
    margin-bottom: 26px; overflow: hidden; max-width: 480px;
}
.hc-head {
    display: flex; align-items: center; gap: 6px; padding: 10px 14px;
    border-bottom: 1px solid var(--glass-line); background: rgba(255,255,255,.02);
}
.hc-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.14); }
.hc-title { margin-left: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.hc-title .ic { width: 14px; height: 14px; color: #a78bfa; }
.hc-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hc-msg { font-size: 12.5px; line-height: 1.5; padding: 9px 12px; border-radius: 12px; }
.hc-msg--user {
    align-self: flex-end; background: rgba(79,140,255,.18); border: 1px solid rgba(79,140,255,.35);
    border-bottom-right-radius: 4px; animation: pop .4s .3s ease both;
}
.hc-msg--bot {
    background: rgba(255,255,255,.03); border: 1px solid var(--glass-line);
    border-bottom-left-radius: 4px; animation: pop .4s .9s ease both;
}
.hc-line b { color: var(--text); }
.hc-bars { display: grid; gap: 6px; margin: 10px 0 8px; }
.hc-bar { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 10px; font-size: 11px; color: var(--text-dim); }
.hc-bar i {
    display: block; height: 7px; border-radius: 99px; background: var(--grad);
    width: var(--w); transform-origin: left; animation: grow .9s 1.3s cubic-bezier(.2,.8,.2,1) both;
}
.hc-src { font-size: 10.5px; color: var(--text-dim); }
.hc-caret {
    display: inline-block; width: 6px; height: 11px; margin-left: 4px; vertical-align: -1px;
    background: var(--accent); animation: blink 1s steps(1) infinite;
}

.hero-feat { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 520px; }
.hero-feat li {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px; border-radius: 12px;
    background: rgba(255,255,255,.025); border: 1px solid var(--glass-line);
    transition: border-color .2s, transform .2s;
}
.hero-feat li:hover { border-color: rgba(79,140,255,.4); transform: translateY(-2px); }
.hf-ic {
    width: 32px; height: 32px; border-radius: 9px; flex: none;
    display: grid; place-items: center;
    background: rgba(79,140,255,.12); color: #8fb4ff;
}
.hero-feat b { display: block; font-size: 13px; margin-bottom: 2px; }
.hero-feat span:not(.hf-ic) { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }

/* ---------- Card ---------- */
.auth-card {
    position: relative;
    background: var(--glass); border: 1px solid var(--glass-line); border-radius: 20px;
    backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 30px 80px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.05);
    padding: 30px 28px 20px;
    animation: rise .6s .1s ease both;
}
.auth-card::before {
    /* gradient hairline on top edge */
    content: ''; position: absolute; left: 24px; right: 24px; top: -1px; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124,92,255,.8), rgba(79,140,255,.8), transparent);
}
.auth-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 24px; }
.auth-card__brand { display: flex; align-items: center; gap: 12px; }
.auth-card__logo { width: 40px; height: 40px; display: none; }
.auth-card h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.auth-card__head p { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }
.auth .badge { font-weight: 600; white-space: nowrap; }
/* "unknown"/"checking…" before any session says nothing useful on the login form. */
.auth #env-badge.badge--muted { display: none; }

.auth .login-form { gap: 16px; }
.auth .field__label { font-size: 12px; font-weight: 500; color: #a5aec6; margin-bottom: 7px; }

/* Inputs with leading icon */
.inp { position: relative; display: block; }
.inp__ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; transition: color .15s; }
.auth .field .inp input {
    background: var(--field); border: 1px solid var(--glass-line); border-radius: 11px;
    padding: 12px 14px 12px 42px; font-size: 14px; height: 46px;
}
.auth .field .inp input::placeholder { color: #5d6684; }
.auth .field .inp input:hover { border-color: rgba(140,160,210,.3); }
.auth .field .inp input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(79,140,255,.16); }
.inp:focus-within .inp__ic { color: var(--accent); }
.auth .field__pw input { padding-right: 46px; }
.auth .pw-toggle {
    right: 6px; width: 34px; height: 34px; padding: 0; border-radius: 8px;
    display: grid; place-items: center; color: var(--text-dim);
}
.auth .pw-toggle:hover { color: var(--text); background: rgba(255,255,255,.05); }
.auth .pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.caps-hint { display: inline-flex; align-items: center; gap: 6px; margin-top: 7px; font-size: 11.5px; color: var(--warn); }
.caps-hint[hidden] { display: none; }
.caps-hint .ic { width: 14px; height: 14px; }

/* Environment segmented control with sliding pill */
.auth .env-toggle {
    position: relative; gap: 0; padding: 4px; border-radius: 12px;
    background: var(--field); border: 1px solid var(--glass-line);
}
.env-toggle__pill {
    position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
    border-radius: 9px; background: linear-gradient(135deg, #f59e0b, #f5a524);
    box-shadow: 0 6px 18px rgba(245,165,36,.3);
    transition: transform .3s cubic-bezier(.3,.9,.3,1), background .3s, box-shadow .3s;
}
.auth .env-toggle:has(input[value=production]:checked) .env-toggle__pill {
    transform: translateX(100%);
    background: linear-gradient(135deg, #ff5c6c, #e64980);
    box-shadow: 0 6px 18px rgba(255,92,108,.3);
}
.auth .env-toggle label,
.auth .env-toggle label:has(input:checked) {
    position: relative; z-index: 1; background: transparent;
    font-size: 12.5px; font-weight: 600; padding: 9px 4px;
}
.auth .env-toggle label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.auth .env-hint { margin-top: 8px; font-size: 11.5px; }

/* Collapsible server config */
.auth-adv {
    border: 1px solid var(--glass-line); border-radius: 12px;
    background: rgba(255,255,255,.015);
}
.auth-adv summary {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 8px;
    padding: 11px 12px; font-size: 12.5px; color: #a5aec6; font-weight: 500;
}
.auth-adv summary::-webkit-details-marker { display: none; }
.auth-adv summary:hover { color: var(--text); }
.auth-adv summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px; }
.auth-adv__chev { width: 15px; height: 15px; transition: transform .2s; }
.auth-adv[open] .auth-adv__chev { transform: rotate(90deg); }
.auth-adv__preview {
    margin-left: auto; font-size: 11px; color: var(--text-dim);
    max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: rgba(255,255,255,.04); padding: 3px 8px; border-radius: 6px;
}
.auth .env-custom { border: 0; border-top: 1px solid var(--glass-line); border-radius: 0; padding: 14px 12px 12px; gap: 12px; }
.auth .env-cfg-row .btn--ghost { border-radius: 9px; }

/* Remember switch */
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: #a5aec6; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
    width: 36px; height: 20px; border-radius: 99px; flex: none; position: relative;
    background: rgba(255,255,255,.1); border: 1px solid var(--glass-line); transition: background .2s;
}
.switch__thumb {
    position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); transition: transform .2s;
}
.switch input:checked + .switch__track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Primary button */
.auth #btn-login {
    height: 48px; border-radius: 12px; font-size: 15px; margin-top: 4px;
    background: linear-gradient(135deg, #4f8cff, #6d5cff);
    box-shadow: 0 10px 28px rgba(79,140,255,.35);
    transition: box-shadow .2s, transform .1s, filter .2s;
}
.auth #btn-login:hover:not([disabled]) { filter: brightness(1.08); box-shadow: 0 14px 34px rgba(79,140,255,.45); }
.auth #btn-login:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn__arrow { transition: transform .2s; }
.auth #btn-login:hover .btn__arrow { transform: translateX(3px); }
.auth #btn-login.is-loading .btn__arrow { display: none; }

.auth .msg { text-align: center; }
.auth .msg:empty { min-height: 0; }

.auth-card__foot {
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--glass-line);
    display: flex; justify-content: space-between; gap: 10px;
    font-size: 11px; color: var(--text-dim);
}
.auth-card__foot code { color: #a5aec6; background: rgba(255,255,255,.04); padding: 1px 6px; border-radius: 5px; }

/* ---------- Motion ---------- */
@keyframes rise  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop   { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes grow  { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .auth *, .auth *::before { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .auth-shell { grid-template-columns: 1fr; max-width: 480px; padding: 28px 16px; gap: 0; }
    .auth-hero { display: none; }
    .auth-card__logo { display: block; }
}
@media (max-width: 420px) {
    .auth-card { padding: 24px 18px 16px; border-radius: 16px; }
    .auth-card__head { flex-direction: column-reverse; gap: 14px; }
    .auth-adv__preview { display: none; }
}
