/* 51-v2-desktop.css — the new interface on a large screen (body.ui-v2, min-width 1024px): the sidebar in the app's
   look, one content width, and page layouts that use the width (columns, grids, table-like rows, a wider capture
   window). Every rule sits inside the one media query below and starts with .ui-v2, so phones (≤768), tablets
   (769–1023) and classic do not change at all (tests/ui-v2-desktop.test.js guards both).
   Rules: docs/DESIGN.md «Desktop (body.ui-v2, ≥1024px)» · decision: docs/DECISIONS.md (desktop layer). */

@media (min-width: 1024px) {

    /* ── The shell: the sidebar ── */
    .ui-v2 .sidebar {
        width: 280px; padding: 20px 16px;
        background: var(--c-surface); border-inline-end: 1px solid var(--c-border);
    }
    /* The brand row: logo + name (index.html, first child of nav.v2-side). */
    .ui-v2 .v2-side__brand {
        display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-inline: 4px;
        font-size: 17px; font-weight: 800; line-height: 1.3; color: var(--c-text);
    }
    .ui-v2 .v2-side__brand img { flex: none; display: block; width: 36px; height: 36px; border-radius: 10px; }
    .ui-v2 .v2-side__capture { min-height: 48px; border-radius: 14px; font-size: 15px; }
    .ui-v2 .v2-side { gap: 4px; }
    .ui-v2 .v2-side__item {
        min-height: 48px; padding: 6px 8px; gap: 12px; border-radius: 14px;
        font-size: 15px; font-weight: 600; color: var(--c-text);
        transition: background-color var(--mo-fast) var(--ease-out), color var(--mo-fast) var(--ease-out);
    }
    .ui-v2 .v2-side__item i {
        flex: none; width: 36px; height: 36px; display: grid; place-items: center;
        border-radius: 10px; background: var(--c-surface-2); color: var(--c-text-muted); font-size: 15px;
        transition: background-color var(--mo-fast) var(--ease-out), color var(--mo-fast) var(--ease-out);
    }
    .ui-v2 .v2-side__item.is-on { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 700; }
    .ui-v2 .v2-side__item.is-on i { background: var(--c-surface); color: var(--c-primary); }

    /* The bottom of the sidebar: the e-mail as a quiet line, calm tool buttons, the version. */
    .ui-v2 .sidebar .bottom-actions {
        display: flex; flex-direction: column; gap: 2px;
        margin-top: auto; padding-top: 12px; border-top: 1px solid var(--c-border);
    }
    .ui-v2 #current-user-email {
        font-size: 12px !important; font-weight: 500 !important; margin-bottom: 6px !important;
    }
    .ui-v2 .sidebar .bottom-actions .btn {
        justify-content: flex-start; gap: 10px; min-height: 44px; margin-top: 2px; padding: 0 12px;
        border-color: transparent; border-radius: 14px; background: transparent; box-shadow: none;
        font-size: 14px; font-weight: 600; text-align: start;
    }
    .ui-v2 .sidebar .bottom-actions .btn > i:first-child { width: 20px; text-align: center; }
    .ui-v2 .sidebar .gdrive-backup-status { margin-inline: 12px; }
    .ui-v2 .sidebar-version {
        margin-top: 8px; font-size: 11px; font-weight: 500; color: var(--c-text-muted); text-align: center;
    }

    /* ── The content: one width for the v2 pages (classic pages under v2 keep theirs) ── */
    /* The window scrolls on a large screen (navigation scrolls it to the top), so the content must not be a scroll
       container of its own: overflow-y auto made it one and stopped every position: sticky inside it. */
    .ui-v2 .main-content { min-width: 0; padding: 28px 32px 48px; overflow-x: clip; overflow-y: visible; }
    .ui-v2 #view-today,
    .ui-v2 #view-plan,
    .ui-v2 #view-menu,
    .ui-v2 #view-settings,
    .ui-v2 #view-money,
    .ui-v2 #view-transactions,
    .ui-v2 #view-spending,
    .ui-v2 #view-cars,
    .ui-v2 #view-warranties,
    .ui-v2 #view-forecast { max-width: 1180px; margin-inline: auto; }
    /* The 720px columns inside them give way to the page width. */
    .ui-v2 .v2-ops-head,
    .ui-v2 .v2-ops,
    .ui-v2 .v2m,
    .ui-v2 .v2c-page,
    .ui-v2 .v2w-page,
    .ui-v2 .v2f-page,
    .ui-v2 #view-transactions .ledger-filters,
    .ui-v2 #ledger-custom-range { max-width: none; }

    /* ── اليوم: main column + a 400px side column (ينتظر قرارك, القادم حتى الراتب) that stays in view ── */
    .ui-v2 #v2t-body.v2t {
        /* Two equal columns until 1280px (a 400px side column would leave the hero ~250px wide at 1024). */
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto 1fr;
        grid-template-areas: "omni omni" "hero side" "main side";
        gap: 24px; align-items: start;
    }
    .ui-v2 .v2t > .v2t-omni { grid-area: omni; margin: 0; }
    .ui-v2 .v2t > .v2t-hero,
    .ui-v2 .v2t > .v2t-heros,
    .ui-v2 .v2t > .v2t-error { grid-area: hero; margin-top: 0; }
    .ui-v2 .v2t-cols { display: contents; }
    .ui-v2 .v2t-col:first-child { grid-area: side; position: sticky; top: 16px; align-self: start; }
    .ui-v2 .v2t-col:last-child { grid-area: main; }
    .ui-v2 .v2t-col > .v2t-sec:first-child { margin-top: 0; }
    @media (min-width: 1280px) {
        .ui-v2 #v2t-body.v2t { grid-template-columns: minmax(0, 1fr) 400px; }
    }

    /* ── العمليات: the «السجل | التحليل» head stays at the top while the page scrolls ── */
    .ui-v2 .v2-ops-head {
        position: sticky; top: 0; z-index: 5;
        margin-top: -10px; padding-block: 14px 12px; background: var(--c-bg);
    }

    /* ── السجل: bigger summary boxes, rows laid out like a table ── */
    .ui-v2 .v2-ops-sum { gap: 12px; }
    .ui-v2 .v2-ops-sum__box { padding: 16px 18px; }
    .ui-v2 .v2-ops-sum__box small { font-size: 13px; }
    .ui-v2 .v2-ops-sum__box b { margin-top: 4px; font-size: var(--v2-fs-amount); line-height: 1.25; }
    .ui-v2 .v2-log-card { padding: 4px 12px; }
    .ui-v2 .v2-ops .v2-log-row {
        display: grid; grid-template-columns: 42px minmax(0, 1.3fr) minmax(0, 1fr) 130px;
        align-items: center; column-gap: 16px;
        width: calc(100% + 16px); margin-inline: -8px; padding-inline: 8px; border-radius: 12px;
        transition: background-color var(--mo-fast) var(--ease-out);
    }
    .ui-v2 .v2-ops .v2-log-row .v2-row__text { display: contents; }
    .ui-v2 .v2-ops .v2-log-row .v2-log-tile { grid-column: 1; grid-row: 1; }
    .ui-v2 .v2-ops .v2-log-row .v2-row__title { grid-column: 2; grid-row: 1; justify-self: start; min-width: 0; }
    .ui-v2 .v2-ops .v2-log-row .v2-row__sub { grid-column: 3; grid-row: 1; justify-self: start; min-width: 0; margin-top: 0; font-size: 13px; }
    .ui-v2 .v2-ops .v2-log-row .v2-row__end { grid-column: 4; grid-row: 1; justify-self: end; }

    /* ── التحليل: two columns — the card and insight across, categories | top places below ── */
    .ui-v2 #v2-ops-analysis {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px;
        grid-auto-flow: row dense; align-items: start;
    }
    .ui-v2 #v2-ops-analysis > * { grid-column: 1 / -1; min-width: 0; }
    .ui-v2 #v2-ops-analysis > .v2-an-sh:has(+ .v2-an-cats),
    .ui-v2 #v2-ops-analysis > .v2-an-cats { grid-column: 1; }
    .ui-v2 #v2-ops-analysis > .v2-an-sh:has(+ .v2-an-places),
    .ui-v2 #v2-ops-analysis > .v2-an-places { grid-column: 2; }
    .ui-v2 .v2-an-chart { height: 168px; }

    /* ── أموالي: net worth across, the five sections in two columns ── */
    .ui-v2 .v2m {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-items: start;
    }
    .ui-v2 .v2m > * { min-width: 0; }
    .ui-v2 .v2m > .v2m-nw,
    .ui-v2 .v2m > .v2m-error { grid-column: 1 / -1; }

    /* ── الخطة: plan, obligations and the cash-flow line across; goals side by side ── */
    .ui-v2 #view-plan { max-width: 1180px; }
    .ui-v2 .v2p {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; align-items: start;
    }
    .ui-v2 .v2p > * { grid-column: 1 / -1; min-width: 0; }
    .ui-v2 .v2p > .v2p-goal { grid-column: auto; margin-top: var(--v2-sp-card); }
    .ui-v2 .v2p > .v2-sec-head:has(+ .v2p-goal) { margin-bottom: calc(var(--v2-sp-head) - var(--v2-sp-card)); }
    @media (min-width: 1280px) {
        .ui-v2 .v2p { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }

    /* ── القائمة and الإعدادات: groups flow in two columns with no holes ── */
    .ui-v2 #view-menu,
    .ui-v2 #v2-settings-content { columns: 2; column-gap: 24px; }
    .ui-v2 #view-menu > .v2-head,
    .ui-v2 #view-menu > .v2m-out,
    .ui-v2 #v2-settings-content > .v2s-foot { column-span: all; }
    .ui-v2 #view-menu > .v2m-out { padding-top: var(--v2-sp-sec); }
    /* Both columns start level: the first title loses its top margin (a column break already drops the other's). */
    .ui-v2 #view-menu > .v2-head { margin-bottom: var(--v2-sp-head); }
    .ui-v2 #view-menu > .v2-group-title:first-of-type,
    .ui-v2 #v2-settings-content > .v2-group-title:first-child { margin-top: 0; }
    .ui-v2 #view-menu .v2-card,
    .ui-v2 #view-menu .v2m-group,
    .ui-v2 #v2-settings-content .v2-card { break-inside: avoid; }
    .ui-v2 #view-menu .v2-group-title,
    .ui-v2 #v2-settings-content .v2-group-title { break-after: avoid; }

    /* ── تسجيل عملية: a wider window, five categories a row ── */
    .ui-v2 .v2-cap__sheet { max-width: 520px; }
    .ui-v2 .v2-cap__cats { grid-template-columns: repeat(5, minmax(0, 1fr)); }

    /* ── Desktop touches: a hand on every button, hover states for a mouse ── */
    .ui-v2 button:not(:disabled) { cursor: pointer; }
    @media (hover: hover) and (pointer: fine) {
        .ui-v2 .v2-side__item:not(.is-on):hover { background: var(--c-surface-2); color: var(--c-text); }
        .ui-v2 .v2-side__item:not(.is-on):hover i { background: var(--c-surface); color: var(--c-primary); }
        .ui-v2 .sidebar .bottom-actions .btn:hover { background: var(--c-surface-2); }
        .ui-v2 .v2-ops .v2-log-row:hover { background: var(--c-surface-2); }
        .ui-v2 .v2-list > button.v2-row:hover .v2-row__title { color: var(--c-primary); }
        .ui-v2 .v2-chip:not(.is-on):hover { background: var(--c-surface-2); }
        .ui-v2 .v2-icon-btn:hover { background: var(--c-surface-2); }
        .ui-v2 .v2t-omni:hover { color: var(--c-text); }
        .ui-v2 .v2-cap__cat:not(.is-on):hover,
        .ui-v2 .v2-cap__acc:not(.is-on):hover { border-color: var(--c-border-strong); }
    }
}
