/**
 * DriveX — Mobile UI/UX corrections (2026-11-16).
 *
 * Targeted, additive overrides only. Three fixes, each scoped so no other
 * screen can pick them up:
 *
 *   1. Post Your Ad: one boundary per section (no box-in-a-box).
 *   2. Admin tables on phones: each row becomes a labelled card; actions
 *      sit in an aligned two-column grid.
 *   3. Toasts / status pills never sit on top of fixed bottom controls.
 *
 * `:root:root` is used deliberately: several earlier layers (dx-ds-pages,
 * dx-light-theme, dx-admin-ui) set these properties with !important, and a
 * bare selector loses to `body.xxx …` even with !important.
 */

/* ───────────────────────────────────────────────────────────────────────
   1. POST YOUR AD — remove the nested frame
   style.css made `.al-post-form` the card with flat sections inside it.
   dx-ds-pages.css and dx-light-theme.css later turned every
   `.al-form-section` into its own bordered card, but the outer border was
   never removed, so each section is drawn twice (two outlines, two radii).
   The section card stays as the single boundary; the wrapper becomes an
   invisible grouping element. Same treatment dx-refine.css already gives
   the Seller Portal profile tab.
   ─────────────────────────────────────────────────────────────────────── */
:root:root body.page-template-page-post-vehicle .al-post-form:has(> .al-form-section) {
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  overflow: visible !important;
}
/* Sections keep their single card; spacing does the separating. */
:root:root body.page-template-page-post-vehicle .al-post-form > .al-form-section {
  margin-bottom: 14px !important;
}
:root:root body.page-template-page-post-vehicle .al-post-form > .al-form-section:last-child {
  margin-bottom: 0 !important;
}

/* ───────────────────────────────────────────────────────────────────────
   2. ADMIN TABLES ON PHONES — rows become cards
   dx-admin-mobile.css hides <thead> on phones, but the rows stayed table
   rows: 8 columns squeezed into ~340px, with an inline white-space:nowrap
   on the Actions cell, so the action buttons were pushed off-screen or
   crushed together. Below 769px each row is now a card; each cell is a
   label/value line (labels copied from the <thead> by dx-mobile-ux.php);
   the actions cell is a two-column button grid. Desktop is untouched.
   ─────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root:root body.page-template-page-admin-dashboard table.al-admin-table,
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > tbody {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border: 0 !important;
    background: none !important;
  }
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > thead { display: none !important; }
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > tbody > tr {
    display: block !important;
    width: 100% !important;
    margin: 0 0 12px !important;
    padding: 12px 14px !important;
    border: 1px solid var(--ds-border, var(--border, #e3e9f1)) !important;
    border-radius: 12px !important;
    background: var(--ds-surface, var(--card, #fff)) !important;
  }
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > tbody > tr > td {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: auto !important;
    padding: 7px 0 !important;
    border: 0 !important;
    border-top: 1px solid var(--ds-border, var(--border, #eef2f7)) !important;
    white-space: normal !important;   /* beats the inline nowrap */
    text-align: right !important;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > tbody > tr > td:first-child {
    border-top: 0 !important;
    padding-top: 0 !important;
    text-align: left !important;
    justify-content: flex-start;
  }
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > tbody > tr > td[data-label]:not(:first-child)::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ds-ink-3, var(--text3, #64748b));
  }
  /* Empty-state rows (a single cell spanning all columns) stay centred. */
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > tbody > tr > td[colspan] {
    display: block !important; text-align: center !important; border-top: 0 !important;
  }
  :root:root body.page-template-page-admin-dashboard table.al-admin-table > tbody > tr > td[colspan]::before { content: none !important; }

  /* The actions cell: label on its own line, buttons in an aligned grid. */
  :root:root body.page-template-page-admin-dashboard table.al-admin-table td:has(> .al-action-group) {
    display: block !important;
    text-align: left !important;
    padding-top: 10px !important;
  }
  :root:root body.page-template-page-admin-dashboard table.al-admin-table td:has(> .al-action-group)::before {
    display: block; margin-bottom: 8px;
  }
  :root:root body.page-template-page-admin-dashboard .al-action-group {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    width: 100% !important;
  }
  :root:root body.page-template-page-admin-dashboard .al-action-group > .al-action-btn {
    width: 100%;
    min-width: 0;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 9px 10px !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    white-space: normal !important;   /* a long label wraps instead of spilling */
    text-align: center;
    flex: none !important;
  }
  :root:root body.page-template-page-admin-dashboard .al-action-group > .al-action-btn .al-action-label {
    display: inline !important;
    min-width: 0;
  }
  /* An odd last button spans the row instead of leaving a hole. */
  :root:root body.page-template-page-admin-dashboard .al-action-group > .al-action-btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  /* Nothing else in a card may force the page wider than the screen. */
  :root:root body.page-template-page-admin-dashboard .al-admin-card > div[style*="overflow-x"] {
    overflow-x: visible !important;
  }
}
/* The neutral (Edit) tone still carries the old dark-theme text colour
   (#cbd5e1 on a near-white button), so it reads as disabled. Contrast only. */
:root:root body.page-template-page-admin-dashboard .al-action-btn[data-tone="neutral"] {
  color: #334155 !important;
  border-color: rgba(100,116,139,.35) !important;
}
@media (max-width: 340px) {
  :root:root body.page-template-page-admin-dashboard .al-action-group { grid-template-columns: 1fr; }
  :root:root body.page-template-page-admin-dashboard .al-action-group > .al-action-btn:last-child:nth-child(odd) { grid-column: auto; }
}

/* ───────────────────────────────────────────────────────────────────────
   3. TOASTS AND STATUS PILLS — never over fixed bottom controls
   Every toast on the site was pinned near the bottom edge (14–84px) with a
   z-index above the fixed action bars (Post-ad Back/Continue, admin bottom
   nav, listing contact bar), so they covered those controls. The real
   height of whatever fixed bar is on screen is measured into
   --dx-safe-bottom by dx-mobile-ux.php; every toast sits 12px above it, and
   above the iPhone home indicator when there is no bar. Status messages
   no longer intercept taps, so a control behind one could still be used.
   Inline styles are overridden with !important because the toasts are
   built with style.cssText.
   ─────────────────────────────────────────────────────────────────────── */
.dxdr-bar,
.al-toast-el,
.dx-pv-saved,
.dx-safe-toast {
  bottom: calc(max(var(--dx-safe-bottom, 0px), env(safe-area-inset-bottom, 0px)) + 12px) !important;
  max-width: calc(100vw - 32px) !important;
  box-sizing: border-box !important;
  pointer-events: none !important;
  overflow-wrap: anywhere;
}
@media (max-width: 768px) {
  /* main.js slides its toast in from the right edge at a fixed 24px;
     on a phone it becomes a centred full-width strip instead. */
  .al-toast-el {
    left: 16px !important;
    right: 16px !important;
    max-width: none !important;
  }
  .dxdr-bar { line-height: 1.35; }
}
