/* ============================================================
   Goold — Responsive (mobile <768 / tablet 768-1023 / desktop 1024+)
   Padrão iOS HIG para mobile. Desktop não é tocado por este arquivo.
   ============================================================ */

/* ===== Sheet (componente compartilhado: more-sheet, filters-sheet) ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.36);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 320;
}
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 330;
  background: var(--bg-1);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%);
  transition: transform 380ms cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  overflow: hidden;
  overscroll-behavior: contain;
}
.sheet.is-open { transform: translateY(0); }
.sheet__handle-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}
.sheet__handle {
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: #D1D5DB;
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px 14px;
  border-bottom: 1px solid var(--hairline);
}
.sheet__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet__body--filters { padding: 20px; gap: 24px; }
.sheet__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px;
  background: transparent;
  border: none;
  border-radius: 12px;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  min-height: 48px;
  transition: background 120ms cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet__item:active { background: var(--bg-2); transform: scale(0.985); }
.sheet__item.is-active { color: var(--brand); background: var(--brand-soft); }
.sheet__item-label { flex: 1; }
.sheet__item-chev { color: var(--text-dim); }
.sheet__item--danger { color: var(--brand); }
.sheet__item--danger:active { background: var(--brand-soft); }

/* ===== Bottom tab bar (mobile only) ===== */
.bottom-tabs {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.12);
  align-items: stretch;
  justify-content: space-around;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 48px;
  transition: color 120ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 80ms ease;
}
.bottom-tab .icon { width: 24px; height: 24px; }
.bottom-tab__label { line-height: 1; letter-spacing: 0; }
.bottom-tab:active { transform: scale(0.95); }
.bottom-tab.is-active { color: var(--brand); }

/* =====================================================================
   MOBILE — até 767px
   ===================================================================== */
