/* ============================================================================
   EDITOR SHELL — large-screen (>=768px) layout for the Sale/Purchase/Expense
   editor pages (MOBILE_UX_REDESIGN_PLAN.md §5.9.5, Phase 10).

   Built once in Phase 10a (ProductInvoicePage) and reused as-is by 10b/10c.
   Everything in this file is scoped under (min-width: 768px) — phones are
   never touched here (each editor page keeps its own <768px rules, which
   already win on phone via position:fixed and are unaffected by this file).

   This is a GLOBAL stylesheet (loaded via <link>, not a .razor.css) on
   purpose: Blazor CSS isolation does not reach into the DOM rendered by
   child components (RadzenRow/RadzenColumn/RadzenDataGrid/ContactPicker...),
   so a scoped file cannot style them — see the comment in
   ProductInvoicePage.razor about the same constraint for its mobile styles.
   ============================================================================ */

@media (min-width: 768px) {

    /* ── Ambient page background — same "Harbor Blue bloom" recipe as
       HomePage.razor.css's .qa-page::before, toned down for a content page. ── */
    .editor-shell-page {
        position: relative;
    }
    .editor-shell-page::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: -1;
        pointer-events: none;
        background:
            radial-gradient(40% 32% at 10% 6%,  rgba(var(--rz-primary-rgb, 25, 74, 113), 0.09), transparent 70%),
            radial-gradient(36% 28% at 90% 18%, rgba(10, 132, 255, 0.06), transparent 70%);
    }
    :root[data-theme="dark"] .editor-shell-page::before {
        background:
            radial-gradient(40% 32% at 10% 6%,  rgba(64, 132, 188, 0.10), transparent 70%),
            radial-gradient(36% 28% at 90% 18%, rgba(10, 132, 255, 0.07), transparent 70%);
    }

    /* ── Shell grid — single column (tablet) → two-pane (desktop) ─────────────
       display: grid needs !important — RadzenRow unconditionally emits
       .rz-display-flex { display: flex !important; }, which otherwise wins
       regardless of selector specificity. */
    .editor-shell {
        display: grid !important;
        grid-template-columns: 1fr;
        align-items: start;
        gap: 1.25rem;
    }
    .editor-main {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }
    .editor-rail {
        min-width: 0;
    }
    .editor-rail__sticky {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    /* ── Glass working-area / rail cards — same recipe as NavStatusCard.razor.css ── */
    .editor-card {
        padding: 1.1rem 1.25rem;
        border-radius: 18px;
        border: 1px solid rgba(255, 255, 255, 0.55);
        background: rgba(255, 255, 255, 0.58);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        backdrop-filter: blur(24px) saturate(180%);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.65),
            0 1px 3px rgba(0, 0, 0, 0.05),
            0 4px 14px rgba(var(--rz-primary-rgb, 25, 74, 113), 0.06);
    }
    :root[data-theme="dark"] .editor-card {
        background: rgba(28, 28, 30, 0.55);
        border-color: rgba(255, 255, 255, 0.10);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.07),
            0 1px 3px rgba(0, 0, 0, 0.3),
            0 4px 14px rgba(0, 0, 0, 0.25);
    }

    .editor-card__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        flex-wrap: wrap;
        margin-bottom: 0.85rem;
    }
    .editor-card__eyebrow {
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--rz-text-secondary-color);
    }
    .editor-card__actions {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    /* Fields inside the rail (client / status / payment method / paid-now) */
    .editor-card--fields {
        display: flex;
        flex-direction: column;
    }
    .editor-field {
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
    }
    .editor-field + .editor-field {
        margin-top: 0.9rem;
    }
    .editor-field__label {
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--rz-text-secondary-color);
    }

    /* ── Itemized totals card ─────────────────────────────────────────────────── */
    .editor-totals__row {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.45rem 0;
        border-bottom: 1px solid var(--rz-border-color, rgba(0, 0, 0, 0.08));
    }
    .editor-totals__row:last-child {
        border-bottom: none;
    }
    .editor-totals__row--total {
        padding-top: 0.65rem;
        margin-top: 0.15rem;
        border-top: 1px solid var(--rz-border-color, rgba(0, 0, 0, 0.08));
    }
    .editor-totals__label {
        font-size: 0.78rem;
        color: var(--rz-text-secondary-color);
    }
    .editor-totals__value {
        font-weight: 600;
        color: var(--rz-text-color);
        text-align: right;
    }
    .editor-totals__row--total .editor-totals__label {
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--rz-text-title-color, var(--rz-text-color));
    }
    .editor-totals__row--total .editor-totals__value {
        font-size: 1.4rem;
        font-weight: 800;
        color: var(--rz-primary, #194a71);
    }
    .editor-totals__row--due .editor-totals__label,
    .editor-totals__row--due .editor-totals__value {
        color: var(--rz-warning, #ff9800);
    }

    /* ── Confirm action — plain flow item on desktop, sticky glass bar on tablet ── */
    .editor-confirm {
        margin-top: 0.25rem;
    }
    .editor-confirm .rz-button,
    .editor-confirm .btn {
        width: 100%;
    }

    /* ── Working-area table conventions ──────────────────────────────────────── */
    .editor-card--table .rz-data-row:hover > td {
        background-color: rgba(var(--rz-primary-rgb, 25, 74, 113), 0.045);
    }

    /* ── 10c: "form shell" variant — Expense has no line-items table, so it gets
       ONE centered glass card instead of the main/rail two-pane split. ──────── */
    .editor-form-shell {
        max-width: 880px;
        margin: 0 auto;
        width: 100%;
    }
    .editor-form-card {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    .editor-form-divider {
        border: none;
        border-top: 1px solid var(--rz-border-color, rgba(0, 0, 0, 0.08));
        margin: 0.15rem 0;
    }
    .editor-form-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.9rem 1.25rem;
    }
    .editor-field__value {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--rz-text-color);
    }
    .editor-field--total .editor-field__value {
        font-size: 1.3rem;
        font-weight: 800;
        color: var(--rz-primary, #194a71);
    }
}

/* Tablet only: the rail is NOT sticky-to-top here (it renders as a full-width
   card after the working area, per §10-0) — only the Confirm action pins to
   the bottom of the viewport while its card is in view. */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .editor-confirm {
        position: sticky;
        bottom: 0.85rem;
        z-index: 5;
        padding: 0.6rem;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.78);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        backdrop-filter: blur(20px) saturate(180%);
        border: 1px solid rgba(255, 255, 255, 0.6);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    }
    :root[data-theme="dark"] .editor-confirm {
        background: rgba(28, 28, 30, 0.8);
        border-color: rgba(255, 255, 255, 0.12);
    }
}

/* Desktop only: two-pane grid with a sticky rail. */
@media (min-width: 1024px) {
    .editor-shell {
        grid-template-columns: minmax(0, 1fr) 380px;
    }
    .editor-rail__sticky {
        position: sticky;
        top: 1rem;
    }

    /* 10c form shell: two-column field grid (tablet stays single-column above). */
    .editor-form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .editor-confirm {
        transition: none;
    }
}
