/* ================================================================
   PORTAL  —  Auth shell styles
   ================================================================ */

/* ── Reset / base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Portal chrome ────────────────────────────────────────────── */
.portal-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100dvh;
}

.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    height: var(--nav-height);
    width: min(calc(100% - 48px), var(--max-width));
    margin: 0 auto;
}

.portal-header__logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-primary);
    text-decoration: none;
}

.portal-header__logo:hover { text-decoration: none; }

.portal-header__logo img {
    width: 32px;
    height: 32px;
}

.portal-header__logo-text {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.portal-header__logo-text em {
    font-style: normal;
    color: var(--accent);
}

.portal-header__back {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    transition: color 0.12s;
}

.portal-header__back:hover { color: var(--text-primary); text-decoration: none; }

/* thin accent line under header */
.portal-header-wrap {
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 0 var(--accent-line);
}

/* ── Auth stage ───────────────────────────────────────────────── */
.portal-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-7) var(--space-4);
}

/* Split layout: sidebar + auth card */
.portal-stage--split {
    align-items: flex-start;
    gap: var(--space-8);
    max-width: calc(var(--max-width, 1200px) - 48px);
    margin: 0 auto;
    width: 100%;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.portal-sidebar {
    flex: 0 0 340px;
    min-width: 0;
    position: sticky;
    top: var(--space-7);
}

.portal-sidebar__inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.portal-sidebar__title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.portal-sidebar__title i {
    color: var(--accent);
    font-size: 1.1em;
}

.portal-sidebar__intro {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.portal-services {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.portal-service {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.portal-service__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--accent-glow);
    border: 1px solid var(--accent-line);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 1.1rem;
}

.portal-service__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

.portal-service__name {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.portal-service__badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 20px;
}

.portal-service__badge--soon {
    background: rgba(212, 145, 74, 0.15);
    color: var(--status-wip);
    border: 1px solid rgba(212, 145, 74, 0.3);
}

.portal-service__desc {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.portal-sidebar__note {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    line-height: 1.6;
}

.portal-sidebar__note i {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--accent-dim, var(--accent));
    opacity: 0.6;
}

/* Auth card wrapper (right column) */
.auth-card-wrap {
    flex: 1 1 420px;
    min-width: 0;
    max-width: 460px;
}

/* ── Auth card ────────────────────────────────────────────────── */
.auth-card {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.auth-card--wide {
    max-width: 540px;
}

.auth-card__head {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.auth-card__eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.auth-card__title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    margin: 0;
}

.auth-card__subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
}

/* ── Auth form ────────────────────────────────────────────────── */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.auth-field__label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.auth-field__hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 400;
}

.auth-field__hint a {
    color: var(--accent);
}

.auth-input {
    width: 100%;
    padding: 0.65rem var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: 1.5;
    transition: border-color 0.12s, box-shadow 0.12s;
    outline: none;
    -webkit-appearance: none;
}

.auth-input::placeholder { color: var(--text-muted); }

.auth-input:hover {
    border-color: var(--border-strong);
}

.auth-input:focus {
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-input.is-error {
    border-color: #c0392b;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15);
}

.auth-field__error {
    font-size: var(--text-xs);
    color: #e57373;
    display: none;
}

.auth-field__error.is-visible { display: block; }

/* Password wrapper with show/hide toggle */
.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-wrap .auth-input {
    padding-right: 2.75rem;
}

.auth-input-wrap__toggle {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color 0.12s;
}

.auth-input-wrap__toggle:hover { color: var(--text-secondary); }

/* ── Password strength bar ────────────────────────────────────── */
.auth-strength {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-top: calc(var(--space-1) * -1);
}

.auth-strength__bar {
    display: flex;
    gap: 3px;
    height: 3px;
}

.auth-strength__seg {
    flex: 1;
    border-radius: 2px;
    background: var(--border);
    transition: background 0.2s;
}

.auth-strength__seg.is-weak   { background: #e57373; }
.auth-strength__seg.is-fair   { background: var(--status-wip); }
.auth-strength__seg.is-good   { background: #81c784; }
.auth-strength__seg.is-strong { background: var(--status-released); }

.auth-strength__label {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ── Divider ──────────────────────────────────────────────────── */
.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-muted);
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Submit button ────────────────────────────────────────────── */
.auth-submit {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.12s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.auth-submit:hover {
    background: #7ecde6;
    transform: translateY(-1px);
}

.auth-submit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Footer link line ─────────────────────────────────────────── */
.auth-card__footer {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ── Tab switcher (login / register) ─────────────────────────── */
.auth-tabs {
    display: flex;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    gap: 3px;
}

.auth-tab {
    flex: 1;
    padding: 0.5rem;
    background: none;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

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

.auth-tab.is-active {
    background: var(--bg-raised);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ── Alert banner ─────────────────────────────────────────────── */
.auth-alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    display: none;
    align-items: flex-start;
    gap: var(--space-2);
}

.auth-alert.is-visible { display: flex; }

.auth-alert--error {
    background: rgba(192, 57, 43, 0.12);
    border: 1px solid rgba(192, 57, 43, 0.35);
    color: #e57373;
}

.auth-alert--success {
    background: rgba(91, 186, 111, 0.1);
    border: 1px solid rgba(91, 186, 111, 0.3);
    color: #81c784;
}

.auth-alert--info {
    background: var(--accent-glow);
    border: 1px solid var(--accent-line);
    color: var(--accent);
}

/* ── Portal footer ────────────────────────────────────────────── */
.portal-footer {
    padding: var(--space-5) 0;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.portal-footer a {
    color: var(--text-muted);
    transition: color 0.12s;
}

.portal-footer a:hover { color: var(--text-secondary); text-decoration: none; }

.portal-footer__links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

/* ── Panel transitions ────────────────────────────────────────── */
.auth-panel {
    display: none;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-panel.is-active { display: flex; }

/* ── Checkbox row ─────────────────────────────────────────────── */
.auth-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.auth-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 3px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Auth steps (sub-panels within login/register) ────────────── */
.auth-step {
    display: none;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-step.is-active { display: flex; }

/* ── TOTP code input ──────────────────────────────────────────── */
.totp-code-input {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    letter-spacing: 0.25em;
    text-align: center;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* ── TOTP setup page ──────────────────────────────────────────── */
.totp-setup-step {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.totp-steps {
    margin: 0;
    padding-left: 1.25em;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.8;
}

.totp-qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.totp-qr-box {
    padding: var(--space-3);
    background: #dde3e7;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 200px;
}

.totp-qr-loading {
    color: #0d1820;
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.totp-spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

.totp-secret-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: 100%;
    max-width: 340px;
}

.totp-secret-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
}

.totp-secret {
    flex: 1;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    letter-spacing: 0.08em;
    color: var(--accent);
    word-break: break-all;
}

.totp-copy-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    font-size: 1rem;
    transition: color 0.12s;
}

.totp-copy-btn:hover { color: var(--accent); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    .portal-stage--split {
        flex-direction: column;
        align-items: stretch;
    }
    .portal-sidebar {
        flex: none;
        position: static;
    }
    .auth-card-wrap {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .portal-stage { padding: var(--space-5) var(--space-4); }
    .portal-stage--split { gap: var(--space-5); }
    .auth-card__title { font-size: var(--text-xl); }
    .totp-qr-wrap { align-items: flex-start; }
}
