/*
 * Contractor portal.
 *
 * Everything is scoped under .portal-shell so none of it can reach the back office, which shares
 * the same document head. Built for a phone or an iPad first — the desktop layout is the same
 * cards given more room, not a separate design.
 */

/* Size borders and padding inward on everything portal. Radzen's reset only covers its own
   .rz-* classes, so a plain div with width:100% and 1rem of padding rendered ~34px wider than an
   iPhone screen and the whole page scrolled sideways. */
.portal-shell, .portal-shell *, .portal-shell *::before, .portal-shell *::after,
.portal-auth, .portal-auth *, .portal-auth *::before, .portal-auth *::after {
    box-sizing: border-box;
}

.portal-shell {
    --portal-max-width: 900px;
    --portal-header-height: 56px;
    --portal-nav-height: 64px;

    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--rz-base-200, #f4f6f8);
    /* Belt and braces against any future wide element. `clip` rather than `hidden`, because
       `hidden` would make this a scroll container and unstick the sticky header. */
    overflow-x: clip;
}

/* Muted text. Radzen's `rz-color-secondary` is the theme's SECONDARY BRAND COLOR — pink in the
   Material theme — not a muted gray, which is why captions were rendering hot pink on phones. */
.portal-shell .portal-muted,
.portal-auth .portal-muted {
    color: var(--rz-text-secondary-color, #6b7280);
}

/* ---------- Header ---------- */

.portal-shell .portal-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--portal-header-height);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    padding-top: env(safe-area-inset-top);
    background: var(--rz-primary, #1565c0);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.portal-shell .portal-header img {
    height: 26px;
    width: auto;
}

