/* ============================================================
   Pelvin AI — Auth pages
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #161a22;
    --border: #1f232d;
    --border-soft: #232735;
    --text: #e6e8ee;
    --text-muted: #a8adba;
    --text-dim: #6f7684;
    --accent: #7c5cff;
    --accent-2: #22d3ee;
    --danger: #ff5c72;
    --success: #42d392;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
        radial-gradient(900px 500px at 100% 100%, rgba(34, 211, 238, 0.12), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

.auth-shell {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* ---------- Logo ---------- */

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    margin-bottom: 4px;
}
.auth-logo img {
    display: block;
    border-radius: 12px;
}
.auth-logo-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0d12;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
}
.auth-logo-text {
    font-weight: 800;
    font-size: 1.15rem;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Card ---------- */

.auth-card {
    width: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 40%), var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px 28px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.03) inset,
        0 20px 60px rgba(0, 0, 0, 0.35);
}

.auth-title {
    font-size: 1.55rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}
.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin: 0 0 24px;
}

/* ---------- Form ---------- */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 0;
}

.form-field { display: block; }

.field-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.01em;
}

.field-hint {
    display: block;
    font-size: 0.76rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color .15s, box-shadow .15s;
}
.input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-dim);
    pointer-events: none;
    transition: color .15s;
}
.input-wrap:focus-within .input-icon { color: var(--accent); }

.input-wrap input {
    flex: 1;
    width: 100%;
    padding: 13px 14px 13px 42px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    border-radius: 12px;
}
.input-wrap input::placeholder { color: var(--text-dim); }

/* Chromium autofill fix */
.input-wrap input:-webkit-autofill,
.input-wrap input:-webkit-autofill:hover,
.input-wrap input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* ---------- Password toggle ---------- */

.toggle-password {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 8px 12px;
    margin-right: 4px;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 8px;
    transition: color .15s, background .15s;
}
.toggle-password:hover {
    color: var(--text);
    background: var(--surface-2);
}
.toggle-password .eye-closed { display: none; }
.toggle-password.is-visible .eye-open { display: none; }
.toggle-password.is-visible .eye-closed { display: inline-block; }

/* ---------- Extra row ---------- */

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: -4px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.checkbox input {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    background: var(--bg);
    position: relative;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.checkbox input:checked {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}
.checkbox input:checked::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230b0d12' stroke-width='2.5'><polyline points='3.5 8.5 6.5 11.5 12.5 5'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
}

.link-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color .15s;
}
.link-muted:hover { color: var(--accent); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform .1s, opacity .15s, box-shadow .15s;
    font-family: inherit;
}
.btn:active { transform: scale(0.985); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0d12;
    box-shadow: 0 10px 30px rgba(124, 92, 255, 0.25);
}
.btn-primary:hover { opacity: 0.94; }

.btn-block { width: 100%; }

/* ---------- Alt links / terms ---------- */

.auth-alt {
    margin: 20px 0 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.auth-alt a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.auth-alt a:hover { text-decoration: underline; }

.auth-terms {
    margin: 4px 0 0;
    font-size: 0.76rem;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.5;
}
.auth-terms a { color: var(--text-muted); text-decoration: underline; }

.auth-footer {
    margin: 4px 0 0;
    color: var(--text-dim);
    font-size: 0.78rem;
    text-align: center;
}

/* ---------- Alerts ---------- */

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 0.88rem;
    line-height: 1.5;
}
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert li + li { margin-top: 3px; }
.alert-success {
    background: rgba(66, 211, 146, 0.08);
    border: 1px solid rgba(66, 211, 146, 0.3);
    color: #7ef0a5;
}
.alert-error {
    background: rgba(255, 92, 114, 0.08);
    border: 1px solid rgba(255, 92, 114, 0.3);
    color: #ff9aa6;
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
    body.auth-body { padding: 20px 14px; align-items: flex-start; }
    .auth-shell { max-width: 100%; }
    .auth-card { padding: 26px 20px; border-radius: 16px; }
    .auth-title { font-size: 1.35rem; }
    .auth-logo img { width: 40px; height: 40px; }
    .auth-logo-text { font-size: 1.05rem; }
    .input-wrap input { font-size: 0.94rem; }
}

/* ---------- Logo ---------- */

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    margin-bottom: 4px;
    transition: transform .15s;
}
.auth-logo:hover { transform: translateY(-1px); }

