/* === RESPONSIVIDADE COMPLETA DO LEGENDARIO STUDIO (WEB & DESKTOP MULTI-TELAS) === */

html, body {
  min-height: 100dvh;
  height: 100dvh;
  max-width: 100vw;
}

#platformRoot {
  width: 100%;
  max-width: 100vw;
  min-height: 0;
  flex: 1;
}

#view-hub,
#view-crm,
#view-vault,
#view-editor,
#view-svg {
  height: calc(100dvh - 54px);
  max-height: calc(100dvh - 54px);
}

/* Scrollbar touch & área segura em modais */
#authGateOverlay,
.acct-modal-backdrop,
.pw-backdrop,
.wizard-backdrop,
.leg-modal-backdrop,
#newProjectModal {
  padding: 12px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.auth-card,
.acct-modal,
.pw-card,
.wizard-card,
.modal-card {
  max-width: calc(100vw - 24px) !important;
  max-height: calc(100dvh - 24px) !important;
  overflow-y: auto !important;
}

/* Barra superior do Editor: permite quebra organizada em laptops 1280px e tablets */
@media (max-width: 1260px) {
  #view-editor .topbar {
    height: auto !important;
    min-height: 44px;
    padding: 6px 10px !important;
    flex-wrap: wrap;
    row-gap: 6px;
  }
  #view-editor .topbar-left,
  #view-editor .topbar-center,
  #view-editor .topbar-right {
    flex-wrap: wrap;
    gap: 4px;
  }
  #view-editor .projects-bar {
    height: auto !important;
    min-height: 36px;
    padding: 4px 10px !important;
    flex-wrap: wrap;
    gap: 6px;
  }
  #view-editor .projects-tabs-track {
    max-width: 100%;
    overflow-x: auto;
  }
  #view-editor .active-project-path {
    display: none;
  }
}

/* Topbar global do Studio + Avatar + Nav */
@media (max-width: 960px) {
  .plat-topbar {
    height: auto !important;
    min-height: 54px;
    padding: 8px 12px !important;
    flex-wrap: wrap;
    gap: 8px;
  }
  .plat-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .plat-nav__btn {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .plat-topbar__right {
    margin-left: auto;
    gap: 6px;
  }
  #view-hub,
  #view-crm,
  #view-vault,
  #view-editor,
  #view-svg {
    height: auto !important;
    min-height: calc(100dvh - 96px);
    max-height: none !important;
    overflow-y: auto !important;
  }
}

/* Editor em Tablets e Celulares (<= 900px) */
@media (max-width: 900px) {
  html, body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  #view-editor .workspace {
    flex-direction: column !important;
    height: auto !important;
    min-height: calc(100dvh - 140px);
    overflow: visible !important;
    padding: 8px !important;
    gap: 10px !important;
  }
  #view-editor .sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 410px !important;
    border-radius: 18px !important;
    margin-left: 0 !important;
  }
  #view-editor .sidebar.is-collapsed {
    display: none !important;
  }
  #view-editor .sidebar-handle {
    display: none !important;
  }
  #view-editor .stage {
    width: 100% !important;
    min-height: 520px !important;
    height: 68dvh !important;
    border-radius: 18px;
  }
  #view-editor .topbar-center {
    display: none !important;
  }
  .area-popover {
    width: calc(100vw - 24px) !important;
    bottom: 10px !important;
    padding: 12px !important;
  }
  .area-popover > div:last-child {
    flex-wrap: wrap;
  }
}

/* Hub, CRM, Vectorizer e Vault em Tablets & Celulares */
@media (max-width: 920px) {
  .vectorizer-workbench {
    grid-template-columns: 1fr !important;
    height: auto !important;
    overflow-y: auto !important;
  }
  .vectorizer-sidebar-left,
  .vectorizer-sidebar-right {
    width: 100% !important;
    max-height: none !important;
    border-right: none !important;
    border-left: none !important;
  }
  .soft-hub {
    padding: 14px 14px 28px !important;
  }
  #view-crm .crm-shell {
    padding: 14px 12px 32px !important;
  }
  #view-crm .crm-header {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  #view-crm .crm-header > div {
    flex-wrap: wrap;
    width: 100%;
  }
  #view-crm #crmSearchInput {
    flex: 1 1 180px;
    min-width: 0;
  }
  .crm-kanban,
  .crm-board {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 12px;
  }
}

@media (max-width: 680px) {
  .crm-bento-top {
    grid-template-columns: 1fr !important;
  }
  .wizard-flows-grid,
  .wizard-grid,
  .acct-grid,
  .acct-tabs,
  .pw-grid {
    grid-template-columns: 1fr !important;
  }
  #downloadZipBtn span {
    font-size: 12px;
  }
  .plat-web-guide-link {
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
}