@media (max-width: 767px) {
  body {
    grid-template-columns: 1fr !important;
    overscroll-behavior-y: contain;
  }
  body[data-view="calendario"],
  body[data-view="painel"],
  body[data-view="relatorios"],
  body[data-view="configuracoes"],
  body[data-view="usuarios"],
  body[data-view="perfil"] {
    grid-template-columns: 1fr !important;
  }
  .profile-card { padding: 20px; }
  .profile-photo-row { flex-direction: column; align-items: flex-start; gap: 16px; }

  /* Esconde sidebar/rail; mostra bottom tabs */
  .rail { display: none !important; }
  .sidebar { display: none !important; }
  body[data-view="calendario"] #view-calendario { display: block; }
  body[data-view="calendario"] .main { width: 100%; }
  .bottom-tabs { display: flex; }

  /* Espaço inferior pra não cobrir conteúdo com a tab bar */
  .main, .painel, .placeholder-page {
    padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }

  /* Header colapsado */
  .header {
    grid-template-columns: 1fr auto !important;
    padding: 12px 16px !important;
    padding-top: calc(12px + env(safe-area-inset-top));
    gap: 8px !important;
    position: sticky;
    top: 0;
  }
  .header__title-block { grid-column: 1 / -1; }
  .header__title { font-size: 22px !important; line-height: 1.15; }
  .header__subtitle { font-size: 13px; }
  .header__nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    gap: 4px;
    margin-top: 2px;
  }
  .month-nav { padding: 2px; }
  .month-nav__btn { width: 36px; height: 36px; }
  .month-nav__label { min-width: 120px; padding: 0 8px; font-size: 13px; }
  .month-nav__today { display: none; } /* Hoje some em mobile (spec) */
  .header__actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
  }
  .team-filter__btn {
    height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }
  .team-filter__btn .label { display: none; }
  .header__filters-btn { display: inline-flex; }
  .user-chip__info { display: none; }
  .user-chip__chev { display: none; }
  .user-chip { padding: 2px; }

  /* Team filter dropdown vira bottom sheet em mobile */
  .team-filter__menu {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100vw !important;
    min-width: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 0 12px calc(20px + env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.12) !important;
    z-index: 340;
    animation: gs-sheet-in 380ms cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 60vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .team-filter__handle {
    display: block !important;
    width: 36px;
    height: 5px;
    border-radius: 999px;
    background: #D1D5DB;
    margin: 8px auto 12px;
  }
  .team-filter--open .team-filter__backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(17, 17, 17, 0.36);
    z-index: 335;
    animation: gs-fade-in 200ms ease;
  }
  .team-filter__option {
    padding: 14px 12px;
    font-size: 15px;
    min-height: 48px;
  }
  @keyframes gs-sheet-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  @keyframes gs-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* Painel */
  .painel { padding: 12px 16px !important; gap: 16px !important; }
  .painel__head {
    display: flex !important;
    grid-template-columns: none !important;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .painel__title { font-size: 26px !important; }
  .painel__subtitle { font-size: 13px; }
  .painel__head-actions { width: 100%; justify-content: flex-end; gap: 6px; }
  .painel-section { padding-top: 0 !important; }
  .painel-section__head { padding: 8px 0 !important; }
  .painel-section__title { font-size: 18px !important; }
  .next-action {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    padding: 18px !important;
    gap: 12px !important;
  }
  .next-action__body { gap: 8px; }
  .next-action__cta { width: 100%; }
  .next-action__cta .btn-pill { width: 100%; justify-content: center; }
  .next-action__combo { font-size: 22px !important; line-height: 1.15; }
  .next-action__price .to { font-size: 22px; }
  .next-action__icons .next-action__canal-ico { width: 36px !important; height: 36px !important; }

  /* Stat row */
  .seg-bar { height: 8px; }
  .seg-bar__legend { font-size: 12px; flex-wrap: wrap; gap: 6px; }

  /* List rows full width */
  .list-row {
    padding: 12px !important;
    min-height: 56px;
  }
  .list-row:active { transform: scale(0.98); }
  .list-row__icons { gap: 4px; }
  .list-row__icon { width: 28px; height: 28px; }
  .list-row__combo { font-size: 14px; }
  .list-row__date { font-size: 11px; }
  .list-row__value { font-size: 13px; }

  /* Box do mês — uma coluna */
  .box-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .box-monthly { padding: 18px !important; }

  /* Calendário — modo compacto: dia + bolinha por canal */
  .calendar { padding: 0 12px 24px !important; gap: 8px; }
  .calendar__weekdays { gap: 4px; padding: 0 2px; }
  .calendar__weekday {
    padding: 6px 2px;
    font-size: 10px;
    letter-spacing: 0.04em;
  }
  .calendar__grid {
    grid-auto-rows: minmax(54px, auto) !important;
    gap: 4px !important;
  }
  .cell {
    padding: 6px 4px !important;
    border-radius: 10px;
    min-height: 54px;
    gap: 4px;
  }
  .cell--today { padding: 4.5px 2.5px !important; }
  .cell__head { padding: 0; }
  .cell__day { font-size: 13px; }
  .cell__count {
    font-size: 10px;
    color: var(--brand);
    font-weight: 600;
    background: var(--brand-soft);
    border-radius: 999px;
    padding: 1px 6px;
    line-height: 1.4;
  }
  .cell__actions { display: none !important; }
  .cell__dots {
    display: flex;
    gap: 3px;
    justify-content: center;
    margin-top: auto;
    padding-bottom: 2px;
  }
  .cell:active { transform: scale(0.97); }

  /* Drawer vira sheet full-screen-up em mobile */
  .drawer {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-left: none !important;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    top: auto !important;
    bottom: 0;
    transform: translateY(100%);
    transition: transform 380ms cubic-bezier(0.32, 0.72, 0, 1) !important;
    padding-top: 0;
    padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior: contain;
  }
  .drawer.is-open { transform: translateY(0) !important; }
  .drawer__header {
    padding: 6px 16px 14px !important;
    flex-direction: column;
    align-items: stretch;
  }
  .drawer__header::before {
    content: '';
    display: block;
    width: 36px;
    height: 5px;
    border-radius: 999px;
    background: #D1D5DB;
    margin: 8px auto 12px;
  }
  .drawer__header > div { width: 100%; }
  .drawer__header > button { position: absolute; right: 12px; top: 18px; }
  .drawer__body {
    padding: 16px 20px !important;
    gap: 20px !important;
  }
  .drawer__title { font-size: 22px !important; }
  .price-block { padding: 12px !important; }
  .price-block .to { font-size: 20px !important; }
  .meta-row { grid-template-columns: 1fr !important; gap: 8px; }
  .positioning-row__ico { width: 36px; height: 36px; }
  .positioning-row__ico svg { width: 36px; height: 36px; }

  /* Day popover vira bottom sheet */
  .day-popover {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-height: 85vh !important;
    transform: translateY(100%) !important;
    transition: transform 380ms cubic-bezier(0.32, 0.72, 0, 1) !important;
  }
  .day-popover.is-open { transform: translateY(0) !important; }
  .day-popover__box {
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .day-popover__box::before {
    content: '';
    display: block;
    width: 36px;
    height: 5px;
    border-radius: 999px;
    background: #D1D5DB;
    margin: 8px auto 4px;
  }
  .day-popover__head { padding: 8px 18px 12px; }
  .day-popover__date { font-size: 16px; }

  /* Search modal mobile */
  .search-modal { top: 12vh !important; width: calc(100vw - 16px) !important; }

  /* Toast mobile */
  .toast-stack {
    top: auto !important;
    right: 12px;
    left: 12px;
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .toast { min-width: 0; width: 100%; }

  /* Login: ocupa 100vw com padding */
  .login-screen {
    padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  }
  .login-card { width: 100%; max-width: none; padding: 24px 20px; }
  .login-form input { height: 48px !important; font-size: 16px !important; }
  .login-submit { height: 48px !important; font-size: 16px !important; }

  /* Inputs nunca menores que 16px (Safari iOS não dá zoom) */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Placeholder pages */
  .placeholder-page { padding: 16px !important; }
  .placeholder-title { font-size: 26px !important; }
  .placeholder-card { padding: 24px !important; }
  .placeholder-card__title { font-size: 18px !important; }

  /* Tabela de usuários → cards stack vertical */
  .users-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .users-toolbar .btn-pill { width: 100%; justify-content: center; }
  .users-table { background: transparent !important; border: none !important; }
  .users-row {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-areas:
      "name role"
      "email role"
      "access trash" !important;
    gap: 4px 12px !important;
    padding: 14px !important;
    background: var(--bg-1);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-card);
  }
  .users-row + .users-row { border-top: 1px solid var(--hairline) !important; }
  .users-row.users-row--head { display: none !important; }
  .users-row__name { grid-area: name; font-size: 15px; font-weight: 600; }
  .users-row__email { grid-area: email; font-size: 13px; }
  .users-row__role,
  .users-row > span:nth-child(3) { grid-area: role; align-self: start; justify-self: end; }
  .users-row__access-wrap { grid-area: trash; justify-self: end; align-self: end; }
  .users-row--confirm { grid-template-areas: "name name" "confirm confirm" !important; }
  .users-row__confirm-text { grid-area: confirm; }

  /* Modal de adicionar usuário em mobile */
  .modal {
    align-items: flex-end !important;
  }
  .modal-card {
    width: 100% !important;
    max-width: none !important;
    border-radius: 20px 20px 0 0 !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Tap states gerais (sem hover em mobile, :active scale 0.97) */
  .btn:active,
  .btn-pill:active,
  .chip:active,
  .month-nav__btn:active,
  .month-nav__today:active,
  .user-chip:active,
  .rail__btn:active,
  .live-item:active,
  .box-card:active,
  .next-action__cta .btn-pill:active,
  .search-result:active {
    transform: scale(0.97);
    opacity: 0.9;
  }
  /* Remove hover effects que ficam grudados em mobile */
  .btn:hover,
  .chip:hover,
  .month-nav__btn:hover,
  .cell:hover,
  .live-item:hover,
  .user-chip:hover { background: inherit; transform: none; box-shadow: var(--shadow-card); }

  /* Garante min touch target em controles pequenos */
  .btn--icon { width: 44px !important; height: 44px !important; }
  .month-nav__btn { min-width: 36px; min-height: 36px; }

  /* Painel head em mobile já é flex column; bottom margin extra */
  .painel-progress { padding-top: 0 !important; }

  /* Auto chip em next-action escala pra mobile */
  .auto-chip { font-size: 11px; }
}

/* =====================================================================
   TABLET — 768 a 1023px
   ===================================================================== */
@media (min-width: 768px) and (max-width: 1023px) {
  :root { --nav-w: 64px; --sidebar-w: 64px; }
  body[data-view="calendario"] {
    grid-template-columns: var(--nav-w) 1fr !important;
  }
  body[data-view="painel"],
  body[data-view="relatorios"],
  body[data-view="configuracoes"],
  body[data-view="usuarios"],
  body[data-view="perfil"] {
    grid-template-columns: var(--nav-w) 1fr !important;
  }

  /* Rail colapsada — só ícones */
  .rail { padding: 16px 8px; gap: 20px; }
  .rail__brand { justify-content: center; padding: 0; }
  .rail__brand img { height: 28px; }
  .rail__group-label { display: none; }
  .rail__btn {
    flex-direction: column;
    gap: 0;
    padding: 10px 8px;
    justify-content: center;
    text-align: center;
  }
  .rail__btn span { display: none; }
  .rail__btn .icon { width: 22px; height: 22px; }

  /* Esconde sidebar secundária do calendário; acesso via botão de filtros */
  .sidebar { display: none !important; }
  body[data-view="calendario"] .main { width: 100%; min-width: 0; }
  .header__filters-btn { display: inline-flex; }

  /* Header tablet */
  .header { padding: 16px 24px; }
  .header__title { font-size: 24px; }

  /* Calendar grid menor */
  .calendar { padding: 20px 24px 36px; gap: 12px; }
  .calendar__grid { grid-auto-rows: minmax(100px, auto); gap: 8px; }
  .cell { padding: 6px; min-height: 100px; }
  .cell__day { font-size: 13px; }
  .action { padding: 5px 6px; }
  .action__combo { font-size: 12px; }
  .action__to { font-size: 12px; }
  .action__line, .action__from { font-size: 10px; }
  .status-pill--cell { font-size: 10px; padding: 1px 6px; }
  .canal-mini { width: 16px; height: 16px; }
  .canal-mini--instagram svg, .canal-mini--grupos svg { width: 16px; height: 16px; }

  /* Drawer menor */
  .drawer { width: 320px; }

  /* Painel: stat cards full + box em 2 colunas */
  .painel { padding: 24px 32px; }
  .box-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* =====================================================================
   Garantir que botão de filtros some em desktop
   ===================================================================== */
@media (min-width: 1024px) {
  .header__filters-btn { display: none; }
}
@media (max-width: 1023px) {
  .header__filters-btn { display: inline-flex; }
}

/* =====================================================================
   Landscape em mobile baixo — header colapsa mais
   ===================================================================== */
@media (max-width: 767px) and (orientation: landscape) {
  .header { padding-top: 8px !important; }
  .calendar__grid { grid-auto-rows: minmax(48px, auto) !important; }
}

/* =====================================================================
   Animação de slide-up nos sheets — fallback caso transition não pegue
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .sheet,
  .day-popover,
  .drawer,
  .sheet-backdrop,
  .day-popover-backdrop,
  .drawer-backdrop { transition: opacity 100ms linear !important; transform: none !important; }
}