.auth-logo-mark {
    position: relative;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.14));
    box-shadow:
        0 6px 20px rgba(124, 92, 255, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    flex-shrink: 0;
}
.auth-logo-mark img {
    display: block;
    border-radius: 10px;
}

.auth-logo-text {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.01em;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Compact logo for narrow phones */
@media (max-width: 380px) {
    .auth-logo-mark { width: 42px; height: 42px; border-radius: 12px; }
    .auth-logo-mark img { width: 42px; height: 42px; }
    .auth-logo-text { font-size: 1.05rem; }
}

/* ============================================================
   Pelvin AI — Global Loader
   ============================================================ */

.pelvin-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(11, 13, 18, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}
.pelvin-loader.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.pelvin-loader-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 32px 40px;
    background: var(--surface, #12151c);
    border: 1px solid var(--border, #1f232d);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transform: scale(0.96);
    transition: transform .25s cubic-bezier(0.4, 0, 0.2, 1);
}
.pelvin-loader.is-active .pelvin-loader-box {
    transform: scale(1);
}

/* ---------- Spinner ---------- */

.pelvin-loader-spinner {
    display: flex;
    gap: 8px;
    align-items: center;
    height: 24px;
}
.pelvin-loader-spinner span {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c5cff, #22d3ee);
    animation: pelvin-bounce 1.2s infinite ease-in-out both;
}
.pelvin-loader-spinner span:nth-child(1) { animation-delay: -0.24s; }
.pelvin-loader-spinner span:nth-child(2) { animation-delay: -0.12s; }
.pelvin-loader-spinner span:nth-child(3) { animation-delay: 0s; }

@keyframes pelvin-bounce {
    0%, 80%, 100% {
        transform: scale(0.5);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---------- Text ---------- */

.pelvin-loader-text {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text, #e6e8ee);
    letter-spacing: 0.01em;
}
.pelvin-loader-text .dots span {
    display: inline-block;
    animation: pelvin-dot 1.2s infinite;
}
.pelvin-loader-text .dots span:nth-child(2) { animation-delay: 0.2s; }
.pelvin-loader-text .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pelvin-dot {
    0%, 60%, 100% { opacity: 0.2; }
    30%           { opacity: 1; }
}

/* ============================================================
   ADMIN LOGIN
   ============================================================ */

/* Guest mode — same layout as regular auth, but with a distinct accent */

.admin-body.is-guest {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 20px;
    background:
        radial-gradient(1000px 500px at 50% -10%, rgba(255, 92, 114, 0.12), transparent 60%),
        radial-gradient(900px 500px at 100% 100%, rgba(124, 92, 255, 0.14), transparent 60%),
        var(--bg, #0b0d12);
    background-attachment: fixed;
}

.admin-body.is-guest .auth-shell {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

/* Admin badge above the logo */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(255, 92, 114, 0.1);
    border: 1px solid rgba(255, 92, 114, 0.3);
    border-radius: 999px;
    color: #ff9aa6;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.admin-badge svg { flex-shrink: 0; }

/* Admin card — subtle red-tinted border to differentiate from user login */
.admin-auth-card {
    border-color: rgba(255, 92, 114, 0.2);
}
.admin-auth-card:focus-within {
    border-color: rgba(255, 92, 114, 0.35);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.03) inset,
        0 20px 60px rgba(0, 0, 0, 0.35),
        0 0 0 3px rgba(255, 92, 114, 0.08);
}

/* Admin submit button — override gradient to a red→purple mix for a "secure" feel */
.admin-auth-card .btn-primary {
    background: linear-gradient(135deg, #ff5c72, #7c5cff);
    box-shadow: 0 10px 30px rgba(255, 92, 114, 0.22);
}

/* Security note at the bottom */
.admin-security-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 18px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border, #1f232d);
    border-radius: 10px;
    font-size: 0.76rem;
    line-height: 1.5;
    color: var(--text-dim, #6f7684);
}
.admin-security-note svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--text-dim, #6f7684);
}

/* The logo mark inside the admin context uses the same styling as user auth */

/* Mobile */
@media (max-width: 480px) {
    .admin-body.is-guest { padding: 20px 14px; align-items: flex-start; }
    .admin-body.is-guest .auth-shell { max-width: 100%; }
    .admin-security-note { font-size: 0.72rem; }
}