/* Massi Cloud — application stylesheet.
   Built from the Massi Design System (claude.ai/design project "Massi Design System",
   mirrored at .claude/skills/massi-design/). Bootstrap is NOT used: every value below
   comes from tokens/*.css, and the class vocabulary matches the landing page's
   (.button--primary, .card, .badge) so the two surfaces stay in step.
   Reference treatment: .claude/skills/massi-design/ui_kits/cloud/pages.jsx */

@import "css/tokens/colors.css";
@import "css/tokens/typography.css";
@import "css/tokens/spacing.css";
@import "css/tokens/effects.css";

:root {
    /* --tab-height is the one number the bar's own min-height (NavBottomBar.razor.css) and
       this content offset both read, so raising the tab can't silently leave a gap under it —
       a change to one flows into the other because both derive from the same variable, not
       from two copies of "44px". */
    --tab-height: 44px;
    --tab-bar-height: calc(var(--tab-height) + var(--space-4) + env(safe-area-inset-bottom));
}

/* Lato itself is loaded by a <link> in App.razor, matching landing/src/layouts/Layout.astro. */

/* ---------------------------------------------------------------- base --- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: var(--weight-regular);
    font-size: var(--font-size-base);
    line-height: var(--leading-body);
    color: var(--text-body);
    background: var(--surface-alt);
    -webkit-font-smoothing: antialiased;
    /* AppHeader is a sibling of .page, not inside it (MainLayout.razor), so the header's own
       height has to come out of the 100vh budget here rather than being added on top of a
       second 100vh on .page — otherwise every mobile page is taller than the viewport by
       exactly the header's height, and a short page like /settings shows dead space below the
       fold with nothing to scroll to. */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    margin: 0;
    color: var(--text-heading);
    line-height: var(--leading-tight);
}

h1 {
    font-size: var(--font-size-3xl);
    font-weight: var(--weight-black);
    letter-spacing: var(--tracking-heading);
}

h2 {
    font-size: var(--font-size-2xl);
    font-weight: var(--weight-black);
    letter-spacing: var(--tracking-heading);
}

h3 {
    font-size: var(--font-size-lg);
    font-weight: var(--weight-bold);
}

p {
    margin: 0;
}

a {
    color: var(--link-color);
    font-weight: var(--weight-bold);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ------------------------------------------------------------ app shell --- */

.page {
    display: flex;
    flex-direction: column;
    /* Grow to fill whatever's left of body's 100vh after AppHeader, rather than claiming a
       full 100vh of its own — see the comment on body above. The desktop sidebar still gets a
       full viewport height because .sidebar sizes itself with its own `height: 100vh`, which
       is independent of this element's height. */
    flex: 1;
    min-height: 0;
}

main {
    flex: 1;
    min-width: 0;
}

.content {
    padding: var(--space-6) var(--space-4);
    /* Clear the fixed tab bar. Unconditional, so /sweep — which renders no bar — carries a
       little dead space; the alternative is a JS body-class toggle. */
    padding-bottom: calc(var(--space-6) + var(--tab-bar-height));
    max-width: 960px;
}

@media (min-width: 641px) {
    .page {
        flex-direction: row;
    }

    .content {
        padding: var(--space-8);
    }
}

/* Vertical rhythm inside a page: the design kit stacks every page at --space-4. */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    align-items: flex-start;
}

.stack > * {
    max-width: 100%;
}

.row {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    align-items: center;
}

