/* CommerceOS — global mobile & tablet responsive layer (additive only) */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* ── Mobile navigation drawer (main app) ─────────── */
.app-mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 210;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.app-mobile-nav-toggle svg {
  width: 22px;
  height: 22px;
  display: block;
}

.app-mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 180;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}

.app-mobile-nav-backdrop.is-visible {
  display: block;
}

body.mobile-nav-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .app-mobile-nav-toggle {
    display: inline-flex;
  }

  .app--sidebar {
    flex-direction: row;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(288px, 88vw);
    min-height: 100dvh;
    max-height: 100dvh;
    flex: none;
    z-index: 200;
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    border-right: 1px solid var(--border, #e2e8f0);
    border-bottom: none;
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .app-sidebar__nav {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    overflow-x: visible !important;
    overflow-y: auto;
  }

  .app-sidebar__nav .primary-nav__item {
    width: 100%;
    flex: none;
  }

  .app-main {
    width: 100% !important;
    max-width: 100% !important;
    padding: 60px 14px 40px !important;
  }
}

@media (max-width: 480px) {
  .app-main {
    padding: 56px 10px 32px !important;
  }

  .app-mobile-nav-toggle {
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
  }
}

/* ── Panels & typography ─────────────────────────── */
@media (max-width: 768px) {
  .panel {
    padding: 16px !important;
    border-radius: 12px;
  }

  .panel h2,
  .module-hero h2 {
    font-size: 1.35rem;
  }

  .module-hero__cards,
  .decision-queue-grid,
  .scheduler-summary-grid,
  .execution-summary-grid,
  .priority-action-grid,
  .historical-trend-grid,
  .goal-grid,
  .weights-grid,
  .bundle-builder__grid,
  .integrations-grid,
  .intel-module-grid,
  .excl-settings-grid,
  .journey-analytics-grid,
  .journey-trends-summary,
  .profile-page__layout,
  .integrations-layout {
    grid-template-columns: 1fr !important;
  }

  .exit-offer-layout,
  .intel-command-bar__main,
  .decision-workspace__layout,
  .rec-decision-layout {
    grid-template-columns: 1fr !important;
  }

  .panel__head,
  .panel-head,
  .module-panel > .panel > .panel__toolbar,
  .journey-attribution-panel__head,
  .marketing-attribution-panel__head {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  .filter-tabs,
  .journey-filters__stages,
  .rec-workflow-tabs,
  .settings-tabs {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }

  .filter-tabs::-webkit-scrollbar,
  .journey-filters__stages::-webkit-scrollbar {
    display: none;
  }
}

/* ── Tables & data grids ─────────────────────────── */
@media (max-width: 768px) {
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .journey-attribution-table-wrap,
  .data-table-wrap,
  .action-center-table-wrap,
  .historical-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .data-table,
  .journey-attribution-table,
  .action-center-table {
    min-width: 520px;
  }
}

/* ── Forms & buttons ─────────────────────────────── */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  select,
  textarea,
  .form-input,
  .field-input {
    font-size: 16px;
    max-width: 100%;
  }

  .btn-row,
  .form-actions,
  .panel__actions {
    flex-direction: column;
    align-items: stretch !important;
  }

  .btn-row .btn,
  .form-actions .btn,
  .panel__actions .btn {
    width: 100%;
  }
}

/* ── Modals & drawers ────────────────────────────── */
@media (max-width: 640px) {
  .modal,
  .modal__dialog,
  .drawer,
  .profile-modal__dialog {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    margin: 12px !important;
  }
}

/* ── Journey v2 ──────────────────────────────────── */
@media (max-width: 900px) {
  .app--sidebar .app-main.app-main--journey-v2,
  .app--sidebar .app-main:has(#module-journey:not([hidden])) {
    padding: 56px 10px 16px !important;
  }

  #module-journey.module-panel:not([hidden]),
  #module-journey.jv2-module:not([hidden]) {
    min-height: auto !important;
  }

  .jv2-shell {
    min-height: auto !important;
    gap: 12px !important;
  }

  .jv2-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .jv2-header h2 {
    font-size: 1.35rem;
  }

  .jv2-header .jv2-btn {
    align-self: flex-start;
  }

  .jv2-workspace {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(240px, 38vh) minmax(320px, 1fr) !important;
    min-height: 0 !important;
    border-radius: 12px;
  }

  .jv2-list-panel {
    border-right: none !important;
    border-bottom: 1px solid #eef2f1;
  }

  .jv2-list-head,
  .jv2-filters {
    padding-left: 14px;
    padding-right: 14px;
  }

  .jv2-stages {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .jv2-stages::-webkit-scrollbar {
    display: none;
  }

  .jv2-detail-head {
    padding: 14px 14px 0;
  }

  .jv2-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .jv2-tab-body {
    padding: 14px 12px 18px;
  }

  .jv2-ai-grid {
    grid-template-columns: 1fr !important;
  }

  .jv2-actions-header {
    flex-direction: column;
    align-items: stretch;
  }

  .jv2-actions-auto {
    justify-content: space-between;
  }

  .jv2-heatmap-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .jv2-funnel__step {
    min-width: 100px;
  }
}

@media (max-width: 480px) {
  .jv2-meta {
    grid-template-columns: 1fr !important;
  }

  .jv2-tabs button {
    padding: 10px 10px;
    font-size: 0.75rem;
  }

  .jv2-workspace {
    grid-template-rows: minmax(220px, 34vh) minmax(280px, 1fr) !important;
  }
}

/* ── Legacy journey module ───────────────────────── */
@media (max-width: 900px) {
  .journey-layout,
  .cj-workspace,
  .journey-workspace,
  .journey-content-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(260px, 40vh) minmax(300px, 1fr) !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .journey-replay-layout {
    grid-template-columns: 1fr !important;
  }
}

/* ── Connect page ────────────────────────────────── */
@media (max-width: 900px) {
  .c-shell,
  .c-shell--guide {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  .c-header {
    padding: 14px 16px;
  }

  .c-main {
    padding: 16px !important;
  }

  .c-right,
  .c-left {
    min-width: 0;
  }

  .c-tabs {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .c-heading {
    font-size: 1.5rem !important;
  }

  .c-card,
  .c-panel {
    padding: 16px !important;
  }
}

/* ── Auth pages ──────────────────────────────────── */
@media (max-width: 780px) {
  .auth-shell,
  .auth-layout {
    grid-template-columns: 1fr !important;
  }

  .auth-card {
    padding: 24px 18px !important;
    margin: 16px !important;
    width: calc(100% - 32px) !important;
    max-width: none !important;
  }

  .auth-header {
    padding: 14px 16px;
  }
}

@media (max-width: 768px) {
  .strategy-overview-card,
  .workspace-header__main,
  .workspace-summary-grid,
  .decision-review-grid,
  .rec-offer-card__body {
    grid-template-columns: 1fr !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .workspace-header__main {
    display: flex;
    gap: 12px;
  }

  .workspace-header__badges {
    align-items: flex-start;
  }

  .rec-offer-card,
  .bundle-card,
  .action-card {
    min-width: 0;
  }

  .settings-layout,
  .settings-page__grid {
    grid-template-columns: 1fr !important;
  }

  .marketing-attribution-toolbar,
  .journey-attribution-toolbar {
    flex-direction: column;
    align-items: stretch !important;
    width: 100%;
  }
}

/* ── Landing pages ───────────────────────────────── */
@media (max-width: 900px) {
  .lp-hero,
  .landing-hero,
  .hero-grid,
  .features-grid,
  .pricing-grid {
    grid-template-columns: 1fr !important;
  }

  .lp-nav,
  .landing-nav {
    flex-wrap: wrap;
    gap: 10px;
  }
}
