/* ===========================
   Responsive Breakpoints
   =========================== */

/* --- Tablet / Small Desktop --- */

@media (max-width: 1024px) {
  .agents-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 90%;
  }

  .modal-lg {
    max-width: 95%;
  }

  .content {
    padding: 20px;
  }

  .pipeline-step {
    max-width: 100%;
  }

  .pipeline-add-step {
    max-width: 100%;
  }
}

/* --- Mobile Landscape / Small Tablet --- */

@media (max-width: 768px) {
  /* Sidebar becomes an overlay drawer */
  .sidebar {
    position: fixed;
    left: -280px;
    width: 280px;
    z-index: 200;
    transition: left 0.3s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  /* Overlay backdrop when sidebar is open */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  /* Main content takes full width */
  .main {
    margin-left: 0 !important;
  }

  /* Topbar hamburger menu */
  .topbar {
    padding: 0 12px;
  }

  .topbar-search {
    display: none;
  }

  .notification-panel {
    width: 100%;
  }

  .command-palette {
    width: 95%;
  }

  .content {
    padding: 12px;
  }

  .card {
    padding: 16px;
  }

  .terminal {
    font-size: 12px;
    padding: 12px;
  }

  .editor-textarea {
    font-size: 12px;
    padding: 12px;
  }

  .editor-gutter {
    min-width: 40px;
    font-size: 12px;
  }

  .pipeline-container {
    padding: 12px;
  }

  /* Agent detail header responsive */
  .agent-detail-header {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .agent-detail-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px !important;
  }

  /* Table horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Touch-friendly buttons */
  .btn {
    min-height: 40px;
    padding: 8px 16px;
  }

  .btn-sm {
    min-height: 34px;
    padding: 6px 12px;
  }

  .btn-ghost {
    min-height: 36px;
  }

  /* Follow-up bar stacks on mobile */
  .followup-bar {
    flex-direction: column !important;
  }

  .followup-bar input {
    width: 100% !important;
  }

  /* File list items stack */
  .file-item {
    flex-wrap: wrap;
    gap: 6px !important;
  }

  .file-size, .file-date {
    font-size: 11px;
  }
}

/* --- Mobile Portrait --- */

@media (max-width: 480px) {
  .modal {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-lg {
    max-width: 100%;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    padding: 10px 14px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }

  .btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .agent-card {
    padding: 14px;
  }

  .agent-stats {
    gap: 12px;
  }

  .stat-value {
    font-size: 16px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .notification-panel-header {
    padding: 12px 16px;
  }

  .notification-item {
    padding: 10px 12px;
  }

  .command-palette input {
    padding: 12px 16px;
    font-size: 14px;
  }

  .command-palette-item {
    padding: 8px 12px;
    font-size: 13px;
  }

  .content {
    padding: 8px;
  }

  .form-control {
    padding: 10px 12px;
    font-size: 14px;
  }

  .terminal-toolbar {
    padding: 6px 8px;
    gap: 4px;
    flex-wrap: wrap;
  }

  .terminal-toolbar input {
    width: 100%;
    max-width: none !important;
  }

  .editor-toolbar {
    padding: 6px 8px;
    flex-wrap: wrap;
  }

  /* Stats grid - 2 columns on mobile */
  .content > div[style*="grid-template-columns"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Run tab options stack vertically */
  #model-select, #effort-select, #concurrency-select {
    width: 100% !important;
  }

  /* Mic button larger on touch */
  #mic-btn {
    width: 40px !important;
    height: 40px !important;
  }
}