.page-head {
    display: flex;
    width: 100%;
    gap: var(--space-3);
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* Form columns — the kit caps rule/sweep forms at 480 and the wider AI/MCP ones at 560. */
.form-column {
    width: 100%;
    max-width: 480px;
}

.form-column--wide {
    max-width: 560px;
}

/* ------------------------------------------------------------- sidebar --- */

.sidebar {
    background: var(--color-gray-900);
    flex-shrink: 0;
    /* Mobile navigation is the tab bar and the drawer, not this. */
    display: none;
}

@media (min-width: 641px) {
    .sidebar {
        display: block;
        width: 250px;
        height: 100vh;
        position: sticky;
        top: 0;
    }
}

/* ------------------------------------------------------------- buttons --- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: inherit;
    font-weight: var(--weight-regular);
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    min-height: 44px;
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
    border-radius: var(--border-radius-lg);
}

.button:hover {
    text-decoration: none;
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.button--primary {
    background: var(--gradient-primary);
    color: var(--text-on-primary);
    font-weight: var(--weight-bold);
    box-shadow: var(--shadow-cta);
}

.button--primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-cta-hover);
}

.button--primary:active {
    transform: translateY(0);
}

.button--secondary {
    background: var(--color-gray-100);
    color: var(--color-gray-900);
    border: 1px solid var(--color-gray-300);
}

.button--secondary:hover {
    background: var(--color-gray-200);
}

.button--outline {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.button--outline:hover {
    background: var(--tint-primary-05);
    border-color: var(--color-primary-hover);
}

/* Destructive row action — from the kit's DangerButton: quiet until you look at it. */
.button--danger {
    background: transparent;
    color: var(--color-danger);
    font-weight: var(--weight-bold);
    border: 1px solid #fecaca;
    min-height: 0;
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-sm);
}

.button--danger:hover {
    background: #fef2f2;
}

.button--sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
}

.button--lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
    border-radius: var(--border-radius-xl);
}

/* A text-weight link that sits next to a button without competing with it. */
.button-link {
    align-self: center;
    font-size: var(--font-size-sm);
}

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

.card {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-xl);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: flex-start;
}

.card > .button,
.card > .row {
    flex-shrink: 0;
}

.card--featured {
    border: 2px solid var(--color-primary);
    box-shadow: var(--shadow-lg);
}

/* --------------------------------------------------------------- table --- */

.table-card {
    width: 100%;
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-xl);
    overflow-x: auto;
}

.table-card table {
    width: 100%;
    border-collapse: collapse;
}

.table-card th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    white-space: nowrap;
    font-size: var(--font-size-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-badge);
    color: var(--text-muted);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border-default);
}

.table-card td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--color-gray-700);
    border-bottom: 1px solid var(--color-gray-100);
}

.table-card tr:last-child td {
    border-bottom: none;
}

.table-card td strong {
    color: var(--color-gray-900);
}

/* A note belonging to the row above it — a failed sweep's reason, for instance. Reads as a
   continuation of that row rather than a row of its own: no separator between the two, and the
   separator that closes the pair sits under the note. */
.table-card tr.table-note td {
    padding-top: 0;
    font-size: var(--font-size-xs);
}

.table-card tr:not(.table-note) + tr.table-note td {
    border-top: none;
}

.table-card tr:has(+ tr.table-note) td {
    border-bottom: none;
}

.rule-scope {
    display: block;
}

/* Opt-in stacked rendering: below the breakpoint each row reads as a card, cells labelled by
   their data-label attribute.

   900px, deliberately not the app's 640px mobile breakpoint. The rules table's min-content
   width is ~730px with realistic data (7 columns, an email address, three row-action buttons).
   At 640px the sidebar layout has already engaged, so between ~640px and ~750px the table
   could not fit and the PAGE — not the scroll container — overflowed sideways, leaving the
   last column (Edit / Pause / Delete) off-screen with only a horizontal scrollbar to find it
   by. Measured, not guessed: the actions were off-screen at 700px and fine at 800px.

   The gap between that ~750px threshold and 900px is intentional margin. Min-content width is
   content-dependent — longer rule names or addresses push it up — and being stacked slightly
   too early costs nothing, while being stacked slightly too late hides a row's only controls. */
@media (max-width: 900px) {
    .table-card--stacked table,
    .table-card--stacked tbody {
        display: block;
    }

    .table-card--stacked thead {
        display: none;
    }

    .table-card--stacked tr {
        display: block;
        padding: var(--space-3) var(--space-4);
        border-bottom: 1px solid var(--border-default);
    }

    .table-card--stacked tr:last-child {
        border-bottom: none;
    }

    .table-card--stacked td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: var(--space-3);
        padding: var(--space-1) 0;
        border-bottom: none;
    }

    .table-card--stacked td[data-label]::before {
        content: attr(data-label);
        font-size: var(--font-size-xs);
        font-weight: var(--weight-bold);
        text-transform: uppercase;
        letter-spacing: var(--tracking-badge);
        color: var(--text-muted);
    }

    /* The name cell and the actions cell carry no data-label — stack them as blocks so the
       scope line (already display:block) falls under the name instead of fighting it for
       width beside a right-aligned value. */
    .table-card--stacked td:not([data-label]) {
        display: block;
    }

    /* A labelled cell with no value (e.g. Subject on a from-only rule) would otherwise paint
       a bare uppercase label with nothing after it. */
    .table-card--stacked td[data-label]:empty {
        display: none;
    }
}

