/* =============================================================================
   Auth pages (login / register / change password / delete account)
   Full-screen, split-screen, app-like dark theme. Isolated from the main app.
   ============================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
}

body.auth-body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: #e2e8f0;
    background: #0b1020;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ── Full-screen split shell ── */
.auth-shell {
    position: relative;
    min-height: 100dvh;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
}

/* ── Left showcase panel (desktop only) ── */
.auth-showcase {
    display: none;
    position: relative;
    overflow: hidden;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    padding: clamp(2.5rem, 4vw, 4.5rem);
    color: #f8fafc;
    background:
        radial-gradient(1200px 620px at 15% -12%, rgba(59, 130, 246, 0.35), transparent 60%),
        radial-gradient(900px 520px at 110% 118%, rgba(99, 102, 241, 0.32), transparent 55%),
        linear-gradient(160deg, #0f172a 0%, #0b1020 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.12);
}

/* Decorative floating orbs */
.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(6px);
    opacity: 0.55;
    pointer-events: none;
    animation: auth-float 14s ease-in-out infinite;
}

.auth-orb-1 {
    width: 320px;
    height: 320px;
    top: -80px;
    right: -60px;
    background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.55), transparent 70%);
}

.auth-orb-2 {
    width: 260px;
    height: 260px;
    bottom: -70px;
    left: -50px;
    background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.5), transparent 70%);
    animation-delay: -4s;
}

.auth-orb-3 {
    width: 180px;
    height: 180px;
    top: 45%;
    right: 20%;
    background: radial-gradient(circle at 30% 30%, rgba(96, 165, 250, 0.35), transparent 70%);
    animation-delay: -8s;
}

@keyframes auth-float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(0, -22px); }
}

.auth-showcase-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.auth-showcase-body {
    position: relative;
    z-index: 1;
    max-width: 30rem;
}

.auth-showcase-title {
    margin: 0 0 1rem;
    font-size: clamp(2rem, 3vw, 2.9rem);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #f8fafc;
}

.auth-showcase-text {
    margin: 0 0 2.25rem;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #cbd5e1;
}

.auth-features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.auth-feature {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
}

.auth-feature-icon {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.auth-feature-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.auth-feature-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.auth-feature-text strong {
    font-size: 0.98rem;
    font-weight: 700;
    color: #f1f5f9;
}

.auth-feature-text span {
    font-size: 0.88rem;
    color: #94a3b8;
    line-height: 1.4;
}

.auth-showcase-foot {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #93c5fd;
}

/* ── Right form panel ── */
.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 6vw, 3rem);
    padding-top: calc(clamp(1.5rem, 6vw, 3rem) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(clamp(1.5rem, 6vw, 3rem) + env(safe-area-inset-bottom, 0px));
    background:
        radial-gradient(900px 480px at 50% -20%, rgba(59, 130, 246, 0.14), transparent 60%),
        linear-gradient(180deg, #0b1020 0%, #0f172a 100%);
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ── Brand (in-card, shown on mobile) ── */
.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

.auth-logo svg,
.auth-logo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    padding: 0.2rem;
}

.auth-brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #f8fafc;
}

/* ── Headings ── */
.auth-title {
    margin: 0 0 0.4rem;
    font-size: clamp(1.6rem, 6vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #f8fafc;
}

.auth-subtitle {
    margin: 0 0 1.75rem;
    font-size: 0.95rem;
    color: #94a3b8;
    line-height: 1.5;
}

/* ── Back link ── */
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    align-self: flex-start;
    margin-bottom: 1.5rem;
    padding: 0.4rem 0.75rem 0.4rem 0.5rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}

.auth-back:hover {
    background: rgba(148, 163, 184, 0.18);
    color: #f1f5f9;
}

/* ── Alerts ── */
.auth-alert {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}

.auth-alert svg {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
}

.auth-alert-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.auth-alert-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

/* ── Form ── */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.auth-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #cbd5e1;
    padding-left: 0.15rem;
}

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 0.9rem;
    display: inline-flex;
    align-items: center;
    color: #64748b;
    pointer-events: none;
}

.auth-input-icon svg {
    width: 1.1rem;
    height: 1.1rem;
}

.auth-input {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 2.6rem;
    font-size: 16px;
    font-family: inherit;
    color: #f1f5f9;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-input::placeholder {
    color: #64748b;
}

.auth-input:focus {
    border-color: #3b82f6;
    background: rgba(15, 23, 42, 0.85);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #f1f5f9;
    -webkit-box-shadow: 0 0 0 1000px #16213a inset;
    caret-color: #f1f5f9;
    transition: background-color 9999s ease-in-out 0s;
}

.auth-remember {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    user-select: none;
    padding: 0.15rem 0.15rem 0;
}

.auth-remember-input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.auth-remember-label {
    font-size: 0.88rem;
    color: #94a3b8;
    line-height: 1.4;
}

/* ── Buttons ── */
.auth-btn {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.95rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(59, 130, 246, 0.4);
    transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.auth-btn:hover {
    filter: brightness(1.07);
}

.auth-btn:active {
    transform: translateY(1px) scale(0.99);
}

.auth-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35);
}

.auth-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 10px 28px rgba(239, 68, 68, 0.4);
}

.auth-btn-danger:focus-visible {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.35);
}

/* ── Footer / notes ── */
.auth-foot {
    margin: 1.5rem 0 0;
    text-align: center;
    font-size: 0.9rem;
    color: #94a3b8;
}

.auth-foot-link {
    color: #93c5fd;
    font-weight: 600;
    text-decoration: none;
}

.auth-foot-link:hover {
    text-decoration: underline;
}

.auth-note {
    margin: 0 0 1.5rem;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #fda4af;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.22);
    border-radius: 12px;
}

/* ── Desktop: reveal split screen ── */
@media (min-width: 900px) {
    .auth-shell {
        grid-template-columns: 1.05fr 0.95fr;
    }

    .auth-showcase {
        display: flex;
    }

    /* Brand already lives in the showcase panel on desktop */
    .auth-main .auth-brand {
        display: none;
    }

    .auth-card {
        max-width: 420px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ── iOS Add to Home Screen / standalone ── */
html.pwa-standalone {
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
    overscroll-behavior: none;
}

html.pwa-standalone body.auth-body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
    overscroll-behavior: none;
}

html.pwa-standalone body.auth-body .auth-shell {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
