/**
 * Responsividade compartilhada — área logada / PWA (WebView).
 * Carregar após profile.css nas páginas app/* e profile/*.
 */

html {
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

body.feed-drawer-open,
body.fp-story-viewer-open {
  overflow: hidden;
  overscroll-behavior: none;
}

img,
video,
iframe,
svg {
  max-width: 100%;
}

/* Safe area (iPhone notch / home indicator) */
.profile-header-wrapper {
  padding-top: max(7px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* Navbar compacta — todas as páginas com #navbar-container */
@media (max-width: 768px) {
  .profile-header-wrapper {
    padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 6px
      max(10px, env(safe-area-inset-left));
    overflow: visible;
  }

  .profile-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    height: 48px;
    position: relative;
    overflow: visible;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 4px;
    overflow: visible;
    order: 3;
  }

  .avatar-menu {
    overflow: visible;
  }

  .avatar-menu__dropdown {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    top: calc(52px + env(safe-area-inset-top));
    z-index: 10050;
  }

  .brand-row,
  .nav-tabs,
  .header-actions {
    position: static;
    transform: none;
  }

  .brand-row {
    flex: 0 0 auto;
    padding: 0;
    gap: 0;
    order: 1;
  }

  .logo,
  .logo img {
    width: 110px;
    height: 24px;
  }

  .nav-tabs {
    flex: 1 1 auto;
    min-width: 0;
    gap: clamp(6px, 2vw, 12px);
    justify-content: center;
    overflow: hidden;
    order: 2;
  }

  .nav-item,
  .nav-button {
    width: 34px;
    height: 48px;
  }

  .nav-item {
    flex: 0 0 34px;
  }

  .nav-button {
    padding-top: 4px;
  }

  .nav-button img {
    width: 23px;
    height: 23px;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 4px;
  }

  /* Esconde só o balão do tooltip; mantém os botões (mensagens, atualizar, etc.) */
  .header-actions .tooltip > [class*="tooltip-top"] {
    display: none !important;
  }

  .profile-avatar,
  .svg-wrapper[data-variant="Header/coment"] {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 480px) {
  .logo,
  .logo img {
    width: 96px;
    height: 22px;
  }

  .nav-tabs {
    gap: 4px;
  }
}

/* ==================== Área logada (≤768px) ==================== */
@media (max-width: 768px) {
  .profile-main,
  .third-profile-main {
    margin: 12px auto;
    padding: 12px max(12px, env(safe-area-inset-left)) max(20px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-right));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .profile-secondary-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .profile-secondary-left,
  #my-posts-container,
  #profile-card-container,
  #cover-banner-container,
  #profile-completion-container,
  #professions-container,
  #gallery-container {
    min-width: 0;
    max-width: 100%;
  }

  .profile-admin-shortcut__link {
    width: 100%;
    min-height: 44px;
  }

  .aviso-perfil {
    flex-direction: column;
    align-items: stretch;
  }

  .aviso-perfil .profile-completion-container {
    align-self: center;
  }

  .card-minhas-postagens .no-posts-description,
  .card-minhas-postagens .post-tip {
    width: 100%;
    max-width: 100%;
  }

  .cover-banner {
    height: clamp(140px, 38vw, 220px);
    border-radius: 12px;
  }

  .third-profile-banner {
    height: clamp(140px, 38vw, 220px);
    border-radius: 12px;
  }

  .profile-card {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 14px;
  }

  .profile-card__left {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    flex: none;
    gap: 12px;
    align-items: flex-start;
  }

  .profile-card__avatar {
    width: 96px;
    height: 96px;
  }

  .profile-card__content {
    width: 100%;
    min-width: 0;
  }

  .profile-card__columns {
    flex-direction: column;
    gap: 16px;
  }

  .profile-card__name {
    font-size: 20px;
    line-height: 26px;
  }

  .profile-card__title {
    font-size: 15px;
    line-height: 20px;
  }

  .profile-card__cta {
    min-height: 44px;
    width: auto;
    flex: 1 1 calc(50% - 8px);
  }

  .profile-card__cta + .profile-card__cta {
    margin-top: 0;
  }

  .profile-edit .abas {
    flex-direction: column;
    gap: 12px;
  }

  .profile-edit .main-content {
    min-width: 0;
    width: 100%;
  }

  .profile-edit .tabs-toolbar {
    top: calc(52px + env(safe-area-inset-top, 0px));
  }

  .profile-edit .button,
  .profile-edit .button4,
  .profile-edit .profile-edit-footer__btn {
    min-height: 44px;
  }

  .profile-edit-toast-root {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    align-items: stretch;
  }

  .profile-edit-toast-root .feedback-message {
    width: 100%;
    box-sizing: border-box;
  }

  .profile-edit .notifications-header {
    display: none;
  }

  .profile-edit .notifications-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 0;
  }

  .profile-edit .notifications-type {
    min-width: 0;
  }

  .profile-edit .notifications-channels {
    gap: 32px;
    padding-left: 28px;
  }

  .profile-edit .other-row {
    gap: 12px;
  }

  .profile-edit .text-input,
  .profile-edit .text-select,
  .profile-edit textarea {
    font-size: 16px;
  }

  .fp-collections-page {
    padding: 12px max(12px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-right));
  }

  .fp-record-page {
    padding: 16px max(12px, env(safe-area-inset-left)) max(32px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-right));
    min-height: calc(100dvh - 56px);
  }

  .feed-panel-trigger {
    min-height: 44px;
    padding: 0 16px;
  }

  .gallery-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .gallery-header h1 {
    font-size: 28px;
    line-height: 34px;
  }

  .connections-topline {
    flex-wrap: wrap;
  }

  .connections-breadcrumb {
    flex-wrap: wrap;
  }

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

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

  .post-composer-modal[aria-hidden="false"],
  .location-picker-modal[aria-hidden="false"],
  .fp-collection-modal[aria-hidden="false"] {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    align-items: flex-end;
  }

  .composer__input {
    font-size: 16px;
  }

  .composer__btn {
    min-height: 44px;
  }

  .post__actions button,
  .post__footer button {
    min-height: 40px;
  }
}

