/* Responsivo — 1280 / 1024 / 768 / 480 */

@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .composer-page { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 1024px) {
  /* Header: esconder ações secundárias, deixar a busca encolher */
  .header .btn-primary, .header [aria-label="Ajuda"], .header .credit-label { display: none; }
  .search-trigger { min-width: 0; flex: 1; max-width: 300px; }
  /* Topbar do Estúdio: prioriza Distribuir */
  .studio-topbar .autosave, .studio-topbar .breadcrumb, .studio-topbar .credit-chip { display: none; }
  .studio-topbar #doc-name { width: min(180px, 26vw); }
  .studio-topbar .btn span { display: none; }
  .studio-topbar .btn { padding: 0 var(--space-3); }
  .studio-topbar .btn-primary span { display: inline; }
  /* Sidebar vira drawer */
  .sidebar { transform: translateX(-100%); visibility: hidden; box-shadow: none; width: var(--sidebar-width) !important; transition: transform var(--dur-slow) var(--ease), visibility 0s var(--dur-slow); }
  html[data-nav="open"] .sidebar { transform: translateX(0); visibility: visible; box-shadow: var(--shadow-lg); transition: transform var(--dur-slow) var(--ease), visibility 0s 0s; }
  .main-col { margin-left: 0 !important; }
  .nav-toggle { display: inline-flex !important; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .studio-inspector { position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-drawer); transform: translateX(100%); visibility: hidden; transition: transform var(--dur-slow) var(--ease), visibility 0s var(--dur-slow); box-shadow: var(--shadow-lg); width: 320px; }
  html[data-inspector="open"] .studio-inspector { transform: translateX(0); visibility: visible; transition: transform var(--dur-slow) var(--ease), visibility 0s 0s; }
  .composer-page { display: flex; flex-direction: column; }
  .col-config, .col-side { display: contents; }
  .mo-1 { order: 1; } .mo-2 { order: 2; } .mo-3 { order: 3; } .mo-4 { order: 4; } .mo-5 { order: 5; }
  .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .page { padding: var(--space-4); }
  .header { padding: 0 var(--space-3); gap: var(--space-1); }
  .dropdown-brand { flex: 1 1 auto; min-width: 0; display: flex; }
  .brand-switch { flex: 1; min-width: 0; max-width: none; width: 100%; padding-right: 0; }
  .brand-switch .bs-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
  .search-trigger { flex: none; width: 36px; min-width: 36px; padding: 0; justify-content: center; border-color: transparent; background: transparent; color: var(--text-secondary); }
  .search-trigger > span { display: none; }
  .search-trigger .icon-sm { width: 18px; height: 18px; }
  .header .credit-chip { padding: 0 var(--space-2); }
  .search-trigger .kbd, .header .credit-chip .credit-label { display: none; }
  .card-header { flex-wrap: wrap; row-gap: var(--space-2); }
  .card-footer { flex-wrap: wrap; row-gap: var(--space-2); }
  .settings-section .card-body .row { flex-wrap: wrap; row-gap: var(--space-2); }
  .card-header .seg { contain: inline-size; flex: 1 1 100%; max-width: 100%; overflow-x: auto; }
  .page-actions .select { flex: 1; max-width: 100%; width: auto; }
  .chart-legend { margin-left: 0 !important; }
  .hide-md { display: none !important; }
  .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip .metric { border-left: 0; border-top: 1px solid var(--border-subtle); }
  .kpi-strip .metric:nth-child(even) { border-left: 1px solid var(--border-subtle); }
  .kpi-strip .metric:nth-child(-n + 2) { border-top: 0; }
  .page-head { flex-direction: column; align-items: stretch; }
  .btn, .btn-icon { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .nav-item { min-height: 44px; }

  /* Modais viram bottom sheets */
  .modal { align-items: flex-end; padding: 0; }
  .modal-box { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
  .drawer { width: 100%; max-width: none; }

  /* Tabelas viram cards */
  .table-adapt thead { display: none; }
  .table-adapt tr { display: block; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); margin-bottom: var(--space-3); background: var(--surface-card); padding: var(--space-2); }
  .table-adapt td { display: flex; justify-content: space-between; gap: var(--space-3); border: 0; padding: var(--space-2) var(--space-3); }
  .table-adapt td::before { content: attr(data-label); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
  .table-adapt .td-num { text-align: right; }

  /* Estúdio: Editor / Prévia separados */
  .studio-rail { display: none; }
  .studio-mode-switch { display: inline-flex !important; }
  .studio[data-mode="preview"] .hide-on-preview { display: none !important; }
  .studio[data-mode="preview"] .canvas-stage { background: var(--surface-page); }
  .canvas-frame { height: auto; width: 100%; max-width: 420px; }
  .studio-topbar .hide-md { display: none !important; }
  .studio-inspector { top: auto; left: 0; right: 0; bottom: 0; width: 100% !important; max-height: 72vh; transform: translateY(100%); border-left: 0; border-top: 1px solid var(--border-subtle); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  html[data-inspector="open"] .studio-inspector { transform: translateY(0); }

  /* Calendário compacto */
  .cal-grid { grid-template-columns: 1fr; }
  .header .hide-md { display: none !important; }
  .cal-dow { display: none; }
  .cal-cell { min-height: 0; flex-direction: row; align-items: center; flex-wrap: wrap; border-left: 0; }
  .cal-cell.is-out { display: none; }
  .cal-day { min-width: 44px; }
  .cal-cell .post-chip { width: auto; flex: 1; min-width: 160px; }

  .action-tri { grid-template-columns: 1fr; }
  .composer-page { gap: var(--space-4); }
  .toast-region { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); }
  .toast { max-width: none; }
}

@media (max-width: 480px) {
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi-strip .metric { border-left: 0 !important; }
  .hide-sm { display: none !important; }
  .header { padding: 0 var(--space-2); }
  .header .credit-chip { padding: 0 6px; }
  .header .dropdown:last-child .btn-icon { padding: 0; width: 36px; }
  .dropdown-brand .brand-switch .icon-sm { display: none; }
  .dropdown-brand .brand-switch { gap: var(--space-1); }
}

/* Toggle de navegação móvel — oculto no desktop */
.nav-toggle { display: none; }
.studio-mode-switch { display: none; }

/* Header público compacto */
.cta-short { display: none; }
@media (max-width: 768px) {
  .pub-header-in { gap: var(--space-3); }
  .pub-header .btn-ghost { display: none; }
  .pub-header .cta-full { display: none; }
  .pub-header .cta-short { display: inline; }
}
@media (max-width: 480px) {
  .pub-header .brand-name span { display: none; }
}
