/* Growthmerce responsive ownership layer.
   Loaded last so every authenticated workspace shares one phone/tablet contract. */

@media (max-width: 1279.98px) {
  html:not([data-gm-public="1"]),
  html:not([data-gm-public="1"]) body,
  html:not([data-gm-public="1"]) #root,
  html:not([data-gm-public="1"]) .app-shell-bg,
  html:not([data-gm-public="1"]) .app-shell-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  html:not([data-gm-public="1"]) .app-shell-main,
  html:not([data-gm-public="1"]) main.app-scroll-viewport,
  html:not([data-gm-public="1"]) main.app-scroll-viewport > div,
  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(section, article, form, fieldset) {
    min-width: 0;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport {
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport > div {
    width: 100%;
    max-width: 100%;
    padding-inline: 0;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(img, video, canvas, svg) {
    max-width: 100%;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(.recharts-wrapper, .recharts-responsive-container, .recharts-surface) {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where([role="tablist"], nav) {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where([role="tablist"], nav)::-webkit-scrollbar {
    display: none;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport [role="tablist"] > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport div:has(> table),
  html:not([data-gm-public="1"]) main.app-scroll-viewport [data-gm-scroll-table] {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  html:not([data-gm-public="1"]) :where([role="dialog"], [data-radix-popper-content-wrapper]) {
    max-width: calc(100vw - 16px) !important;
  }

  html:not([data-gm-public="1"]) [data-radix-popper-content-wrapper] > * {
    max-width: min(34rem, calc(100vw - 16px)) !important;
  }

  html:not([data-gm-public="1"]) :where([role="dialog"], [data-radix-menu-content], [data-radix-select-content]) {
    max-height: min(82dvh, 720px);
    overscroll-behavior: contain;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(input, select, textarea, [role="combobox"]) {
    max-width: 100%;
  }

  html:not([data-gm-public="1"]) .message-templates-searchbar,
  html:not([data-gm-public="1"]) .message-templates-grid,
  html:not([data-gm-public="1"]) #gm-warehouse-scan > section,
  html:not([data-gm-public="1"]) #gm-warehouse-scan > div {
    min-width: 0;
  }
}

@media (min-width: 768px) and (max-width: 1279.98px) {
  html:not([data-gm-public="1"]) main.app-scroll-viewport {
    padding: 16px !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(button, a, [role="button"], [role="tab"]) {
    min-height: 40px;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport .grid.grid-cols-4,
  html:not([data-gm-public="1"]) main.app-scroll-viewport .grid.grid-cols-5,
  html:not([data-gm-public="1"]) main.app-scroll-viewport .grid.grid-cols-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  html:not([data-gm-public="1"]) .message-templates-searchbar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html:not([data-gm-public="1"]) .message-templates-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 767.98px) {
  html:not([data-gm-public="1"]),
  html:not([data-gm-public="1"]) body,
  html:not([data-gm-public="1"]) #root {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  html:not([data-gm-public="1"]) .app-shell-bg {
    height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html:not([data-gm-public="1"]) .app-shell-main {
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport {
    min-height: 0 !important;
    padding: 10px 10px max(22px, env(safe-area-inset-bottom, 0px)) !important;
  }

  html:not([data-gm-public="1"]) header.premium-header {
    flex: 0 0 auto;
    max-width: 100vw;
    contain: layout style paint;
    transform: translateZ(0);
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(button, a, [role="button"], [role="tab"]) {
    min-height: 40px;
    touch-action: manipulation;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(input, select, textarea, [role="combobox"]) {
    min-height: 44px;
    font-size: 16px !important;
    touch-action: manipulation;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(h1) {
    font-size: 1.35rem !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(h2) {
    line-height: 1.3 !important;
    letter-spacing: 0 !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where(.grid.grid-cols-4, .grid.grid-cols-5, .grid.grid-cols-6) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport .grid:has(.recharts-responsive-container) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport .grid:has(.recharts-responsive-container) > * {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport .recharts-responsive-container {
    width: 100% !important;
    min-width: 0 !important;
  }

  html:not([data-gm-public="1"]) :where([role="dialog"][data-state="open"]) {
    width: calc(100vw - 12px) !important;
    max-width: calc(100vw - 12px) !important;
    max-height: calc(100dvh - 12px) !important;
    margin: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 10px !important;
  }

  html:not([data-gm-public="1"]) [role="dialog"] > button.absolute {
    top: max(8px, env(safe-area-inset-top, 0px)) !important;
    inset-inline-end: 8px !important;
    width: 40px !important;
    height: 40px !important;
    opacity: 1 !important;
  }

  html:not([data-gm-public="1"]) .message-templates-hero,
  html:not([data-gm-public="1"]) .message-template-card-header {
    align-items: stretch !important;
  }

  html:not([data-gm-public="1"]) .message-templates-primary-actions,
  html:not([data-gm-public="1"]) .message-templates-bulk-actions,
  html:not([data-gm-public="1"]) .message-template-card-actions {
    width: 100%;
  }

  html:not([data-gm-public="1"]) .message-templates-primary-actions > *,
  html:not([data-gm-public="1"]) .message-templates-bulk-actions > * {
    flex: 1 1 140px;
  }

  html:not([data-gm-public="1"]) .message-template-card-header {
    flex-direction: column;
  }

  html:not([data-gm-public="1"]) .message-template-card-actions {
    justify-content: flex-start;
    overflow-x: auto;
    padding-top: 2px;
  }

  html:not([data-gm-public="1"]) .message-template-card-actions > * {
    flex: 0 0 auto;
  }

  html:not([data-gm-public="1"]) .message-templates-searchbar,
  html:not([data-gm-public="1"]) .message-templates-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html:not([data-gm-public="1"]) .message-templates-filter-lane {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html:not([data-gm-public="1"]) #gm-warehouse-scan {
    padding: 0 0 max(76px, env(safe-area-inset-bottom, 0px)) !important;
  }

  html:not([data-gm-public="1"]) #gm-warehouse-scan .grid.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  html:not([data-gm-public="1"]) #gm-warehouse-scan video {
    width: 100% !important;
    height: auto !important;
    min-height: 14rem;
    object-fit: cover;
  }

  html:not([data-gm-public="1"]) :focus-visible {
    outline: 2px solid hsl(var(--primary)) !important;
    outline-offset: 2px !important;
  }
}

@media (hover: none) and (pointer: coarse) {
  html:not([data-gm-public="1"]) main.app-scroll-viewport :where([class*="hover:-translate"], [class*="hover:scale"], .gm-hover-lift):hover {
    transform: none !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where([class*="transition-"], [class*="duration-"]) {
    transition-duration: 120ms !important;
  }

  html:not([data-gm-public="1"]) main.app-scroll-viewport :where([class*="backdrop-blur"], [style*="backdrop-filter"]) {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:not([data-gm-public="1"]) *,
  html:not([data-gm-public="1"]) *::before,
  html:not([data-gm-public="1"]) *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
