@import url('theme.css');

* { box-sizing: border-box; margin: 0; padding: 0; }

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--scrollbar-track);
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    border-color: var(--scrollbar-track);
}

*::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.25s ease, color 0.2s ease;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.auth-page {
    display: grid;
    grid-template-columns: minmax(320px, 480px) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---------- Aside (branding) ---------- */
.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 2.5rem;
    overflow: hidden;
    background: linear-gradient(155deg, var(--primary) 0%, #1e3a8a 55%, #172554 100%);
    color: #fff;
}

[data-theme="dark"] .auth-aside {
    background: linear-gradient(155deg, #1e3a8a 0%, #0f172a 50%, #060a12 100%);
}

.auth-aside::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 40%);
    pointer-events: none;
}

.auth-aside-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: inherit;
}

.auth-logo span { color: rgba(255, 255, 255, 0.85); }

.auth-logo-img {
    display: block;
    height: 44px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.auth-logo-img--aside {
    height: 48px;
    max-width: 220px;
    padding: 0.45rem 0.7rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.auth-aside-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem 0;
}

.auth-badge {
    display: inline-block;
    align-self: flex-start;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-bottom: 1.25rem;
}

.auth-aside-body h2 {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 0.85rem;
}

.auth-aside-body > p {
    font-size: 1rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.82);
    max-width: 36ch;
    margin-bottom: 2rem;
}

.auth-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-features li {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.auth-feature-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 1.15rem;
}

.auth-features strong { font-weight: 700; }

.auth-aside-foot {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
}

/* ---------- Main panel ---------- */
.auth-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
}

[data-theme="light"] .auth-main {
    background: linear-gradient(180deg, #eef2f7 0%, var(--bg) 40%);
}

[data-theme="dark"] .auth-main {
    background: linear-gradient(180deg, #0c1018 0%, var(--bg) 40%);
}

.auth-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    padding-top: max(1.25rem, env(safe-area-inset-top));
}

.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--muted);
    transition: color 0.15s ease;
}

.auth-back:hover { color: var(--primary); }

.auth-theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 1.05rem;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.auth-theme-toggle:hover {
    background: var(--hover);
    border-color: var(--primary-border);
}

[data-theme="light"] .auth-theme-toggle .icon-moon,
[data-theme="dark"] .auth-theme-toggle .icon-sun { display: none; }

.auth-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem 2.5rem;
    padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
}

/* ---------- Card ---------- */
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.25rem;
    box-shadow: var(--shadow-lg);
}

.auth-logo-mobile {
    display: none;
    margin-bottom: 1.25rem;
    color: var(--text);
}

.auth-logo-mobile .auth-logo-img {
    height: 42px;
}

.auth-logo-mobile span { color: var(--primary); }

.auth-brand h1 {
    font-size: 1.65rem;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.auth-brand p {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* ---------- Tabs ---------- */
.auth-tabs {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
    background: var(--bg-subtle);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.auth-tabs .tab {
    flex: 1;
    padding: 0.65rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.auth-tabs .tab:hover:not(.active) {
    color: var(--text);
    background: var(--hover);
}

.auth-tabs .tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ---------- Forms ---------- */
.auth-form {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.auth-form.active { display: flex; }

.auth-form-header {
    margin-bottom: 0.25rem;
}

.auth-form-header h2 {
    font-size: 1.25rem;
    letter-spacing: -0.01em;
    margin-bottom: 0.35rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.auth-form label {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.auth-form input {
    padding: 0.8rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 16px;
    width: 100%;
    min-height: 48px;
    touch-action: manipulation;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-form input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.auth-form input.input-code {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.35em;
    font-family: 'Consolas', 'Courier New', monospace;
    padding-left: 1.35em;
}

.btn {
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.05s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    margin-top: 0.25rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #ffffff;
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    padding: 0.5rem;
    transition: opacity 0.15s ease;
}

.btn-link:hover { opacity: 0.8; }

.form-hint {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

/* ---------- Alert ---------- */
.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.92rem;
    margin-bottom: 0.25rem;
    line-height: 1.45;
}

.alert.hidden { display: none; }

.alert.error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.alert.success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid var(--success-border);
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-aside { display: none; }

    .auth-logo-mobile { display: inline-block; }

    .auth-topbar {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .auth-panel {
        padding: 0.5rem 1.25rem 2rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 1.75rem 1.35rem;
        border-radius: 14px;
        border-left: none;
        border-right: none;
        box-shadow: none;
        background: transparent;
        border-top: none;
        border-bottom: none;
    }

    .auth-main {
        background: var(--bg);
    }

    [data-theme="light"] .auth-main,
    [data-theme="dark"] .auth-main {
        background: var(--bg);
    }

    .auth-brand h1 { font-size: 1.45rem; }

    .auth-tabs .tab {
        padding: 0.75rem 0.5rem;
        min-height: 44px;
    }

    .btn-primary {
        min-height: 48px;
        width: 100%;
    }

    .btn-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 380px) {
    .auth-card { padding: 1.5rem 1rem; }
}
