/* BillBabu mobile sales-returns view (Variant B per PRD §7).
   Scoped to .bb-mr root and only applies on mobile viewports.
   The desktop layout (.sr-page etc.) is hidden via html.page-sales-returns
   scoping inside the existing page; see pages/sales-returns-v0.html
   inline <style>. */

@media (max-width: 767px) {

/* ── Root ───────────────────────────────────────────────────────── */
.bb-mr {
    font-family: 'Inter', system-ui, sans-serif;
    background: #f3f4f6;
    color: #111827;
    padding: 12px 12px calc(96px + env(safe-area-inset-bottom, 0px));
    min-height: 100vh;
    box-sizing: border-box;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.bb-mr-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 14px;
}
.bb-mr-back {
    width: 36px !important;
    height: 36px !important;
    /* Override css/mobile.css's `button { min-height: 40px }` which
       would stretch this 36px circle vertically into an ellipse.
       !important needed because the base rule lives in a previously-
       SW-cached file; we want the override to win even if specificity
       resolves the other way in stale browser state. */
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #4318D0;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
}
.bb-mr-title {
    font-size: 19px;
    font-weight: 800;
    color: #17172a;
    margin: 0;
    letter-spacing: -0.01em;
}

/* ── Segmented control ─────────────────────────────────────────── */
.bb-mr-segment {
    display: flex;
    background: #e7e9f0;
    border-radius: 12px;
    padding: 3px;
    margin-bottom: 14px;
    gap: 0;
}
.bb-mr-seg-btn {
    flex: 1;
    padding: 9px 0;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 700;
    color: #6b7280;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s ease, color 0.12s ease;
}
.bb-mr-seg-btn.active {
    background: #fff;
    color: #17172a;
    box-shadow: 0 1px 3px rgba(15,23,42,0.08);
}
.bb-mr-seg-count {
    font-weight: 700;
}

/* ── Card primitive ─────────────────────────────────────────────── */
.bb-mr-card {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
}

/* ── Lookup row ─────────────────────────────────────────────────── */
.bb-mr-lookup-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.bb-mr-input {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid #d7deea;
    border-radius: 12px;
    font-size: 14px;
    color: #17172a;
    background: #fafbfd;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
}
.bb-mr-input:focus {
    outline: none;
    border-color: #6C47FF;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(108, 71, 255, 0.12);
}
.bb-mr-fetch-btn {
    padding: 11px 16px;
    background: linear-gradient(135deg, #6C47FF 0%, #4318D0 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.bb-mr-fetch-btn:active {
    transform: scale(0.97);
}

/* ── Invoice hero card (purple) ─────────────────────────────────── */
.bb-mr-hero {
    background: linear-gradient(135deg, #6C47FF 0%, #4318D0 100%);
    color: #fff;
    padding: 16px 16px 18px;
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: 0 4px 14px rgba(67, 24, 208, 0.22);
}
.bb-mr-hero-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.72);
    margin-bottom: 4px;
}
.bb-mr-hero-no {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 2px;
    color: #fff;
    letter-spacing: -0.01em;
}
.bb-mr-hero-cust {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.92;
    margin-bottom: 12px;
}
.bb-mr-hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.bb-mr-hero-cell-label {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.72);
    letter-spacing: 0.08em;
    margin-bottom: 2px;
}
.bb-mr-hero-cell-val {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

/* ── Items list ─────────────────────────────────────────────────── */
.bb-mr-items-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.bb-mr-items-head h3 {
    font-size: 14px;
    font-weight: 700;
    color: #17172a;
    margin: 0;
}

.bb-mr-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.bb-mr-pill-info {
    background: #ede8ff;
    color: #4318D0;
}
.bb-mr-pill-returned {
    background: #fee2e2;
    color: #b91c1c;
}

.bb-mr-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid #f1f3f9;
}
.bb-mr-item-row:last-of-type {
    border-bottom: none;
}
.bb-mr-item-row.disabled {
    opacity: 0.55;
}
.bb-mr-item-row.selected {
    /* slight bg tint when an item is selected for return */
}

.bb-mr-check {
    width: 28px !important;
    height: 28px !important;
    /* Override `button { min-height: 40px }` from css/mobile.css. The
       !important is belt-and-suspenders against any stale-cached state
       that gets the specificity wrong. */
    min-height: 28px !important;
    max-height: 28px !important;
    border-radius: 50%;
    border: 2px solid #cdd6e7;
    background: #fff;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}
.bb-mr-check.on {
    background: #4318D0;
    border-color: #4318D0;
}
.bb-mr-check.on::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 10px;
    width: 4px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.bb-mr-check:disabled {
    cursor: not-allowed;
}

.bb-mr-item-body {
    flex: 1;
    min-width: 0;
}
.bb-mr-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #17172a;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bb-mr-item-sub {
    font-size: 11px;
    color: #6b7280;
    margin-top: 3px;
}

