/*
 * Client portal and sign-in screens (Material Design 3, mobile first).
 * Builds on the colour roles and components in /css/app.css.
 */

/* ---- Portal shell: top app bar, navigation rail (desktop), navigation bar (mobile) ---- */
.portal-body { background: var(--md-surface); min-height: 100vh; }
.portal-bar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem; height: 64px; padding: 0 .75rem 0 1rem;
    background: var(--md-surface); transition: background .2s; }
.portal-bar.scrolled { background: var(--md-surface-container); }
.portal-bar .brand { display: flex; align-items: center; gap: .5rem; color: var(--md-on-surface); text-decoration: none; font-size: 1.125rem; font-weight: 500; min-width: 0; }
.portal-bar .brand .material-symbols-outlined { color: var(--md-primary); font-size: 28px; }
.portal-bar .brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.portal-rail { display: none; }
.portal-main { padding: .25rem 1rem 6.5rem; max-width: 1120px; margin: 0 auto; }

.portal-navbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; justify-content: space-around; height: 80px;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--md-surface-container); box-shadow: 0 -1px 0 var(--md-outline-variant); }
.portal-navbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--md-on-surface-variant); text-decoration: none;
    font-size: .75rem; font-weight: 500; letter-spacing: .03em; position: relative; }
.portal-navbar a .pill { width: 64px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; transition: background .2s; position: relative; }
.portal-navbar a .material-symbols-outlined { font-size: 24px; }
.portal-navbar a.active { color: var(--md-on-surface); }
.portal-navbar a.active .pill { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.portal-navbar a.active .material-symbols-outlined, .portal-rail a.active .material-symbols-outlined { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.md-badge-dot { position: absolute; top: 2px; right: 14px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--md-error);
    color: #fff; font-size: 11px; line-height: 16px; text-align: center; font-weight: 500; }

@media (min-width: 840px) {
    .portal-navbar { display: none; }
    .portal-rail { display: flex; flex-direction: column; align-items: center; gap: 12px; position: fixed; top: 64px; bottom: 0; left: 0; width: 88px;
        padding-top: 12px; background: var(--md-surface); z-index: 1010; }
    .portal-rail a { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 80px; color: var(--md-on-surface-variant); text-decoration: none;
        font-size: .75rem; font-weight: 500; letter-spacing: .03em; text-align: center; }
    .portal-rail a .pill { width: 56px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; position: relative; transition: background .2s; }
    .portal-rail a:hover .pill { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
    .portal-rail a.active { color: var(--md-on-surface); }
    .portal-rail a.active .pill { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
    .portal-rail a .material-symbols-outlined { font-size: 24px; }
    .portal-rail .md-badge-dot { right: 8px; }
    .portal-main { padding: .5rem 2rem 3rem 120px; max-width: 1240px; }
}

.portal-preview { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); padding: .6rem 1rem; display: flex; gap: .5rem; align-items: center; font-weight: 500; font-size: .875rem; }

/* ---- Hero / greeting ---- */
.portal-hero { border-radius: 28px; padding: 1.5rem; margin: .5rem 0 1.25rem; color: var(--md-on-primary-container);
    background: linear-gradient(135deg, var(--md-primary-container), color-mix(in srgb, var(--md-tertiary-container) 70%, var(--md-primary-container))); position: relative; overflow: hidden; }
.portal-hero h1 { font-size: 1.75rem; line-height: 2.25rem; font-weight: 400; margin: 0 0 .25rem; }
.portal-hero p { margin: 0; opacity: .9; max-width: 60ch; }
.portal-hero .hero-icon { position: absolute; right: -10px; bottom: -24px; font-size: 140px; opacity: .12; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 48; }
@media (min-width: 840px) { .portal-hero { padding: 2rem 2.25rem; } .portal-hero h1 { font-size: 2.25rem; line-height: 2.75rem; } }

.portal-section-title { font-size: 1rem; font-weight: 500; margin: 1.5rem 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.portal-section-title a { margin-left: auto; font-size: .875rem; font-weight: 500; text-decoration: none; }

/* ---- To-do cards ---- */
.portal-task { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.25rem; border-radius: 16px; background: var(--md-surface-container-low);
    text-decoration: none; color: var(--md-on-surface); transition: background .15s, box-shadow .15s; height: 100%; }
.portal-task:hover { background: var(--md-surface-container); color: var(--md-on-surface); box-shadow: var(--md-elev-1); }
.portal-task .ic { width: 48px; height: 48px; border-radius: 16px; flex: 0 0 48px; display: flex; align-items: center; justify-content: center;
    background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.portal-task .ic .material-symbols-outlined { font-size: 24px; }
.portal-task .t { font-weight: 500; }
.portal-task .s { font-size: .8125rem; color: var(--md-on-surface-variant); }
.portal-task .go { margin-left: auto; color: var(--md-primary); font-weight: 500; font-size: .875rem; white-space: nowrap; display: flex; align-items: center; gap: .25rem; }

/* ---- Progress tracker (M3 linear progress + vertical stepper) ---- */
.md-linear { height: 4px; border-radius: 2px; background: var(--md-secondary-container); overflow: hidden; }
.md-linear > span { display: block; height: 100%; border-radius: 2px; background: var(--md-primary); transition: width .6s cubic-bezier(.2,0,0,1); }
.case-card { border-radius: 16px; background: var(--md-surface-container-lowest); border: 1px solid var(--md-outline-variant); padding: 1.25rem; text-decoration: none; color: var(--md-on-surface); display: block; }
a.case-card:hover { box-shadow: var(--md-elev-1); color: var(--md-on-surface); }
.case-card .head { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .75rem; }
.case-card .head .material-symbols-outlined { color: var(--md-primary); font-size: 28px; }
.case-card .headline { font-size: 1.125rem; font-weight: 500; }
.tone-success .md-linear > span { background: var(--md-success); }
.tone-warning .md-linear > span { background: var(--md-warning); }
.tone-neutral .md-linear > span { background: var(--md-outline); }

.stepper { list-style: none; margin: 0; padding: 0; }
.stepper li { position: relative; display: flex; gap: 1rem; padding-bottom: 1.25rem; }
.stepper li:last-child { padding-bottom: 0; }
.stepper li::before { content: ''; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--md-outline-variant); }
.stepper li:last-child::before { display: none; }
.stepper li.done::before { background: var(--md-primary); }
.stepper .dot { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px; display: flex; align-items: center; justify-content: center; font-size: .8125rem; font-weight: 500;
    border: 2px solid var(--md-outline-variant); color: var(--md-on-surface-variant); background: var(--md-surface); z-index: 1; }
.stepper .dot .material-symbols-outlined { font-size: 18px; }
.stepper li.done .dot { background: var(--md-primary); border-color: var(--md-primary); color: var(--md-on-primary); }
.stepper li.current .dot { border-color: var(--md-primary); color: var(--md-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-primary) 16%, transparent); }
.stepper li.stopped .dot { border-color: var(--md-outline); color: var(--md-outline); }
.stepper .ttl { font-weight: 500; line-height: 32px; }
.stepper li.upcoming .ttl { color: var(--md-on-surface-variant); font-weight: 400; }
.stepper .txt { font-size: .875rem; color: var(--md-on-surface-variant); margin-top: -.15rem; }
.stepper .when { font-size: .75rem; color: var(--md-on-surface-variant); margin-left: .5rem; font-weight: 400; }

/* ---- People cards ---- */
.person { display: flex; gap: 1rem; align-items: center; }
.person .md-avatar { width: 48px; height: 48px; font-size: 1.125rem; }
.person .role { font-size: .75rem; color: var(--md-on-surface-variant); }
.person .name { font-weight: 500; font-size: 1rem; }
.person-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

/* ---- Upload drop zone ---- */
.dropzone { border: 2px dashed var(--md-outline); border-radius: 16px; padding: 2rem 1rem; text-align: center; color: var(--md-on-surface-variant);
    background: var(--md-surface-container-lowest); transition: border-color .15s, background .15s; cursor: pointer; position: relative; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--md-primary); }
.dropzone.dragging { border-color: var(--md-primary); background: color-mix(in srgb, var(--md-primary) 8%, var(--md-surface)); }
.dropzone .big { font-size: 48px; color: var(--md-primary); display: block; margin: 0 auto .5rem; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-list { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .5rem; }
.file-list li { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; border-radius: 12px; background: var(--md-surface-container); font-size: .875rem; }
.file-list li .sz { margin-left: auto; color: var(--md-on-surface-variant); font-size: .75rem; }
.file-list li.bad { background: var(--md-error-container); color: var(--md-on-error-container); }
.upload-progress { display: none; margin-top: .75rem; }
.upload-progress.on { display: block; }

/* ---- Lists ---- */
.md-list { list-style: none; margin: 0; padding: 0; }
.md-list > li { display: flex; gap: 1rem; align-items: center; padding: .75rem 1rem; min-height: 64px; border-bottom: 1px solid var(--md-outline-variant); }
.md-list > li:last-child { border-bottom: 0; }
.md-list .lead { width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px; display: flex; align-items: center; justify-content: center; background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.md-list .lead.ok { background: var(--md-success-container); color: var(--md-on-success-container); }
.md-list .lead.warn { background: var(--md-warning-container); color: var(--md-on-warning-container); }
.md-list .lead.bad { background: var(--md-error-container); color: var(--md-on-error-container); }
.md-list .main { min-width: 0; flex: 1; }
.md-list .main .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.md-list .main .s { font-size: .8125rem; color: var(--md-on-surface-variant); }
.md-list .trail { margin-left: auto; flex: 0 0 auto; display: flex; gap: .5rem; align-items: center; }

/* ---- Messages (conversation) ---- */
.thread { display: flex; flex-direction: column; gap: .75rem; }
.bubble { max-width: min(560px, 88%); padding: .75rem 1rem; border-radius: 20px; white-space: pre-wrap; word-break: break-word; }
.bubble .meta { font-size: .75rem; opacity: .8; margin-top: .35rem; white-space: normal; }
.bubble .subj { font-weight: 500; margin-bottom: .2rem; white-space: normal; }
.bubble.in { align-self: flex-end; background: var(--md-primary); color: var(--md-on-primary); border-bottom-right-radius: 6px; }
.bubble.out { align-self: flex-start; background: var(--md-surface-container-high); color: var(--md-on-surface); border-bottom-left-radius: 6px; }
.bubble.update { align-self: center; background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); border-radius: 16px; max-width: 640px; }
.bubble.unread { box-shadow: 0 0 0 2px var(--md-primary); }
.composer { position: sticky; bottom: 88px; background: var(--md-surface); padding: .75rem 0; }
@media (min-width: 840px) { .composer { bottom: 0; } }

/* ---- Mortgage cards ---- */
.mortgage { border-radius: 16px; padding: 1.25rem; background: var(--md-surface-container-low); }
.mortgage .lender { font-size: 1.125rem; font-weight: 500; }
.mortgage .big { font-size: 1.75rem; line-height: 2.25rem; }
.mortgage dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; margin: 1rem 0 0; }
.mortgage dt { font-size: .75rem; color: var(--md-on-surface-variant); font-weight: 400; }
.mortgage dd { margin: 0; font-weight: 500; }
@media (min-width: 576px) { .mortgage dl { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ends-soon { border: 2px solid var(--md-warning); }

/* ---- Status pills ---- */
.status-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 16px; font-weight: 500; font-size: .875rem; }
.status-pill.ok { background: var(--md-success-container); color: var(--md-on-success-container); }
.status-pill.warn { background: var(--md-warning-container); color: var(--md-on-warning-container); }
.status-pill.bad { background: var(--md-error-container); color: var(--md-on-error-container); }
.status-pill.neutral { background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); }

/* ---- Sign-in screens ---- */
.auth-card { max-width: 440px; margin: 0 auto; }
.auth-card .card-body { padding: 2rem; }
@media (max-width: 575.98px) { .auth-card .card-body { padding: 1.5rem 1.25rem; } }
.auth-title { font-size: 1.5rem; font-weight: 400; margin: 0 0 .25rem; }
.auth-sub { color: var(--md-on-surface-variant); margin-bottom: 1.5rem; }
.sso-btn { display: flex; align-items: center; justify-content: center; gap: .75rem; width: 100%; height: 44px; border-radius: 22px; border: 1px solid var(--md-outline);
    background: var(--md-surface-container-lowest); color: var(--md-on-surface); font-weight: 500; text-decoration: none; transition: background .15s; }
.sso-btn:hover { background: color-mix(in srgb, var(--md-on-surface) 6%, var(--md-surface-container-lowest)); color: var(--md-on-surface); }
.sso-btn svg { width: 20px; height: 20px; }
.or-divider { display: flex; align-items: center; gap: .75rem; color: var(--md-on-surface-variant); font-size: .75rem; margin: 1.25rem 0; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--md-outline-variant); }
.pw-toggle { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); z-index: 5; }
.code-input { font-size: 1.75rem !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }

/* Staff panels */
.portal-panel .md-list > li { padding: .6rem .25rem; min-height: 56px; }
.portal-link-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8125rem; word-break: break-all; background: var(--md-surface-container); padding: .5rem .75rem; border-radius: 8px; }
.btn-check:checked + .md-chip { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: transparent; }
.btn-check:checked + .md-chip::before { content: 'check'; font-family: 'Material Symbols Outlined'; font-size: 18px; }

/* Staff preview: the banner pushes the shell down, so the fixed rail starts below it. */
@media (min-width: 840px) {
    .portal-body.is-preview .portal-rail { top: 116px; }
}