/* -------------------------------------------------------------- alerts --- */

.alert {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--border-radius-lg);
    font-size: var(--font-size-sm);
    line-height: var(--leading-body);
    border: 1px solid transparent;
}

.alert--info {
    background: var(--color-primary-50);
    color: #1e40af;
    border-color: #bfdbfe;
}

.alert--success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.alert--warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.alert--danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.alert a {
    color: inherit;
    text-decoration: underline;
}

/* -------------------------------------------------------------- badges --- */

.badge {
    display: inline-block;
    font-size: var(--font-size-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-badge);
    padding: 2px 10px;
    border-radius: var(--border-radius-pill);
    vertical-align: middle;
}

.badge--soon {
    background: var(--color-primary);
    color: var(--color-white);
}

.badge--free {
    background: var(--color-success);
    color: var(--color-white);
}

.badge--tint {
    background: var(--tint-primary-10);
    color: var(--color-primary);
}

.badge--neutral {
    background: var(--color-gray-100);
    color: var(--color-gray-600);
}

.badge--count {
    background: var(--color-danger);
    color: var(--color-white);
}

/* --------------------------------------------------------------- forms --- */

.input,
.select {
    width: 100%;
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-base);
    font-family: inherit;
    color: var(--color-gray-900);
    background: var(--color-white);
    border: 1px solid var(--border-input);
    border-radius: var(--border-radius-lg);
}

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

.field-label {
    font-size: var(--font-size-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-badge);
    color: var(--text-muted);
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
    font-size: var(--font-size-sm);
    font-weight: var(--weight-bold);
    color: var(--color-gray-700);
}

.checkbox-field input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-primary);
}

/* An <EditForm> renders one <form> element, so it needs its own stack. */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
}

/* An input and its button on one line (create-token, BYOK, suggest). */
.input-row {
    display: flex;
    gap: var(--space-2);
    width: 100%;
}

.input-row > .input,
.input-row > .select {
    flex: 1;
}

.input-row > .button {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ----------------------------------------------------------- text tone --- */

.muted {
    color: var(--text-body);
}

.muted strong {
    color: var(--color-gray-900);
}

.subtle {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.error-text {
    color: var(--color-danger);
    font-size: var(--font-size-sm);
}

.success-text {
    color: var(--color-success);
    font-size: var(--font-size-sm);
}

/* A confirmation that replaces a form, rather than annotating one — so it carries the weight
   of a heading instead of the small type used for inline status. */
.auth-success {
    color: var(--color-success);
    font-size: var(--font-size-lg);
    font-weight: var(--weight-bold);
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: var(--color-gray-100);
    color: var(--color-gray-800);
    padding: 2px 6px;
    border-radius: var(--border-radius-sm);
}

.code--block {
    display: block;
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* -------------------------------------------------------------- status --- */

/* 8px dot + label, the design system's only status idiom (no icon font). */
.status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: var(--weight-bold);
    color: var(--color-gray-600);
}

.status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status--ok {
    color: var(--color-success);
}

.status--bad {
    color: var(--color-danger);
}

.status--pending {
    color: var(--color-warning);
}

/* ------------------------------------------------------------ progress --- */

.progress {
    width: 100%;
    height: 8px;
    border-radius: var(--border-radius-pill);
    background: var(--color-gray-100);
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: var(--gradient-primary);
    transition: width var(--transition);
}

/* ------------------------------------------------------- notifications --- */

/* No reference in ui_kits/cloud (notifications postdate the design system) —
   composed from the system's card + row idiom. */
.notifications {
    width: 100%;
    max-width: 640px;
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-xl);
    overflow: hidden;
}

.notification {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--color-gray-100);
}

.notifications li:last-child .notification,
.notification:last-child {
    border-bottom: none;
}

.notification--unread {
    background: var(--tint-primary-04);
    font-weight: var(--weight-bold);
    color: var(--color-gray-900);
}