@media (max-width: 480px) {
  .profile-card__left {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .profile-card__since-block {
    align-items: center;
  }

  .profile-card__cta {
    width: 100%;
    flex: 1 1 100%;
  }

  .profile-card__settings-wrap {
    top: 10px;
    right: 10px;
  }

  .profile-edit .profile-section {
    padding: 16px;
  }

  .profile-edit .user-image-icon {
    width: 88px;
    height: 88px;
  }

  .profile-edit .user-info {
    font-size: 20px;
  }

  .profile-edit .tabs-select {
    min-height: 48px;
    font-size: 16px;
  }

  .third-profile-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .third-profile-card__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .third-profile-card__actions .third-profile-card__connect-btn,
  .third-profile-card__actions .third-profile-card__more-btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
}

/* ==================== Auth / cadastro (PWA) ==================== */
@media (max-width: 768px) {
  .signup-main,
  .signup-page .main-container,
  .renew-pass-container {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-sizing: border-box;
  }

  .signup-main input,
  .signup-main select,
  .signup-main textarea,
  .renew-pass-container input,
  .renew-pass-container select,
  .renew-pass-container textarea {
    font-size: 16px;
  }

  .breadcrumbs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  .breadcrumb-item,
  .breadcrumb-line {
    flex-shrink: 0;
  }

  .breadcrumb-circle {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    aspect-ratio: 1;
    border-radius: 50%;
  }

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

/* ==================== Base responsiva global (320–768px) ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  body {
    min-height: 100dvh;
  }

  input,
  select,
  textarea {
    font-size: max(16px, 1em);
  }

  .profile-main > *,
  .feed-layout > *,
  .feed-layout__grid > *,
  .dm-layout > *,
  .notif-layout > *,
  .connections-page > *,
  .gallery-page > *,
  .fp-collections-page > *,
  .profile-edit > * {
    min-width: 0;
    max-width: 100%;
  }

  .navbar-notif-dropdown {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: calc(100dvh - 72px - env(safe-area-inset-top));
    z-index: 10050;
  }

  .navbar-notif-dropdown__list {
    max-height: calc(100dvh - 180px - env(safe-area-inset-top));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .feed-layout {
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(32px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .post__media--carousel .post__carousel-track,
  .post__media--carousel .post__media-img {
    height: clamp(220px, 72vw, 320px);
  }

  .post-viewer__dialog {
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    transform: none;
    border-radius: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 42dvh) minmax(0, 1fr);
  }

  .post-viewer__left {
    min-height: 0;
    overflow: auto;
  }

  .post-viewer__right {
    min-height: 0;
    border-left: 0;
    border-top: 1px solid var(--gray-color-2, #e4e4e4);
  }

  .post-viewer__media {
    max-width: 100%;
    max-height: 42dvh;
  }

  .post-viewer__composer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .post-composer-modal__textarea,
  .post-composer-modal__location-input,
  .location-picker-modal__search,
  .location-picker-modal__search-input {
    font-size: 16px;
  }

  .fp-story-viewer__header {
    top: max(12px, env(safe-area-inset-top));
  }

  .fp-story-viewer__actions {
    bottom: max(20px, env(safe-area-inset-bottom));
  }

  .fp-story-viewer__media-wrap {
    max-height: calc(100dvh - 210px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .fp-record-page,
  .fp-collections-page {
    min-height: calc(100dvh - 56px);
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .flash-record-modal__stage {
    max-height: min(58dvh, calc(100dvh - 240px));
  }

  .flash-record-modal__actions,
  .fp-create-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .fp-create-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--background-color-1, #fff);
  }

  .dm-page,
  .dm-layout {
    min-height: calc(100dvh - 56px - env(safe-area-inset-top));
  }

  .dm-search input,
  .dm-composer textarea,
  .dm-modal input,
  .dm-modal textarea {
    font-size: 16px;
  }

  .dm-send-btn,
  .dm-icon-btn--sm,
  .dm-new-conv-btn,
  .dm-btn,
  .connections-back,
  .connections-pagination button {
    min-width: 44px;
    min-height: 44px;
  }

  .dm-composer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .connections-search {
    width: 100%;
    max-width: 100%;
  }

  .profile-edit .button {
    width: 100%;
    max-width: 301px;
  }

  .profile-edit input,
  .profile-edit select,
  .profile-edit textarea {
    font-size: 16px;
  }

  .card-minhas-postagens .post-tip,
  .card-minhas-postagens .no-posts-description {
    width: 100%;
    max-width: 100%;
  }

  .third-profile-name,
  .third-profile-card__name {
    overflow-wrap: anywhere;
    font-size: clamp(24px, 7vw, 40px);
  }

  .notif-modal-overlay,
  .dm-modal-overlay {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .skip-upload-switch {
    position: static;
    width: 100%;
    transform: none;
  }

  .step-content.step-professional {
    width: 100%;
    max-width: 100%;
    padding: 1.5rem 1rem;
    align-items: stretch;
  }

  .step-professional-content,
  .step-professional-info,
  .step-professional-description,
  .form-group-professional {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .step-professional-description {
    height: auto;
    overflow-wrap: anywhere;
  }

  .step-professional-info {
    align-items: stretch;
  }

  .step-professional .btn-add-profession {
    max-width: 100%;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .profession-card,
  .profession-card-text {
    min-width: 0;
    max-width: 100%;
  }

  .step-navigation {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .step-navigation__end {
    order: 2;
    width: 100%;
    margin-left: 0;
  }

  .step-navigation__start {
    order: 3;
    width: 100%;
    flex-direction: column;
  }

  .step-navigation .btn-next,
  .step-navigation .btn-submit,
  .step-navigation .btn-back,
  .step-navigation .btn-cancel {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .step-navigation .btn-back {
    order: 1;
  }

  .step-navigation .btn-cancel {
    order: 2;
  }

  .signup-content-footer {
    display: grid;
    grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
    gap: 6px 10px;
  }

  .signup-footer-center {
    grid-column: 1 / -1;
    margin: 0;
  }

  .signup-footer-left,
  .signup-footer-right {
    width: 100%;
  }

  .signup-btn-back,
  .signup-btn-accept {
    min-height: 44px;
    padding: 8px 10px;
  }

  .signup-btn-accept {
    font-size: 13px;
  }

  .signup-page .main-container,
  .signup-page .signup-main {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .signup-container,
  .multi-step-form {
    min-height: 0;
  }

  .step-navigation {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  }

  .profession-modal,
  .signup-confirm-overlay,
  .crop-modal.show {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .profession-modal {
    align-items: flex-end;
  }

  .profession-modal-box {
    width: 100%;
    max-width: 600px;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    border-radius: 16px 16px 0 0;
  }

  .profession-modal-inner {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .profession-search-input-wrap .profession-search,
  .profession-other-input {
    font-size: 16px;
  }

  .profession-options-list-wrap {
    height: auto;
    min-height: 100px;
    max-height: min(375px, calc(100dvh - 270px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    flex: 1 1 auto;
  }

  .profession-modal-footer-row {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .btn-profession-modal-cancel,
  .btn-profession-modal-confirm {
    width: 100%;
    min-height: 44px;
    text-align: center;
  }

  .signup-confirm-actions {
    flex-direction: column;
  }

  .signup-confirm-actions .signup-confirm-btn {
    width: 100%;
    justify-content: center;
  }

  .upload-area,
  .image-preview,
  .image-preview img,
  .default-user-image,
  .default-avatar {
    width: min(320px, 100%);
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .crop-modal {
    z-index: 10040;
  }

  .crop-modal-content {
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    padding: 1rem;
  }

  .cropper-container {
    width: 100%;
    max-height: min(300px, 45dvh);
  }

  .success-animation-container,
  .success-animation {
    width: min(300px, 100%);
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .step-success,
  .step-success.active {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
  }

  .success-container,
  .success-content,
  .warning-message {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .breadcrumb-circle {
    flex-basis: 32px;
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .success-animation-container,
  .success-animation {
    width: min(260px, 100%);
  }

  .success-circle::before {
    inset: -12px;
  }

  .success-circle::after {
    inset: -24px;
  }
}
