/* =====================================================================
 * DrukBid — mobile presentation overrides for the auction listing.
 *
 * Single source of truth: the SAME components render on every device; this
 * file only reshapes their appearance on phones so auction data is presented
 * as a clean vertical card feed instead of the desktop grid. Loaded AFTER
 * style.css so these rules win. Everything here is wrapped in a phone-width
 * media query, so desktop/tablet layouts are untouched.
 *
 * Scope: auction browse grid (MultipurposeAuctionGrid + AuctionDataCard).
 * ===================================================================== */

@media (max-width: 575px) {

  /* --- Section rhythm: the desktop pt-50 / mb-110 are huge on a phone --- */
  .auction-grid-section {
    padding-top: 20px !important;
    margin-bottom: 48px !important;
  }

  .auction-grid-section .container-fluid {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* --- Header: results count + filter + sort, stacked and compact -------- */
  .auction-grid-title-section {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px !important;
  }

  .auction-grid-title-section h6 {
    width: 100%;
    font-size: 13px;
    color: #6b7280;
    margin: 0;
  }

  .auction-grid-title-section .filter-selector {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .auction-grid-title-section .filter-selector .filter {
    flex: 0 0 auto;
  }

  .auction-grid-title-section .filter-selector .selector {
    flex: 1 1 auto;
  }

  /* The 2 / 3 / 4-column density toggle is a desktop control — hide it. */
  .auction-grid-title-section .grid-view {
    display: none !important;
  }

  /* --- Feed spacing: one comfortable card per row ----------------------- */
  .list-grid-product-wrap .row.g-4 {
    row-gap: 16px !important;
  }

  /* --- Card chrome: make each item read as a distinct feed card --------- */
  .list-grid-product-wrap .auction-card {
    background: #fff;
    border: 1px solid #eceff1;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(17, 24, 39, 0.06);
  }

  .list-grid-product-wrap .auction-card .auction-card-content {
    padding: 14px 16px 16px;
  }

  .list-grid-product-wrap .auction-card .auction-card-content h6 a {
    font-size: 16px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* --- Countdown pill: keep it legible and inside the image ------------- */
  .list-grid-product-wrap .auction-card .auction-card-img-wrap .countdown-timer {
    width: auto !important;
    left: auto;
    right: 10px;
    bottom: 10px;
    padding: 5px 10px;
    border-radius: 999px;
  }

  .list-grid-product-wrap .auction-card .auction-card-img-wrap .countdown-timer ul li.times {
    font-size: 13px;
  }

  .list-grid-product-wrap .auction-card .auction-card-img-wrap .countdown-timer ul li.times span {
    font-size: 8px;
  }

  /* --- Action row: brand over a full-width, thumb-friendly Bid button --- */
  .list-grid-product-wrap .auction-card .author-and-btn-area {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .list-grid-product-wrap .auction-card .author-and-btn-area .author-content {
    text-align: left;
  }

  .list-grid-product-wrap .auction-card .author-and-btn-area .bid-btn {
    width: 100%;
    text-align: center;
    padding: 13px 16px;
    border-radius: 12px;
    font-size: 15px;
  }
}

/* =====================================================================
 * Dashboard tables → stacked "label: value" cards on mobile.
 *
 * The same <table> renders on every device. Below 767px the columnar
 * layout (which forces awkward horizontal scrolling on a phone) is
 * reflowed so each data row becomes a self-contained card and every cell
 * shows its column name (from `data-label`) beside its value. Opt-in per
 * table: add the `mobile-cards` class next to `dashboard-enterprise-table`
 * once its cells are tagged, so untagged tables are left untouched.
 *
 * Requirements on the markup:
 *   - each data <tr> has class `hover-row`
 *   - each value <td> (except the first "item" cell) has a `data-label`
 *   - full-width expander / empty-state cells use `colSpan` (left as-is)
 * ===================================================================== */

@media (max-width: 767px) {

  .mobile-cards {
    border: none;
  }

  /* Column headers are replaced by per-cell labels below. Child combinators
     (>) are used throughout so none of this leaks into tables nested inside
     an expanded row's detail (e.g. the auctioneer's bidder lists). */
  .mobile-cards > thead {
    display: none;
  }

  .mobile-cards,
  .mobile-cards > tbody,
  .mobile-cards > tbody > tr,
  .mobile-cards > tbody > tr > td {
    display: block;
    width: 100%;
  }

  /* Each data row is a card. */
  .mobile-cards > tbody > tr.hover-row {
    background: #fff;
    border: 1px solid #eceff1;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(17, 24, 39, 0.05);
    padding: 4px 14px;
    margin-bottom: 14px;
  }

  /* First cell (thumbnail + item name) becomes the card header. */
  .mobile-cards > tbody > tr.hover-row > td:first-child {
    padding: 12px 0 10px !important;
    margin-bottom: 4px;
    border-bottom: 1px solid #eceff1 !important;
    max-width: none !important;
  }

  .mobile-cards > tbody > tr.hover-row > td:first-child::before {
    display: none;
  }

  /* Remaining cells: label on the left, value on the right. */
  .mobile-cards > tbody > tr.hover-row > td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    text-align: right;
    padding: 9px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid #f4f5f6 !important;
    max-width: none !important;
    white-space: normal !important;
  }

  .mobile-cards > tbody > tr.hover-row > td:last-child {
    border-bottom: 0 !important;
  }

  .mobile-cards > tbody > tr.hover-row > td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 42%;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #6b7280;
  }

  /* Action cell: let buttons wrap to their own full-width block. */
  .mobile-cards > tbody > tr.hover-row > td[data-label="Actions"] {
    flex-wrap: wrap;
  }

  .mobile-cards > tbody > tr.hover-row > td[data-label="Actions"] > div {
    width: 100%;
    justify-content: flex-start;
  }

  /* Full-width expander / empty-state cells keep their own layout; wide
     nested content scrolls inside the card rather than blowing out the page. */
  .mobile-cards > tbody > tr > td[colspan] {
    padding: 0 !important;
    text-align: left;
    overflow-x: auto;
  }

  .mobile-cards > tbody > tr > td[colspan]::before {
    display: none;
  }

  /* -------------------------------------------------------------------
   * Stack variant (add `mobile-cards--stack`): for tables whose cells are
   * already self-describing (inline sub-labels, badges, countdowns) rather
   * than bare values — e.g. the bidder "My Bids" tab. Cells stack as
   * left-aligned blocks instead of label:value rows, and empty "—" cells
   * (marked with `.cell-dash`) are hidden to keep each card tidy.
   * ----------------------------------------------------------------- */
  .mobile-cards--stack > tbody > tr.hover-row {
    padding: 6px 16px 12px !important;
    border-radius: 16px;
  }

  /* Uniform vertical rhythm: every field is a full-width block with the
     same padding and a hairline divider. */
  .mobile-cards--stack > tbody > tr.hover-row > td {
    display: block;
    text-align: left !important;
    padding: 11px 0 !important;
    border-bottom: 1px solid #f1f3f4 !important;
  }

  .mobile-cards--stack > tbody > tr.hover-row > td:first-child {
    padding: 12px 0 !important;
  }

  .mobile-cards--stack > tbody > tr.hover-row > td:last-child {
    border-bottom: 0 !important;
    padding-bottom: 2px !important;
  }

  /* Empty "—" fields (marked `.cell-dash`) are dropped so each card shows
     only what's relevant. */
  .mobile-cards--stack > tbody > tr.hover-row > td:has(> .cell-dash:only-child) {
    display: none;
  }

  /* Action buttons: full-width, thumb-friendly, evenly split when paired. */
  .mobile-cards--stack > tbody > tr.hover-row > td button {
    flex: 1 1 auto;
    min-height: 42px;
  }

  /* Countdown rings: framed chip with room to breathe (was a cramped
     row of tiny rings). Only affects the mobile card, never desktop. */
  .mobile-cards--stack .db-ring-countdown {
    gap: 14px !important;
    margin-top: 4px;
    padding: 10px 16px;
    background: #fafafa;
    border: 1px solid #eef0f1;
    border-radius: 12px;
  }

  /* --- My Bids (`--bidder`): Bid/Offer (col 3) + Status (col 4) share one
     line — price left, status badge pinned right. JSX strips the whitespace
     between the sibling <td>s, so inline-block sits flush with no gap. --- */
  .mobile-cards--bidder > tbody > tr.hover-row > td:nth-child(3),
  .mobile-cards--bidder > tbody > tr.hover-row > td:nth-child(4) {
    display: inline-block;
    box-sizing: border-box;
    vertical-align: bottom;
  }

  .mobile-cards--bidder > tbody > tr.hover-row > td:nth-child(3) {
    width: 58%;
    padding-right: 8px !important;
  }

  .mobile-cards--bidder > tbody > tr.hover-row > td:nth-child(4) {
    width: 42%;
    text-align: right !important;
  }

  /* --- Auctioneer listings (`--auct`): Category (col 2) and Brand (col 3)
     already appear in the item header, so hide those redundant cells; let
     the lifecycle stepper scroll if it's wider than the card. --- */
  .mobile-cards--auct > tbody > tr.hover-row > td:nth-child(2),
  .mobile-cards--auct > tbody > tr.hover-row > td:nth-child(3) {
    display: none;
  }

  .mobile-cards--auct > tbody > tr.hover-row > td:nth-child(7) {
    overflow-x: auto;
  }

  /* --- Browse listings (`--browse`): Starting Bid (col 4) + Current Bid
     (col 5) share one line — "From" price left, "Current" price right. --- */
  .mobile-cards--browse > tbody > tr.hover-row > td:nth-child(4),
  .mobile-cards--browse > tbody > tr.hover-row > td:nth-child(5) {
    display: inline-block;
    box-sizing: border-box;
    vertical-align: bottom;
    width: 50%;
  }

  .mobile-cards--browse > tbody > tr.hover-row > td:nth-child(5) {
    text-align: right !important;
  }

  /* "Bid Now" / "My Listing" is a styled <Link>/<span>, not a <button>, so
     stretch it to the full card width for an easy tap target. */
  .mobile-cards--browse > tbody > tr.hover-row > td:nth-child(6) > a,
  .mobile-cards--browse > tbody > tr.hover-row > td:nth-child(6) > span {
    display: flex;
    justify-content: center;
    width: 100%;
    min-height: 42px;
  }
}

/* =====================================================================
 * Tooltips (shared InfoTooltip) — keep inside the viewport on phones.
 *
 * The tooltip is hard-coded to 220px centered on its trigger, which spills
 * off-screen for the right-pinned status badges. On phones, anchor it to
 * the trigger's right edge and cap its width so it stays on screen.
 * ===================================================================== */
@media (max-width: 767px) {
  .db-tooltip {
    left: auto !important;
    right: 0 !important;
    transform: none !important;
    width: max-content !important;
    max-width: 78vw !important;
  }

  .db-tooltip-arrow {
    left: auto !important;
    right: 18px !important;
    transform: none !important;
  }
}

/* =====================================================================
 * Auctioneer pipeline filter (All / Drafts / Active / Negotiation …).
 *
 * On desktop this is a full-width stat bar (big number over label, flex:1,
 * vertical dividers). On phones that overflows into a cramped grid, so it
 * becomes a horizontal row of compact, swipeable filter chips: outlined
 * pills that size to their content and scroll, with the active one filled.
 * Only the mobile presentation changes — the same buttons/handlers stay.
 * ===================================================================== */
@media (max-width: 767px) {
  .pipe-bar {
    gap: 8px;
    padding: 10px 14px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .pipe-bar::-webkit-scrollbar {
    display: none;
  }

  .pipe-bar .pipe-tab {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 8px 14px !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 999px !important;
  }

  /* The top accent bar reads wrong on a pill — drop it. */
  .pipe-bar .pipe-tab > span:first-child {
    display: none !important;
  }

  /* Compact count badge + single-line label ("All 12", "Drafts 3", …). */
  .pipe-bar .pipe-tab .pipe-num {
    font-size: 14px !important;
  }

  .pipe-bar .pipe-tab > span:last-child {
    min-height: 0 !important;
    font-size: 11px !important;
    letter-spacing: 0.2px !important;
    white-space: nowrap !important;
  }
}

/* =====================================================================
 * Top-level dashboard tabs (My Listings / My Bids / Re-Auction /
 * Marketplace). The theme scrolls these in a single overflowing row on
 * phones. Instead, wrap them into a tidy 2-per-row grid so every tab is
 * visible without horizontal scrolling. (Overrides the theme's
 * `flex-wrap: nowrap !important`, hence the !important here.)
 * ===================================================================== */
@media (max-width: 767px) {
  .section-card-header.mine-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .mine-header .section-tabs {
    flex-wrap: wrap !important;
    overflow: visible !important;
    gap: 8px;
    margin: 0;
    padding: 0;
  }

  /* Two tabs per row. */
  .mine-header .section-tab {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    height: 40px;
  }

  /* Hide the decorative vertical divider (a bare <span>) between the "mine"
     tabs and Marketplace — it doesn't belong in a wrapped grid. */
  .mine-header .section-tabs > span {
    display: none !important;
  }
}
