/* Mobile navigation drawer + six-column trade history.
   This file is loaded after the main dashboard stylesheet so it can remain a
   small, isolated UI layer without touching trading/runtime code. */

.foa-mobile-menu-launcher,
.foa-mobile-drawer,
.foa-mobile-drawer-backdrop {
  display: none;
}

/* Exit Spot is a real trade-history column on every screen size. */
.trade-head,
.trade-row {
  grid-template-columns:
    minmax(0, .82fr)
    minmax(0, 1fr)
    minmax(0, 1.18fr)
    minmax(0, .78fr)
    minmax(0, .72fr)
    minmax(0, 1.18fr) !important;
}

.trade-exit-spot {
  min-width: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  color: var(--soft);
}

@media (max-width: 760px) {
  body.foa-mobile-drawer-open {
    overflow: hidden !important;
  }

  /* The full desktop header is intentionally removed on phones. Navigation and
     account controls live in the left drawer instead. */
  .builder-header {
    display: none !important;
  }

  .foa-mobile-menu-launcher {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 48px;
    padding: 5px 1px 3px;
  }

  .foa-mobile-menu-button,
  .foa-mobile-drawer-close {
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    color: var(--text);
    background: linear-gradient(145deg, var(--panel), var(--panel-2));
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
    cursor: pointer;
    touch-action: manipulation;
  }

  .foa-mobile-menu-button {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 13px;
  }

  .foa-mobile-menu-button span,
  .foa-mobile-menu-button::before,
  .foa-mobile-menu-button::after {
    content: "";
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
  }

  .foa-mobile-menu-button span {
    margin: 4px 0;
  }

  .foa-mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    background: rgba(1, 6, 15, .64);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: opacity 180ms ease;
  }

  .foa-mobile-drawer {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 111;
    flex-direction: column;
    width: min(86vw, 320px);
    max-width: calc(100vw - 44px);
    padding: calc(14px + env(safe-area-inset-top)) 13px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    color: var(--text);
    background:
      radial-gradient(circle at 0 0, rgba(59, 130, 246, .18), transparent 18rem),
      linear-gradient(160deg, #07111d, #03070d 72%);
    border-right: 1px solid var(--line);
    box-shadow: 28px 0 80px rgba(0, 0, 0, .42);
    transform: translateX(-104%);
    transition: transform 210ms ease;
  }

  #foa-simple-app[data-theme="light"] .foa-mobile-drawer {
    background:
      radial-gradient(circle at 0 0, rgba(37, 99, 235, .12), transparent 18rem),
      linear-gradient(160deg, #ffffff, #f5f8fd 72%);
  }

  body.foa-mobile-drawer-open .foa-mobile-drawer {
    transform: translateX(0);
  }

  body.foa-mobile-drawer-open .foa-mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .foa-mobile-drawer-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
  }

  .foa-mobile-drawer-head strong,
  .foa-mobile-drawer-head small {
    display: block;
  }

  .foa-mobile-drawer-head strong {
    font-size: 16px;
    letter-spacing: -.035em;
  }

  .foa-mobile-drawer-head small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9.5px;
  }

  .foa-mobile-drawer-close {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 11px;
    font-size: 21px;
    line-height: 1;
  }

  .foa-mobile-account-card {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(59, 130, 246, .08);
  }

  .foa-mobile-account-card span {
    color: var(--muted);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .09em;
  }

  .foa-mobile-account-card strong {
    min-width: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
    text-transform: capitalize;
  }

  .foa-mobile-drawer-nav {
    display: grid;
    gap: 6px;
    margin-top: 12px;
  }

  .foa-mobile-drawer button,
  .foa-mobile-drawer a {
    font: inherit;
  }

  .foa-mobile-nav-button,
  .foa-mobile-risk-button,
  .foa-mobile-logout-button,
  .foa-mobile-login-button {
    width: 100%;
    min-height: 43px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--text);
    background: rgba(255, 255, 255, .035);
    text-align: left;
    cursor: pointer;
    text-decoration: none;
  }

  .foa-mobile-nav-button.active {
    color: #fff;
    border-color: var(--line-strong);
    background: linear-gradient(135deg, var(--blue-deep), var(--blue));
  }

  .foa-mobile-theme-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
  }

  .foa-mobile-theme-copy strong,
  .foa-mobile-theme-copy small {
    display: block;
  }

  .foa-mobile-theme-copy strong {
    font-size: 12px;
  }

  .foa-mobile-theme-copy small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
  }

  .foa-mobile-theme-toggle {
    position: relative;
    width: 52px;
    height: 30px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(148, 163, 184, .16);
    cursor: pointer;
  }

  .foa-mobile-theme-toggle::after {
    content: "";
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--text);
    transform: translateX(0);
    transition: transform 160ms ease;
  }

  .foa-mobile-theme-toggle[aria-checked="true"] {
    background: var(--blue);
  }

  .foa-mobile-theme-toggle[aria-checked="true"]::after {
    transform: translateX(22px);
    background: #fff;
  }

  .foa-mobile-drawer-actions {
    display: grid;
    gap: 6px;
    margin-top: auto;
    padding-top: 14px;
  }

  .foa-mobile-risk-button {
    color: var(--soft);
  }

  .foa-mobile-logout-button {
    color: #fecaca;
    border-color: rgba(239, 68, 68, .34);
    background: var(--red-soft);
  }

  .foa-mobile-login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    background: linear-gradient(135deg, #16a34a, #22c55e);
  }

  /* On Trades, the KPI strip is moved above the trading-status panel by the
     enhancement script. This keeps Balance/P&L/Runs/Wins/Losses as the first
     execution telemetry below the menu icon. */
  .builder-stats,
  .builder-stats.compact {
    top: max(6px, env(safe-area-inset-top)) !important;
  }

  /* Six compact columns fit inside the phone. No sideways scroll is introduced. */
  .trade-head,
  .trade-row {
    display: grid !important;
    grid-template-columns:
      minmax(0, .68fr)
      minmax(0, .74fr)
      minmax(0, 1.02fr)
      minmax(0, .68fr)
      minmax(0, .62fr)
      minmax(0, 1.02fr) !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    gap: 3px !important;
    padding: 7px 5px !important;
  }

  .trade-head {
    font-size: 7.5px !important;
  }

  .trade-row {
    margin: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-radius: 0 !important;
    font-size: 8.3px !important;
  }

  .trade-row > *,
  .trade-head > * {
    min-width: 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .trade-exit-spot {
    text-align: center !important;
  }
}

@media (max-width: 380px) {
  .trade-head {
    font-size: 7px !important;
  }

  .trade-row {
    font-size: 7.7px !important;
  }

  .trade-head,
  .trade-row {
    gap: 2px !important;
    padding-left: 3px !important;
    padding-right: 3px !important;
  }
}