.portal-shell .portal-header-titles {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.portal-shell .portal-header-company {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-shell .portal-header-user {
    font-size: 0.75rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-shell .portal-header-spacer {
    flex: 1;
}

.portal-shell .portal-header button {
    color: #fff !important;
}

/* ---------- Body ---------- */

.portal-shell .portal-body {
    flex: 1;
    width: 100%;
    max-width: var(--portal-max-width);
    margin: 0 auto;
    padding: 1rem;
    /* Clears the fixed bottom nav on phones. */
    padding-bottom: calc(var(--portal-nav-height) + env(safe-area-inset-bottom) + 1rem);
}

.portal-shell .portal-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--rz-text-secondary-color, #6b7280);
    margin: 0 0 0.5rem;
}

/* ---------- Claim cards ---------- */

.portal-shell .portal-claim-card {
    display: block;
    width: 100%;
    text-align: left;
    text-decoration: none;
    color: inherit;
    background: var(--rz-base-background-color, #fff);
    border: 1px solid var(--rz-border-color, #e5e7eb);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    /* Comfortably bigger than the 44px iOS minimum, since these are tapped with a thumb. */
    min-height: 88px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.portal-shell .portal-claim-card:hover,
.portal-shell .portal-claim-card:focus-visible {
    border-color: var(--rz-primary, #1565c0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    outline: none;
}

/* A submission staff have already acted on: nothing to open, so it should not invite a tap. */
.portal-shell .portal-claim-card--static {
    cursor: default;
}

.portal-shell .portal-claim-card--static:hover {
    border-color: var(--rz-border-color, #e5e7eb);
    box-shadow: none;
}

.portal-shell .portal-claim-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.portal-shell .portal-claim-title {
    font-weight: 600;
    font-size: 1.0625rem;
    line-height: 1.25;
    word-break: break-word;
    /* Flex child: without min-width:0 a long nickname refuses to wrap and shoves the chip out. */
    flex: 1;
    min-width: 0;
}

.portal-shell .portal-claim-meta {
    font-size: 0.8125rem;
    color: var(--rz-text-secondary-color, #6b7280);
    line-height: 1.45;
}

.portal-shell .portal-chip {
    flex: none;
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    /* A long status name ("Storm Watch - Waiting on Carrier") truncates instead of widening the
       card past the screen edge. */
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--rz-info-lighter, #e3f2fd);
    color: var(--rz-info-dark, #0d47a1);
}

.portal-shell .portal-chip-pending {
    background: var(--rz-warning-lighter, #fff4e5);
    color: var(--rz-warning-dark, #8a5300);
}

.portal-shell .portal-chip-closed {
    background: var(--rz-base-300, #e5e7eb);
    color: var(--rz-text-secondary-color, #4b5563);
}

/* ---------- Detail rows ---------- */

.portal-shell .portal-field {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--rz-border-color, #eceff1);
}

.portal-shell .portal-field:last-child {
    border-bottom: none;
}

.portal-shell .portal-field-label {
    font-size: 0.75rem;
    color: var(--rz-text-secondary-color, #6b7280);
    margin-bottom: 0.1rem;
}

.portal-shell .portal-field-value {
    font-size: 0.9375rem;
    word-break: break-word;
}

/* ---------- Bottom navigation (phone and tablet) ---------- */

.portal-shell .portal-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    height: calc(var(--portal-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--rz-base-background-color, #fff);
    border-top: 1px solid var(--rz-border-color, #e5e7eb);
}

.portal-shell .portal-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    text-decoration: none;
    font-size: 0.7rem;
    color: var(--rz-text-secondary-color, #6b7280);
}

.portal-shell .portal-nav a.active {
    color: var(--rz-primary, #1565c0);
    font-weight: 600;
}

.portal-shell .portal-nav .rzi {
    font-size: 1.4rem;
}

/* ---------- New-claim wizard header ---------- */

/* Replaces RadzenSteps' header: five labelled steps do not fit a phone, and its headers are
   tappable, which let people jump past validation. Five dots and the current step's name do. */
.portal-shell .portal-wizard-steps {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
}

.portal-shell .portal-wizard-dot {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--rz-base-300, #e5e7eb);
    color: var(--rz-text-secondary-color, #6b7280);
}

.portal-shell .portal-wizard-dot--current {
    background: var(--rz-primary, #1565c0);
    color: #fff;
}

.portal-shell .portal-wizard-dot--done {
    background: var(--rz-info-lighter, #e3f2fd);
    color: var(--rz-primary, #1565c0);
}

.portal-shell .portal-wizard-label {
    margin-left: 0.35rem;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- File picker ---------- */

/* Visually hidden rather than display:none. A label can only activate an input that is still
   rendered, and Safari in particular is unreliable about labels pointing at display:none inputs. */
.portal-shell .portal-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Styled to match a Radzen primary button, but it is a <label>. That matters: tapping a label
   opens the file picker natively, inside the tap's own user-activation context. Routing the tap
   through a Blazor button meant the click reached the server over SignalR and JS called .click()
   afterwards — by then the gesture had expired and iOS Safari silently refused to open anything. */
.portal-shell .portal-upload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0 1.1rem;
    border-radius: 4px;
    background: var(--rz-primary, #1565c0);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.portal-shell .portal-upload-button:active {
    filter: brightness(0.92);
}

.portal-shell .portal-upload-button--busy {
    pointer-events: none;
    opacity: 0.6;
}

/* ---------- Forms ---------- */

.portal-shell .portal-form-card {
    background: var(--rz-base-background-color, #fff);
    border: 1px solid var(--rz-border-color, #e5e7eb);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* 16px is the threshold below which iOS Safari zooms the page on focus. */
.portal-shell input,
.portal-shell textarea,
.portal-shell select {
    font-size: 16px;
}

.portal-shell .rz-button {
    min-height: 44px;
}

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
    .portal-shell .portal-body {
        padding: 1.5rem;
        padding-bottom: 2rem;
    }

    /* The bottom bar is a phone idiom; on a desktop the header links carry navigation. */
    .portal-shell .portal-nav {
        display: none;
    }

    .portal-shell .portal-claim-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .portal-shell .portal-claim-card {
        margin-bottom: 0;
    }
}

@media (max-width: 899px) {
    .portal-shell .portal-header-links {
        display: none;
    }
}

/* ---------- Sign-in pages ---------- */

.portal-auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: var(--rz-base-200, #f4f6f8);
}

.portal-auth .portal-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--rz-base-background-color, #fff);
    border-radius: 14px;
    padding: 1.75rem 1.5rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.portal-auth .portal-auth-logo {
    display: block;
    height: 46px;
    margin: 0 auto 1.25rem;
}

.portal-auth input {
    font-size: 16px;
}

.portal-auth .rz-button {
    min-height: 46px;
}

/* ---------- E-sign (signing contract) ---------- */

.portal-shell .portal-esign-qr {
    display: flex;
    justify-content: center;
    padding: 0.75rem 0;
}

.portal-shell .portal-esign-qr img {
    width: min(240px, 60vw);
    height: auto;
    border: 1px solid var(--rz-border-color, #eceff1);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
}

.portal-shell .portal-esign-link {
    background: var(--rz-base-100, #f4f5f7);
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    word-break: break-all;
    user-select: all;
}

/* The public signing page shares portal-auth's centered card. */
.portal-auth .portal-sign-doc-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0.25rem 0 0;
}

.portal-auth .portal-sign-status-icon {
    font-size: 52px;
}
