

/* ============================================================================
   AG Studio Pro — Mobile-First Responsive Enhancements
   Appended automatically — do not remove
   ============================================================================ */

/* === Sidebar becomes bottom sheet on mobile === */
@media (max-width: 768px) {
  /* Push content down for fixed header */
  body.ag-studio-page {
    padding-top: 52px !important;
    padding-bottom: 54px !important;
  }

  /* Hide old floating HUDs on mobile */
  #dCanvasTopHud,
  #topBedBar,
  #topSofaBar,
  #dWorkspaceQuickDock {
    display: none !important;
  }

  /* Main layout: stack vertically on mobile */
  .designer-layout {
    flex-direction: column !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Sidebar: fixed to bottom as a drawer */
  .controls-sidebar {
    position: fixed !important;
    bottom: 54px !important;
    left: 0 !important; right: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: 55vh !important;
    overflow-y: auto !important;
    z-index: 7000 !important;
    border-radius: 14px 14px 0 0 !important;
    transform: translateY(100%) !important;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1) !important;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5) !important;
  }
  .controls-sidebar.mobile-open {
    transform: translateY(0) !important;
  }

  /* Sidebar toggle handle */
  .controls-sidebar::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 10px auto 8px;
    cursor: grab;
  }

  /* Preview workspace: full screen on mobile */
  .preview-workspace {
    flex: none !important;
    width: 100% !important;
    height: calc(100dvh - 52px - 54px) !important;
    position: relative !important;
  }

  /* All interactive buttons: minimum 44px touch target */
  button, .btn, .tab-btn, .preset-btn, .door-btn {
    min-height: 44px !important;
    min-width: 44px !important;
    touch-action: manipulation;
  }

  /* Sliders: taller for thumb */
  input[type="range"] {
    height: 28px !important;
    cursor: pointer;
  }

  /* Number inputs: larger on mobile */
  input[type="number"] {
    min-height: 40px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 6px 10px !important;
  }

  /* Tabs: scroll horizontally */
  .tab-bar, .tabs-nav {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch;
  }
  .tab-bar::-webkit-scrollbar, .tabs-nav::-webkit-scrollbar { display: none; }
  .tab-btn {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* Data tables: scroll horizontally */
  .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Stat cards: 2 columns on mobile */
  .stats-grid, .stat-cards {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Panel cards: full width */
  .panel-card {
    margin: 8px 4px !important;
    border-radius: 10px !important;
  }

  /* Typography scale */
  h1 { font-size: 18px !important; }
  h2 { font-size: 16px !important; }
  h3 { font-size: 14px !important; }

  /* Toolbar preview at top of viewport */
  .preview-toolbar {
    display: none !important; /* Replaced by AG bottom toolbar */
  }
}

/* === Extra small phones (< 400px) === */
@media (max-width: 400px) {
  .stats-grid, .stat-cards {
    grid-template-columns: 1fr !important;
  }
  body.ag-studio-page {
    font-size: 13px;
  }
}

/* === Landscape mobile (short viewport) === */
@media (max-width: 900px) and (orientation: landscape) {
  .controls-sidebar {
    max-height: 40vh !important;
  }
  .preview-workspace {
    height: calc(100dvh - 52px - 54px) !important;
  }
}

/* === Tablet (769px — 1024px) === */
@media (min-width: 769px) and (max-width: 1024px) {
  .controls-sidebar {
    width: 260px !important;
    min-width: 240px !important;
  }
  .designer-layout {
    flex-direction: row !important;
  }
}

/* === Orientation change notification === */
#agOrientationNote {
  display: none;
  position: fixed;
  bottom: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff; font-size: 13px;
  padding: 8px 16px; border-radius: 20px; z-index: 9999;
  pointer-events: none; white-space: nowrap;
}
@media (max-width: 768px) and (orientation: portrait) {
  #agOrientationNote { display: block; }
}

/* === AG Studio Pro Sidebar Mobile Toggle Button === */
#agSidebarToggle {
  display: none;
}
@media (max-width: 768px) {
  #agSidebarToggle {
    display: flex !important;
    position: fixed;
    bottom: 60px; right: 16px; z-index: 8000;
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #0ea5e9, #7c3aed);
    border-radius: 50%; border: none; cursor: pointer;
    align-items: center; justify-content: center;
    font-size: 20px; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    color: #fff;
    -webkit-tap-highlight-color: transparent;
  }
}