.bb-mr-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.bb-mr-qty-btn {
    width: 32px !important;
    height: 32px !important;
    /* Override `button { min-height: 40px }` from css/mobile.css. */
    min-height: 32px !important;
    min-width: 32px !important;
    max-height: 32px !important;
    max-width: 32px !important;
    border-radius: 50%;
    background: #ede8ff;
    color: #4318D0;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.bb-mr-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.bb-mr-qty-btn:active {
    transform: scale(0.92);
    background: #d8cffd;
}
.bb-mr-qty-display {
    width: 28px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #17172a;
}

.bb-mr-all-btn {
    background: #f1f3f9;
    color: #4318D0;
    border: none;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 10px;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.bb-mr-all-btn:active {
    background: #e3e6f0;
}

/* ── Empty state ────────────────────────────────────────────────── */
.bb-mr-empty-state {
    padding: 36px 16px;
    text-align: center;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
}
.bb-mr-empty-icon {
    font-size: 36px;
    color: #d1d5db;
    margin-bottom: 10px;
    line-height: 1;
}
.bb-mr-empty-title {
    font-size: 15px;
    font-weight: 700;
    color: #4b5563;
    margin: 0 0 4px;
}
.bb-mr-empty-text {
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.4;
    margin: 0;
}

/* ── Status row ─────────────────────────────────────────────────── */
.bb-mr-status {
    min-height: 18px;
    margin-top: 4px;
    padding: 0 4px;
    font-size: 12px;
    color: #6b7280;
}
.bb-mr-status.error {
    color: #b91c1c;
}
.bb-mr-status.info {
    color: #4318D0;
}

/* ── Past returns ───────────────────────────────────────────────── */
.bb-mr-past-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.bb-mr-past-card {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.05);
    position: relative;
}
.bb-mr-past-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 4px;
}
.bb-mr-past-num {
    font-size: 12px;
    font-weight: 800;
    color: #4318D0;
    letter-spacing: 0.02em;
}
.bb-mr-past-total {
    font-size: 16px;
    font-weight: 800;
    color: #17172a;
}
.bb-mr-past-sub {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.45;
}
.bb-mr-past-mode {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    background: #ede8ff;
    color: #4318D0;
}

/* ── Sticky bottom bar ──────────────────────────────────────────── */
.bb-mr-sticky {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    background: #fff;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #eef0f7;
    box-shadow: 0 -2px 12px rgba(15,23,42,0.08);
    display: flex;
    gap: 10px;
    /* Above the mobile-shell bottom nav (z-index: 998) so Cancel/Save
       are always reachable. We also hide the bottom nav on this page
       (see body.bb-mobile-returns-mounted rule below) so there's no
       visual overlap — z-index here is belt-and-suspenders. */
    z-index: 1000;
}

/* Hide the global mobile bottom nav while the user is on the sales-
   returns mobile view. Cancel + Save take over the bottom-bar role. */
body.bb-mobile-returns-mounted .bb-bottom-nav { display: none !important; }
/* Also override the body padding-bottom that mobile-shell adds for the
   nav — without this the page leaves an awkward 80px gap at the bottom. */
body.bb-mobile-returns-mounted.bb-has-bottom-nav { padding-bottom: 0 !important; }
.bb-mr-btn {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.bb-mr-btn-outline {
    background: #fff;
    color: #4318D0;
    border: 1.5px solid #cdc3ff;
    flex: 0.8;
}
.bb-mr-btn-primary {
    background: linear-gradient(135deg, #6C47FF 0%, #4318D0 100%);
    color: #fff;
    flex: 1.4;
}
.bb-mr-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.bb-mr-btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* ── Hide the legacy desktop layout on mobile.
   Scoping via html.page-sales-returns + this @media block ensures
   nothing on other pages is affected. */
html.page-sales-returns .sr-page,
html.page-sales-returns .sr-banner,
html.page-sales-returns .sidebar-host,
html.page-sales-returns .sidebar,
html.page-sales-returns .sidebar-overlay,
html.page-sales-returns .dashboard-topbar,
html.page-sales-returns .topbar-greeting,
html.page-sales-returns .dashboard-main > .dashboard-content,
body.bb-mobile-returns-mounted .dashboard-content,
body.bb-mobile-returns-mounted .sr-page,
body.bb-mobile-returns-mounted .sidebar,
body.bb-mobile-returns-mounted .dashboard-topbar {
    display: none !important;
}
body.bb-mobile-returns-mounted .dashboard-main,
body.bb-mobile-returns-mounted main {
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
}

} /* end @media (max-width: 767px) */
