/* ============================================================
   GSTR-9C module design system — scoped under .gstr9c-shell
   Ported token-for-token from the prototype (GSTR9C-Prototype-Source/
   GSTR9_UI/style.css): blue-gradient header, amber/green step chips,
   computed-bg/auto-bg table shading. Deliberately its own palette —
   the 9C prototype is a separate design from the 9 prototype's navy one.
   ============================================================ */

.gstr9c-shell {
    /* ---- brand / palette: tied to the app theme (--theme-default + Bootstrap vars) ---- */
    --c9-blue:       var(--theme-default, #1a5276);
    --c9-blue-dark:  color-mix(in srgb, var(--theme-default, #1a5276) 80%, #000);
    --c9-blue-light: color-mix(in srgb, var(--theme-default, #1a5276) 12%, var(--bs-body-bg, #fff));
    --c9-accent:     var(--theme-default, #00adff);
    --c9-green:      #1e8449;
    --c9-red:        #c0392b;
    --c9-amber:      #b9770e;
    --c9-border:     var(--bs-border-color, #cfd8dc);
    --c9-computed-bg: #fef9e7;
    --c9-auto-bg:    #eafaf1;
    /* ---- surfaces / ink: Bootstrap-tied, dark-mode-aware ---- */
    --c9-surface:    var(--bs-body-bg, #fff);
    --c9-surface-2:  color-mix(in srgb, var(--bs-body-color, #1a252f) 5%, var(--bs-body-bg, #f4f6f7));
    --c9-grey:       var(--c9-surface-2);
    --c9-ink:        var(--bs-body-color, #1a252f);
    --c9-ink-2:      color-mix(in srgb, var(--bs-body-color, #1a252f) 70%, var(--bs-secondary-color, #6c757d));
    --c9-ink-3:      var(--bs-secondary-color, #5d6d7e);
}

/* ---- app dark mode integration (body.dark-only) ---- */
body.dark-only .gstr9c-shell {
    --c9-blue:       color-mix(in srgb, var(--theme-default, #5b9bd5) 90%, #fff);
    --c9-blue-dark:  var(--theme-default, #4a7bc4);
    --c9-blue-light: color-mix(in srgb, var(--theme-default, #5b9bd5) 18%, #0d1420);
    --c9-green:      #52c08a;
    --c9-red:        #f0837a;
    --c9-amber:      #e0a34a;
    --c9-computed-bg: #2a2415;
    --c9-auto-bg:    #142a1e;
}

/* ---- topbar (blue gradient) + status box ---- */
.gstr9c-shell .c9-topbar {
    background: linear-gradient(135deg, var(--c9-blue-dark), var(--c9-blue));
    color: #fff;
    padding: 12px 16px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    border-radius: 8px 8px 0 0;
}
.gstr9c-shell .c9-topbar h1 { font-size: 16px; font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000); flex: 1 1 auto; margin: 0; }
.gstr9c-shell .c9-topbar .sub { font-size: 11px; opacity: .85; display: block; font-weight: clamp(1, calc(400 + var(--spq-fw-delta, 0)), 1000); }
.gstr9c-shell .c9-status-box {
    display: flex; flex-direction: column; justify-content: center; gap: 2px;
    border: 1px solid rgba(255,255,255,.35); border-radius: 6px;
    padding: 4px 12px; font-size: 11px; background: rgba(255,255,255,.12);
}
.gstr9c-shell .c9-status-box div { display: flex; gap: 8px; }
.gstr9c-shell .c9-status-box span { color: rgba(255,255,255,.7); min-width: 62px; }
.gstr9c-shell .c9-status-box b { color: #ffd5d5; }
.gstr9c-shell .c9-status-box b.ok { color: #a9f5c8; }
.gstr9c-shell .c9-btn {
    border: none; border-radius: 6px; padding: 7px 13px; font-size: 12.5px; font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000);
    cursor: pointer; background: var(--c9-accent); color: #fff; transition: filter .15s;
}
.gstr9c-shell .c9-btn:hover { filter: brightness(1.1); }
.gstr9c-shell .c9-btn.ghost { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.4); }
.gstr9c-shell .c9-btn.green { background: var(--c9-green); }
.gstr9c-shell .c9-btn.red { background: var(--c9-red); }

/* ---- step workflow bar ---- */
.gstr9c-shell .c9-stepbar {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch;
    padding: 8px 14px; background: var(--c9-surface); border-bottom: 2px solid var(--c9-border);
}
.gstr9c-shell .c9-stepbtn {
    border: 1px solid var(--c9-border); border-radius: 6px; background: var(--c9-surface);
    padding: 5px 12px; cursor: pointer; text-align: center;
    transition: background .15s; min-width: 130px; font-size: 12px; color: var(--c9-ink);
}
.gstr9c-shell .c9-stepbtn:hover { background: var(--c9-blue-light); }
.gstr9c-shell .c9-stepbtn b { display: block; color: var(--c9-blue-dark); font-size: 12px; }
.gstr9c-shell .c9-stepbtn small { display: block; color: var(--c9-amber); font-size: 10px; font-weight: clamp(1, calc(700 + var(--spq-fw-delta, 0)), 1000); }
.gstr9c-shell .c9-stepbtn small.done { color: var(--c9-green); }
.gstr9c-shell .c9-stepbtn.help { background: var(--c9-computed-bg); border-color: var(--c9-amber); }

/* ---- taxpayer strip (Pt. I) ---- */
.gstr9c-shell .tp-strip {
    background: var(--c9-surface); border: 1px solid var(--c9-border); border-radius: var(--radius, 8px);
    padding: 10px 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px;
}
.gstr9c-shell .tp-strip label { font-size: 11px; font-weight: clamp(1, calc(700 + var(--spq-fw-delta, 0)), 1000); color: var(--c9-ink-2); display: block; text-transform: uppercase; }
.gstr9c-shell .tp-strip input, .gstr9c-shell .tp-strip select {
    width: 100%; border: 1px solid var(--c9-border); border-radius: 4px; padding: 6px 8px; font-size: 13px;
    background: var(--c9-surface-2); color: var(--c9-ink);
}

/* ---- part title + table card ---- */
.gstr9c-shell .part-title { background: var(--c9-blue); color: #fff; padding: 10px 14px; border-radius: 8px 8px 0 0; font-size: 15px; font-weight: clamp(1, calc(700 + var(--spq-fw-delta, 0)), 1000); }
.gstr9c-shell .tbl-card { background: var(--c9-surface); border: 1px solid var(--c9-border); border-top: none; padding: 12px 14px 18px; margin-bottom: 18px; }
.gstr9c-shell .tbl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.gstr9c-shell .tbl-no { background: var(--c9-blue-dark); color: #fff; font-weight: clamp(1, calc(700 + var(--spq-fw-delta, 0)), 1000); font-size: 13px; padding: 3px 10px; border-radius: 4px; }
.gstr9c-shell .tbl-title { font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000); font-size: 14px; color: var(--c9-blue-dark); flex: 1; }
.gstr9c-shell .tbl-badge { font-size: 10px; font-weight: clamp(1, calc(700 + var(--spq-fw-delta, 0)), 1000); padding: 2px 8px; border-radius: 10px; }
.gstr9c-shell .tbl-badge.optional { background: var(--c9-computed-bg); color: var(--c9-amber); }
.gstr9c-shell .tbl-badge.newfy { background: var(--c9-auto-bg); color: var(--c9-green); }
.gstr9c-shell .help-icon {
    width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--c9-accent);
    background: var(--c9-surface); color: var(--c9-accent); font-weight: clamp(1, calc(800 + var(--spq-fw-delta, 0)), 1000); font-size: 13px; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.gstr9c-shell .help-icon:hover { background: var(--c9-accent); color: #fff; }
.gstr9c-shell .gstr9c-table-card { margin-bottom: 0; border-radius: 0 0 var(--radius, 8px) var(--radius, 8px); }

/* ---- computation & validation ---- */
.gstr9c-shell .comp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; padding: 14px; }
.gstr9c-shell .comp-card { border: 1px solid var(--c9-border); border-left: 5px solid var(--c9-blue); border-radius: 6px; padding: 12px; background: var(--c9-surface); }
.gstr9c-shell .comp-card h4 { font-size: 12px; color: var(--c9-ink-3); text-transform: uppercase; margin-bottom: 6px; }
.gstr9c-shell .comp-card .val { font-size: 20px; font-weight: clamp(1, calc(700 + var(--spq-fw-delta, 0)), 1000); font-family: Consolas, monospace; color: var(--c9-blue-dark); }
.gstr9c-shell .comp-card .val.pos { color: var(--c9-red); }
.gstr9c-shell .comp-card .val.ok { color: var(--c9-green); }
.gstr9c-shell .comp-card small { color: var(--c9-ink-3); }

.gstr9c-shell .vld-list { padding: 10px 14px 16px; }
.gstr9c-shell .vld-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 6px; margin-bottom: 6px; font-size: 13px; cursor: pointer; }
.gstr9c-shell .vld-item.err { background: var(--sf-raised, #fdecea); color: var(--c9-red); }
.gstr9c-shell .vld-item.warn { background: var(--sf-subtle, #fef5e7); color: var(--c9-amber); }
.gstr9c-shell .vld-item.ok { background: var(--sf-subtle, #eafaf1); color: var(--c9-green); }
.gstr9c-shell .vld-item .tag { font-weight: clamp(1, calc(800 + var(--spq-fw-delta, 0)), 1000); min-width: 52px; }

/* ---- bottom toolbar ---- */
.gstr9c-shell .gstr9c-bottombar { background: var(--c9-surface); border-top: 2px solid var(--c9-border); box-shadow: 0 -2px 10px rgba(0,0,0,.08); position: sticky; bottom: 0; z-index: 20; }
.gstr9c-shell .c9-btn.ghost2 { background: var(--c9-blue-light); color: var(--c9-blue-dark); font-size: 15px; padding: 6px 14px; }

/* ---- pill card (Basic/landing part cards) ---- */
.gstr9c-shell .card { border: 1px solid var(--c9-border); border-radius: 8px; box-shadow: 0 1px 2px rgba(20,32,54,.06); }

/* ============================================================
   Mobile responsive layer — native app feel
   Applies below 768 px. Scoped under .gstr9c-shell so it never
   leaks into other modules.
   ============================================================ */
@media (max-width: 768px) {

    /* sticky module topbar so save/validate stay reachable while scrolling
       tall reconciliation tables */
    .gstr9c-shell .sticky-head {
        position: sticky;
        top: 0;
        z-index: 20;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    }

    /* topbar: compress padding and let h1 take its own line */
    .gstr9c-shell .c9-topbar {
        padding: 8px 10px;
        gap: 6px;
        border-radius: 0;
    }
    .gstr9c-shell .c9-topbar h1 {
        font-size: 14px;
        flex-basis: 100%;
    }

    /* status box: spread fields in a row rather than column */
    .gstr9c-shell .c9-status-box {
        flex-basis: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px 16px;
        padding: 4px 8px;
    }
    .gstr9c-shell .c9-status-box div {
        flex: 1 1 auto;
    }

    /* every action button in the topbar: ≥44px touch target */
    .gstr9c-shell .c9-btn {
        min-height: 44px;
        font-size: 12px;
        padding: 6px 12px;
    }

    /* step bar: scrolls horizontally rather than wrapping into messy rows */
    .gstr9c-shell .c9-stepbar {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 6px 10px;
        -webkit-overflow-scrolling: touch;
    }
    .gstr9c-shell .c9-stepbtn {
        flex: 0 0 auto;
        min-width: 110px;
        min-height: 44px;
        font-size: 11px;
        padding: 4px 10px;
    }

    /* part title + description: compact, no border-radius collision */
    .gstr9c-shell .part-title {
        font-size: 13px;
        padding: 8px 10px;
        border-radius: 6px 6px 0 0;
    }
    .gstr9c-shell .part-desc {
        font-size: 12px;
        padding: 4px 10px;
        margin-bottom: 10px !important;
    }

    /* table card: tighter chrome */
    .gstr9c-shell .tbl-card {
        padding: 8px 8px 12px;
        margin-bottom: 12px;
    }
    .gstr9c-shell .tbl-head {
        gap: 6px;
        flex-wrap: wrap;
    }
    .gstr9c-shell .tbl-title {
        font-size: 13px;
        flex-basis: 100%;
    }

    /* SmartGrid host: horizontal scroll so wide reconciliation tables
       stay navigable on a phone without pushing the page width */
    .gstr9c-shell .grid-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .gstr9c-shell .grid-wrap .d-flex {
        min-width: 480px;
    }

    /* taxpayer strip: fields already auto-fit to 1 col on narrow viewports;
       give inputs a comfortable touch height */
    .gstr9c-shell .tp-strip {
        padding: 8px 10px;
        gap: 8px;
    }
    .gstr9c-shell .tp-strip input,
    .gstr9c-shell .tp-strip select {
        min-height: 40px;
        font-size: 14px;
    }

    /* bottombar: 44px touch targets, consistent wrapping */
    .gstr9c-shell .gstr9c-bottombar {
        gap: 0.35rem;
        padding: 0.5rem 0.5rem 0.6rem;
    }
    .gstr9c-shell .gstr9c-bottombar .c9-btn {
        min-height: 44px;
        font-size: 11.5px;
        padding: 5px 10px;
    }
}

/* very narrow phones: tighten one more notch */
@media (max-width: 380px) {
    .gstr9c-shell .c9-topbar h1 {
        font-size: 13px;
    }
    .gstr9c-shell .c9-stepbtn {
        min-width: 95px;
        font-size: 10.5px;
    }
    .gstr9c-shell .c9-btn {
        font-size: 11px;
        padding: 5px 9px;
    }
}

/* #region Arun (29-Oct-2026) — step strip sticky on every breakpoint (was phones only), as GSTR-9's
   top bar: the page scrolls inside .root-container, so stick flush at its top. */
.gstr9c-shell > .sticky-head {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--c9-surface);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
    margin-bottom: 6px;
}
/* #endregion */

/* #region Arun (29-Oct-2026) — footer vs dialogs / floating buttons
   The step dialogs render inside the sticky strip (z-index 20). The footer had the same z-index and
   comes later in the page, so it painted over an open dialog. Keep the footer one level BELOW the
   strip instead of lifting the strip (lifting it pushed the header over the portal login dialog). */
.gstr9c-shell .gstr9c-bottombar { z-index: 19; }
/* the bottom-right floating help / report buttons sat on top of Save and Delete */
@media (min-width: 768px) {
    .gstr9c-shell .gstr9c-bottombar { padding-right: 150px !important; }
}
/* #endregion */

/* #region Arun (29-Oct-2026) — footer must be solid, never see-through
   --c9-surface follows --bs-body-bg, which the theme can set translucent, so the grid showed
   through the bar. Paint the bar with the card surface (solid in light and dark), and keep every
   grid layer (selection outline, frozen header) in its own stacking context below the footer. */
.gstr9c-shell .gstr9c-bottombar { background: var(--sf-card, #fff); }
body.dark-only .gstr9c-shell .gstr9c-bottombar { background: var(--sf-card, #1f2937); }
.gstr9c-shell .grid-wrap { position: relative; z-index: 0; isolation: isolate; }
/* #endregion */

/* #region Arun (29-Oct-2026) — mandatory tables / lines (GSTN offline tool v2.9: 5A, 5Q, 7F, 9Q, 12A, 12E) */
.gstr9c-shell .tbl-badge.mandatory { background: var(--sf-raised, #fdecea); color: color-mix(in srgb, #c0392b var(--ink-keep, 100%), var(--ink-flip, #c0392b)); font-weight: clamp(1, calc(700 + var(--spq-fw-delta, 0)), 1000); }
body.dark-only .gstr9c-shell .tbl-badge.mandatory { background: #4a1f1f; color: #f87171; }
.gstr9c-shell .c9m__desc.is-req, .gstr9c-shell .c9-req { color: color-mix(in srgb, #c0392b var(--ink-keep, 100%), var(--ink-flip, #c0392b)); }
body.dark-only .gstr9c-shell .c9m__desc.is-req, body.dark-only .gstr9c-shell .c9-req { color: #f87171; }
/* #endregion */

/* #region Arun (30-Oct-2026) — ERP finish: one card language for every GSTR-9C page.
   Cards are rounded and lightly raised, headers read as headers (title weight, muted subtitle, hairline
   divider), numbers are tabular, and spacing follows one 4/8/12/16 rhythm. Tokens only, so light and
   dark both follow the theme; nothing here changes layout on phones (their rules stay in the media query above). */
.gstr9c-shell {
    --c9-radius: 10px;
    --c9-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .04);
    font-variant-numeric: tabular-nums;
}
body.dark-only .gstr9c-shell { --c9-shadow: 0 1px 2px rgba(0, 0, 0, .35); }

.gstr9c-shell .tbl-card {
    background: var(--sf-card, #ffffff);
    border: 1px solid var(--bd, #e2e8f0);
    border-radius: var(--c9-radius);
    box-shadow: var(--c9-shadow);
    padding: 14px 16px 16px;
    margin-bottom: 16px;
}
.gstr9c-shell .gstr9c-table-card { border-radius: var(--c9-radius); margin-bottom: 16px; }
.gstr9c-shell .tbl-head {
    padding-bottom: 10px; margin-bottom: 12px;
    border-bottom: 1px solid var(--bd, #eef2f7);
}
.gstr9c-shell .tbl-no {
    min-width: 34px; text-align: center; border-radius: 8px; letter-spacing: .01em;
    background: var(--theme-default, #1a5276);
}
.gstr9c-shell .tbl-title {
    font-size: 15px; letter-spacing: -.005em;
    color: var(--theme-text, #1a5276);
    font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000);
}
.gstr9c-shell .tbl-badge { border-radius: 999px; padding: 3px 9px; letter-spacing: .02em; }

.gstr9c-shell .part-title {
    border-radius: var(--c9-radius) var(--c9-radius) 0 0;
    letter-spacing: .01em;
}

.gstr9c-shell .card {
    border: 1px solid var(--bd, #e2e8f0);
    border-radius: var(--c9-radius);
    box-shadow: var(--c9-shadow);
    background: var(--sf-card, #ffffff);
}

.gstr9c-shell .comp-card {
    border: 1px solid var(--bd, #e2e8f0);
    border-left: 4px solid var(--theme-default, #1a5276);
    border-radius: var(--c9-radius);
    box-shadow: var(--c9-shadow);
    background: var(--sf-card, #ffffff);
}
.gstr9c-shell .comp-card h4 { letter-spacing: .04em; font-size: 11.5px; color: var(--tc-muted, #64748b); }
.gstr9c-shell .comp-card .val { font-family: inherit; font-variant-numeric: tabular-nums; }

.gstr9c-shell .vld-item { border-radius: 8px; padding: 9px 12px; border: 1px solid transparent; transition: border-color .12s ease; }
.gstr9c-shell .vld-item:hover { border-color: var(--bd, #e2e8f0); }

.gstr9c-shell > .sticky-head {
    border-bottom: 1px solid var(--bd, #e2e8f0);
    box-shadow: 0 6px 16px -10px rgba(15, 23, 42, .25);
}
.gstr9c-shell .gstr9c-bottombar {
    border-top: 1px solid var(--bd, #e2e8f0);
    box-shadow: 0 -6px 16px -10px rgba(15, 23, 42, .25);
}
/* #endregion */

/* #region Arun (30-Oct-2026) — Compare: portal read progress */
.c9cmp-prog { max-width: 520px; margin: 28px auto; padding: 18px 20px; border: 1px solid var(--bd, #e2e8f0); border-radius: 12px; background: var(--sf-card, #ffffff); }
.c9cmp-prog__bar { height: 4px; border-radius: 4px; overflow: hidden; background: var(--sf-subtle, #e2e8f0); margin-bottom: 14px; }
.c9cmp-prog__bar span { display: block; width: 40%; height: 100%; background: var(--theme-default, #2563eb); animation: c9cmp-slide 1.4s ease-in-out infinite; }
@keyframes c9cmp-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.c9cmp-prog__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.c9cmp-prog__steps li { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: var(--tc-muted, #64748b); }
.c9cmp-prog__steps li.is-now { color: var(--tc-strong, #0f172a); font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000); }
.c9cmp-prog__steps li.is-done { color: color-mix(in srgb, #15803d var(--ink-keep, 100%), var(--ink-flip, #15803d)); }
.c9cmp-prog__note { margin-top: 12px; font-size: 12px; color: var(--tc-muted, #64748b); }
body.dark-only .c9cmp-prog__steps li.is-done { color: #4ade80; }
@media (prefers-reduced-motion: reduce) { .c9cmp-prog__bar span { animation: none; width: 100%; opacity: .5; } }
/* #endregion */

.c9cmp-stamp { margin-left: 4px; font-weight: clamp(1, calc(600 + var(--spq-fw-delta, 0)), 1000); white-space: nowrap; }

/* #region Arun (30-Oct-2026) — footer pinned to the window bottom (spqPinFooter), always opaque */
@media (min-width: 768px) {
    .gstr9c-shell .gstr9c-bottombar.c9-pinned {
        position: fixed; bottom: 0; z-index: 30; margin: 0;
        /* a solid colour under the token, so a translucent theme surface can never let rows show through */
        background: linear-gradient(var(--sf-card, #ffffff), var(--sf-card, #ffffff)), var(--sf-card, #ffffff) !important;
        padding-bottom: calc(.5rem + env(safe-area-inset-bottom, 0px)) !important;
    }
    body.dark-only .gstr9c-shell .gstr9c-bottombar.c9-pinned { background: linear-gradient(var(--sf-card, #1f2937), var(--sf-card, #1f2937)), var(--sf-card, #111827) !important; }
}
/* #endregion */