/* ------------------------------------------------- destructive actions --- */

/* Table row actions sit on one line and never wrap mid-control. */
.row-actions {
    display: inline-flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

/* An armed ConfirmButton: the question and its two answers, in place of the button.
   No modal — the design system has no dialog idiom for the cloud app. */
.confirm {
    display: inline-flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

.confirm__prompt {
    font-size: var(--font-size-sm);
    font-weight: var(--weight-bold);
    color: var(--color-gray-900);
}

/* ---------------------------------------------------------- card grids --- */

/* Two cards side by side (the kit pairs the connect options and the paid tiers). */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
    width: 100%;
    align-items: start;
}

.card-grid--narrow {
    max-width: 640px;
}

/* Equal-height cards, so bottom-aligned CTAs line up (the tier pair). */
.card-grid--stretch {
    align-items: stretch;
}

@media (min-width: 641px) {
    .card-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --------------------------------------------------------------- tiers --- */

.tier__price {
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
}

.tier__amount {
    font-size: var(--font-size-3xl);
    font-weight: var(--weight-black);
    color: var(--color-gray-900);
}

.tier__period {
    color: var(--text-muted);
    font-weight: var(--weight-bold);
}

.tier__tagline {
    color: var(--color-primary);
    font-weight: var(--weight-bold);
}

.tier .button {
    margin-top: auto;
    width: 100%;
}

/* Stands in for the button on the plan you already hold, so it needs the same bottom-alignment
   the button gets — otherwise that card's content floats and the grid row stops lining up. */
.tier__current {
    margin-top: auto;
    width: 100%;
    text-align: center;
    padding: var(--space-2) 0;
    color: var(--text-muted);
    font-weight: var(--weight-bold);
}

/* ---------------------------------------------------------- auth shell --- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: var(--gradient-hero);
}

.auth-card {
    width: 380px;
    max-width: 100%;
    padding: var(--space-8);
    box-shadow: var(--shadow-xl);
}

.auth-card .button,
.auth-card .input {
    width: 100%;
}

.wordmark {
    font-weight: var(--weight-black);
    font-size: var(--font-size-2xl);
    letter-spacing: var(--tracking-heading);
    color: var(--color-gray-900);
}

/* --------------------------------------------------------- error strip --- */

#blazor-error-ui {
    color-scheme: light only;
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    background: #fef2f2;
    color: #991b1b;
    border-top: 1px solid #fecaca;
}

#blazor-error-ui .reload {
    color: inherit;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: var(--space-3);
    top: var(--space-2);
}

.blazor-error-boundary {
    padding: var(--space-4);
    border-radius: var(--border-radius-lg);
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-size: var(--font-size-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* Blazor validation hooks (were Bootstrap-styled). */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--color-success);
}

.invalid {
    outline: 1px solid var(--color-danger);
}

.validation-message {
    color: var(--color-danger);
    font-size: var(--font-size-sm);
}

/* ------------------------------------------------------------- motion --- */

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }

    .button--primary:hover {
        transform: none;
    }
}

/* ------------------------------------------------------------ settings --- */

/* The brand mark, shared by the header and the drawer. Global rather than scoped for the
   same reason .avatar below is: Blazor scoped CSS cannot be shared between components, and
   two verbatim copies of one rule is the worse trade. */
.mark {
    display: block;
    flex: none;
}

.settings-account {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.settings-account__email {
    font-weight: var(--weight-bold);
    color: var(--text-heading);
}

/* The design's account glyph: initials on a primary tint. Reused by the brand bar. */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--tint-primary-10);
    color: var(--color-primary);
    font-weight: var(--weight-bold);
    font-size: var(--font-size-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    position: relative;
}

.settings-rows {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    background: var(--surface-card);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--border-radius-xl);
    overflow: hidden;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 52px;
    padding: 0 var(--space-4);
    color: var(--text-heading);
    font-weight: var(--weight-bold);
    text-decoration: none;
    border-top: 1px solid var(--color-gray-100);
}

.settings-row:first-child {
    border-top: none;
}

.settings-row:hover {
    background: var(--surface-alt);
    text-decoration: none;
}

.chev {
    font-size: var(--font-size-lg);
    font-weight: var(--weight-bold);
    color: var(--color-gray-400);
    line-height: 1;
}
