@import url("admin-theme.css");

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    overflow-x: hidden;
}

body.admin-auth {
    display: flex;
    position: relative;
    min-height: 100vh;
    margin: 0;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(120% 90% at 14% 6%, rgba(220, 23, 61, .07) 0%, transparent 55%),
        radial-gradient(110% 100% at 88% 96%, rgba(220, 23, 61, .05) 0%, transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

/* ---------- base decorative layers ---------- */

.auth-noise {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: .05;
    mix-blend-mode: multiply;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.auth-glow {
    position: fixed;
    inset: -10%;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(38% 32% at 22% 20%, var(--accent-glow-soft) 0%, transparent 70%),
        radial-gradient(42% 38% at 80% 78%, var(--accent-glow-soft) 0%, transparent 70%);
    opacity: .8;
    filter: blur(10px);
    animation: driftGlow 16s var(--ease-out) infinite alternate;
}

@keyframes driftGlow {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(2%, -3%, 0) scale(1.06); }
}

.auth-cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    width: 480px;
    height: 480px;
    margin: -240px 0 0 -240px;
    pointer-events: none;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(220, 23, 61, .07) 0%, transparent 70%);
    opacity: 0;
    transition: opacity .6s var(--ease-out);
    transform: translate3d(var(--cx, 50vw), var(--cy, 50vh), 0);
    will-change: transform;
}

.auth-cursor-glow.is-active { opacity: 1; }

@media (prefers-reduced-motion: reduce), (hover: none) {
    .auth-cursor-glow { display: none; }
    .auth-glow { animation: none; }
}

/* ---------- intro sequence ---------- */

.auth-intro {
    position: fixed;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: var(--bg);
    opacity: 1;
    transition: opacity .7s var(--ease-out), visibility .7s;
}

.auth-intro.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ignition-mark {
    width: 96px;
    height: 96px;
    overflow: visible;
}

.ignition-mark .ring {
    fill: none;
    stroke-width: 1.6;
    transform-origin: 60px 60px;
}

.ignition-mark .ring-outer {
    stroke: var(--border-strong);
    stroke-dasharray: 315;
    stroke-dashoffset: 315;
    animation: drawRing 1.1s var(--ease-out) forwards .1s;
}

.ignition-mark .ring-inner {
    stroke: var(--accent);
    stroke-dasharray: 220;
    stroke-dashoffset: 220;
    opacity: .9;
    animation: drawRing 1s var(--ease-out) forwards .35s,
               spinSlow 6s linear infinite .8s;
}

.ignition-mark .spark {
    fill: var(--accent);
    opacity: 0;
    transform: scale(.2);
    transform-origin: 60px 60px;
    animation: sparkPop .6s var(--ease-spring) forwards .95s;
}

@keyframes drawRing {
    to { stroke-dashoffset: 0; }
}

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

@keyframes sparkPop {
    0%   { opacity: 0; transform: scale(.2); }
    60%  { opacity: 1; transform: scale(1.25); }
    100% { opacity: 1; transform: scale(1); }
}

.intro-word {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .32em;
    text-align: center;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(6px);
    animation: introWordIn .6s var(--ease-out) forwards 1.15s;
}

.intro-word span {
    display: block;
    margin-top: 4px;
    color: var(--accent);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .08em;
}

@keyframes introWordIn {
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .ignition-mark .ring,
    .ignition-mark .spark,
    .intro-word { animation: none !important; opacity: 1 !important; stroke-dashoffset: 0 !important; transform: none !important; }
}

/* ---------- stage + card ---------- */

.auth-stage {
    position: relative;
    z-index: 2;
    display: flex;
    width: 100%;
    max-width: 1100px;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 40px 34px 34px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-panel);
    background-clip: padding-box;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .8) inset,
        0 30px 60px -24px rgba(22, 22, 22, .16),
        0 1px 2px rgba(22, 22, 22, .04),
        0 24px 48px -18px var(--accent-glow);
    opacity: 0;
    transform: translateY(28px) scale(.97);
}

.auth-card.is-visible {
    animation: cardRise .8s var(--ease-spring) forwards;
}

.auth-card.is-instant {
    opacity: 1;
    transform: none;
}

@keyframes cardRise {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-card.is-shaking {
    animation: cardShake .5s var(--ease-out);
}

@keyframes cardShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-9px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

.auth-card-mark {
    display: flex;
    width: 46px;
    height: 46px;
    margin: 0 0 20px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(220, 23, 61, .18);
    border-radius: 13px;
    background: linear-gradient(160deg, rgba(220, 23, 61, .12), rgba(220, 23, 61, .03));
    color: var(--accent);
}

.auth-card-mark svg { width: 22px; height: 22px; }

.auth-card h1 {
    margin: 0 0 6px;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 25px;
    font-weight: 600;
    letter-spacing: -.02em;
}

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

.auth-error {
    margin: 0 0 18px;
    padding: 11px 14px;
    border: 1px solid var(--danger-border);
    border-radius: 10px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: 13px;
    line-height: 1.5;
    font-weight: 600;
}

.field {
    display: block;
    margin-bottom: 18px;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.field input {
    display: block;
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    background: #fbfbfc;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color .25s var(--ease-out), background-color .25s var(--ease-out);
}

.field input::placeholder { color: #a7abb4; }

.field input:hover { border-color: #c4c7ce; }

.field input:focus {
    border-color: var(--accent);
    background: #ffffff;
}

.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field-password { position: relative; display: block; }
.field-password input { padding-right: 44px; }

.toggle-password {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    place-items: center;
    transform: translateY(-50%);
    border-radius: 8px;
    transition: color .2s var(--ease-out), background-color .2s var(--ease-out);
}

.toggle-password:hover { color: var(--text); background: rgba(22, 22, 22, .05); }
.toggle-password:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-password svg { width: 18px; height: 18px; }
.toggle-password .icon-off { display: none; }
.toggle-password.is-visible .icon-on { display: none; }
.toggle-password.is-visible .icon-off { display: block; }

.auth-submit {
    position: relative;
    display: flex;
    width: 100%;
    height: 50px;
    margin-top: 8px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(160deg, var(--accent), var(--accent-deep));
    box-shadow:
        0 1px 0 rgba(255, 255, 255, .25) inset,
        0 14px 30px -10px var(--accent-glow);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    transition: transform .25s var(--ease-spring), box-shadow .25s var(--ease-out), filter .2s var(--ease-out);
}

.auth-submit:hover { transform: translateY(-1px); filter: brightness(1.06); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 3px; }

.auth-submit:disabled { cursor: default; filter: grayscale(.15) brightness(.95); }

.auth-submit-link { text-decoration: none; }

.submit-spinner {
    display: none;
    width: 16px;
    height: 16px;
    margin-left: 10px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #ffffff;
    border-radius: 50%;
}

.auth-submit.is-loading .submit-label { opacity: .85; }
.auth-submit.is-loading .submit-spinner {
    display: block;
    animation: spin .7s linear infinite;
}

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

.auth-foot {
    margin: 22px 0 0;
    color: #9aa0ab;
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .auth-card, .auth-card.is-visible, .auth-card.is-shaking, .auth-submit, .auth-submit:hover {
        animation: none !important;
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}

@media (max-width: 480px) {
    .auth-stage { padding: 20px 16px; }
    .auth-card { padding: 32px 22px 26px; border-radius: 16px; }
}
