/* Camada PWA/mobile. Só altera layout abaixo de 1180px e fora do Electron. */

.simochat-tabbar,
.simochat-pwa-banner,
.simochat-pwa-modal,
.chat-back-btn,
.simochat-mobile-logout {
  display: none;
}

html.simochat-pwa-banner-on {
  --simochat-pwa-banner-h: 0px;
}

.simochat-pwa-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--primary2, #2b235a);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  transform: translateY(-110%);
  transition: transform .28s ease;
}

.simochat-pwa-banner.is-visible {
  display: flex;
  transform: translateY(0);
}

.simochat-pwa-banner__icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex: none;
  object-fit: cover;
}

.simochat-pwa-banner__copy {
  flex: 1;
  min-width: 0;
}

.simochat-pwa-banner__copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.simochat-pwa-banner__copy span {
  display: block;
  font-size: 12px;
  opacity: .85;
  line-height: 1.3;
  margin-top: 2px;
}

.simochat-pwa-banner__actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.simochat-pwa-banner__actions button {
  margin: 0;
  padding: 8px 12px;
  min-height: 44px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transform: none;
}

.simochat-pwa-banner__install {
  background: #fff;
  color: var(--primary, #5b4bff);
}

.simochat-pwa-banner__dismiss {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
}

.simochat-pwa-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.simochat-pwa-modal.is-visible {
  display: flex;
}

.simochat-pwa-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 17, 28, .55);
}

.simochat-pwa-modal__card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--card, #fff);
  color: var(--text, #222);
  border-radius: 22px;
  padding: 24px 20px 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
  text-align: center;
}

.simochat-pwa-modal__icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  margin: 0 auto 12px;
  display: block;
}

.simochat-pwa-modal__card h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  line-height: 1.25;
}

.simochat-pwa-modal__lead,
.simochat-pwa-modal__hint {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted, #5c5e72);
}

.simochat-pwa-modal__hint {
  font-size: 12px;
}

.simochat-pwa-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.simochat-pwa-modal__actions button {
  width: 100%;
  min-height: 48px;
  margin: 0;
  border-radius: 12px;
  font-weight: 700;
  transform: none;
}

.simochat-pwa-modal__install {
  background: var(--primary, #5b4bff);
  color: #fff;
}

.simochat-pwa-modal__dismiss {
  background: transparent;
  color: var(--text, #222);
  border: 1px solid var(--line, #e4e4e4);
}

@media (max-width: 1179px) {
  html:not(.simochat-electron) {
    --simochat-tabbar-h: 56px;
  }

  html:not(.simochat-electron),
  html:not(.simochat-electron) body {
    height: 100%;
    overflow: hidden;
  }

  html:not(.simochat-electron) .app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    height: 100%;
    padding: 0;
  }

  html.simochat-pwa-banner-on:not(.simochat-electron) .app-shell,
  html.simochat-pwa-banner-on:not(.simochat-electron) body.auth-page {
    padding-top: var(--simochat-pwa-banner-h, 0px);
  }

  html:not(.simochat-electron) .main-sidebar {
    display: none !important;
  }

  html:not(.simochat-electron) .simochat-tabbar {
    display: flex;
    position: relative;
    order: 3;
    flex: none;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 6;
    width: 100%;
    height: var(--simochat-tabbar-h);
    padding: 0 4px;
    background: var(--card);
    border-top: 1px solid var(--line);
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
    box-sizing: border-box;
  }

  html:not(.simochat-electron) .simochat-tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    min-width: 0;
    padding: 4px 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
  }

  html:not(.simochat-electron) .simochat-tabbar a i {
    font-size: 18px;
    line-height: 1;
  }

  html:not(.simochat-electron) .simochat-tabbar a.is-active,
  html:not(.simochat-electron) .simochat-tabbar a[aria-current="page"] {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
  }

  html:not(.simochat-electron) .app-shell > main {
    order: 2;
    flex: 1 1 0%;
    align-self: stretch;
    min-width: 0;
    min-height: 0;
    width: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 0 !important;
  }

  html:not(.simochat-electron) .page-card,
  html:not(.simochat-electron) main.page-card.perfil-page,
  html:not(.simochat-electron) main.page-card.people-page {
    margin: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    border-radius: 0;
    padding: 16px 16px 20px;
    overflow: auto;
    min-height: 0;
    scrollbar-gutter: auto;
  }

  html:not(.simochat-electron) .perfil-form {
    overflow: visible;
    scrollbar-gutter: auto;
    max-width: 100%;
    width: 100%;
  }

  html:not(.simochat-electron) .people-page {
    scrollbar-gutter: auto;
  }

  html:not(.simochat-electron) .people-page-head {
    margin-bottom: 12px;
  }

  html:not(.simochat-electron) .people-page-head h1 {
    font-size: 1.35rem;
  }

  html:not(.simochat-electron) .people-page-lead {
    font-size: 13px;
  }

  html:not(.simochat-electron) .people-search {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 8px;
  }

  html:not(.simochat-electron) .people-search .search {
    min-width: 0;
    width: 100%;
  }

  html:not(.simochat-electron) .people-search button {
    width: 100%;
    min-height: 44px;
  }

  html:not(.simochat-electron) .people-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  html:not(.simochat-electron) .people-card {
    flex-direction: column;
    align-items: center;
    min-height: 0 !important;
    height: auto;
    padding: 12px 8px 10px;
    gap: 6px;
  }

  html:not(.simochat-electron) .people-card-accent {
    width: 40%;
  }

  html:not(.simochat-electron) .people-card-glow {
    display: none;
  }

  html:not(.simochat-electron) .people-card-visual {
    padding: 8px 8px 0;
  }

  html:not(.simochat-electron) .people-card-avatar {
    width: 56px;
    height: 56px;
    font-size: 18px;
    box-shadow: none;
  }

  html:not(.simochat-electron) .people-card-body {
    align-items: center;
    text-align: center;
    padding: 0 6px 4px;
    gap: 4px;
  }

  html:not(.simochat-electron) .people-card-name {
    font-size: 13px;
    -webkit-line-clamp: 2;
  }

  html:not(.simochat-electron) .people-card-meta-slot,
  html:not(.simochat-electron) .people-card-meta-slot:not(.people-card-meta-slot--empty) {
    align-items: center;
    flex: none;
    min-height: 0;
  }

  html:not(.simochat-electron) .people-card-job {
    text-align: center;
    -webkit-line-clamp: 1;
  }

  html:not(.simochat-electron) .people-card-cta-hint {
    margin-top: 2px;
    opacity: .75;
    font-size: 10px;
  }

  html:not(.simochat-electron) .chat-shell {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
  }

  html:not(.simochat-electron) .conversation-panel {
    display: flex !important;
    flex: 1 1 0%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: none !important;
    height: auto !important;
    border-right: 0;
    border-bottom: 0;
    padding: 14px 14px 10px;
  }

  html:not(.simochat-electron) .message-panel {
    flex: 1 1 0%;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: auto !important;
    display: flex;
    flex-direction: column;
  }

  html:not(.simochat-electron) .messages {
    flex: 1 1 0%;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  html:not(.simochat-electron) .composer,
  html:not(.simochat-electron) .chat-header,
  html:not(.simochat-electron) .reply-banner,
  html:not(.simochat-electron) .typing-bar,
  html:not(.simochat-electron) .composer-attach-preview {
    flex: none;
  }

  html:not(.simochat-electron) .chat-header {
    position: relative;
    z-index: 5;
    flex: none;
    padding-left: 8px;
    padding-right: 10px;
    height: auto;
    min-height: 56px;
    gap: 8px;
  }

  html:not(.simochat-electron) .message-panel.is-conv-searching .chat-subtitle {
    display: none;
  }

  html:not(.simochat-electron) .message-panel.is-conv-searching .conv-search-bar {
    max-width: 100%;
  }

  html:not(.simochat-electron) .conv-search-pop {
    position: fixed;
    top: 64px;
    left: 8px;
    right: 8px;
    width: auto;
  }

  html:not(.simochat-electron) .new-chat-modal {
    width: 100%;
    max-height: min(78dvh, 560px);
  }

  html:not(.simochat-electron) .new-chat-modal .user-pick-list {
    max-height: min(48dvh, 360px);
  }

  html:not(.simochat-electron) .new-chat-modal .user-pick-row {
    width: 100%;
    margin: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    border-radius: 12px;
    transform: none;
    box-shadow: none;
  }

  html:not(.simochat-electron) .new-chat-modal .user-pick-row:hover,
  html:not(.simochat-electron) .new-chat-modal .user-pick-row:focus {
    background: var(--bubble);
    filter: none;
    transform: none;
  }

  html:not(.simochat-electron) .chat-back-btn {
    display: none;
    flex: none;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border-radius: 12px;
    background: var(--bubble);
    color: var(--text);
    box-shadow: none;
  }

  html:not(.simochat-electron) .chat-back-btn:hover {
    transform: none;
    filter: none;
  }

  html:not(.simochat-electron) .composer {
    align-items: center;
    padding: 8px 10px !important;
    gap: 6px;
  }

  html:not(.simochat-electron) .composer-input-wrap {
    align-items: center;
  }

  html:not(.simochat-electron) .composer textarea,
  html:not(.simochat-electron) .composer-input-wrap textarea {
    min-height: 44px !important;
    max-height: 120px;
    padding: 10px 12px !important;
    line-height: 1.35;
    font-size: 16px;
    overflow-y: auto;
  }

  html:not(.simochat-electron) .composer button,
  html:not(.simochat-electron) .composer .attach-btn,
  html:not(.simochat-electron) .attach-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px !important;
    padding: 0 !important;
    flex-shrink: 0;
  }

  html:not(.simochat-electron) .quick-actions,
  html:not(.simochat-electron) .msg:hover .quick-actions,
  html:not(.simochat-electron) .msg:focus-within .quick-actions,
  html:not(.simochat-electron) .msg.msg-actions-hover .quick-actions,
  html:not(.simochat-electron) .mine .quick-actions,
  html:not(.simochat-electron) .mine:hover .quick-actions,
  html:not(.simochat-electron) .mine:focus-within .quick-actions,
  html:not(.simochat-electron) .mine.msg-actions-hover .quick-actions {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    max-width: 100% !important;
    width: 100%;
    margin: 8px 0 0 !important;
    display: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    border-radius: 14px !important;
    background: var(--card) !important;
    border: 1px solid var(--line) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--text) !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  html:not(.simochat-electron) .msg.msg-actions-hover .quick-actions,
  html:not(.simochat-electron) .msg:focus-within .quick-actions {
    display: flex !important;
  }

  html:not(.simochat-electron) .quick-actions .qa-reply,
  html:not(.simochat-electron) .mine .quick-actions .qa-reply,
  html:not(.simochat-electron) .quick-actions .qa-secondary,
  html:not(.simochat-electron) .mine .quick-actions .qa-secondary {
    color: var(--text) !important;
    background: var(--bubble) !important;
  }

  html:not(.simochat-electron) .quick-actions .qa-reply {
    color: var(--primary) !important;
  }

  html:not(.simochat-electron) .search-row {
    flex-wrap: wrap;
  }

  html:not(.simochat-electron) .search-mode {
    min-width: 0;
    flex: 1 1 100%;
  }

  html:not(.simochat-electron) .conv-item {
    min-height: 56px;
    padding: 12px 10px;
  }

  html:not(.simochat-electron) .msg {
    max-width: 92%;
  }

  html:not(.simochat-electron) .bubble,
  html:not(.simochat-electron) .attachment img,
  html:not(.simochat-electron) .table-wrap {
    max-width: 100%;
  }

  html:not(.simochat-electron) .simochat-mobile-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 12px;
    text-decoration: none;
  }

  html:not(.simochat-electron) .perfil-page .perfil-panel__grid,
  html:not(.simochat-electron) .perfil-page .perfil-notify-grid {
    grid-template-columns: 1fr;
  }

  html:not(.simochat-electron) .perfil-page .perfil-field input,
  html:not(.simochat-electron) .perfil-page .perfil-field select,
  html:not(.simochat-electron) .perfil-page .perfil-save,
  html:not(.simochat-electron) .perfil-page .perfil-avatar-btn {
    min-height: 44px;
  }

  html:not(.simochat-electron) body.auth-page {
    overflow: auto;
    min-height: 100dvh;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    align-items: start;
  }

  html:not(.simochat-electron) .auth-card {
    width: min(440px, 100%);
    margin: auto;
  }

  html:not(.simochat-electron) .auth-card input,
  html:not(.simochat-electron) .auth-card button {
    min-height: 44px;
  }

  html:not(.simochat-electron) .modal-overlay {
    padding: 12px;
    padding-bottom: calc(12px + var(--simochat-tabbar-h));
    align-items: flex-end;
  }

  html:not(.simochat-electron) .modal-card {
    width: 100%;
    max-height: min(88dvh, 720px);
  }

  html:not(.simochat-electron) .notify-permission-bar {
    flex: none;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
  }

  html:not(.simochat-electron) .notify-permission-bar-actions button {
    min-height: 44px;
  }

  html.simochat-keyboard-open:not(.simochat-electron),
  html.simochat-keyboard-open:not(.simochat-electron) body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--simochat-vvh, 100%);
    overflow: hidden;
  }

  html.simochat-keyboard-open:not(.simochat-electron) .app-shell {
    position: fixed;
    left: 0;
    right: 0;
    height: var(--simochat-vvh, 100%) !important;
    overflow: hidden;
  }

  html.simochat-keyboard-open:not(.simochat-electron) .simochat-tabbar {
    display: flex;
  }

  html.simochat-keyboard-open:not(.simochat-electron) .chat-header {
    display: flex;
    flex: none;
  }

  html.simochat-keyboard-open:not(.simochat-electron) .composer {
    padding-bottom: 8px !important;
  }

  html.simochat-keyboard-open:not(.simochat-electron) .messages {
    scroll-padding-bottom: 16px;
    padding-bottom: 16px;
  }

  html.simochat-keyboard-open:not(.simochat-electron) .modal-overlay {
    padding-bottom: 12px;
    align-items: stretch;
  }

  html.simochat-keyboard-open:not(.simochat-electron) .new-chat-modal {
    max-height: 100%;
  }
}

/* Telefone: lista OU conversa */
@media (max-width: 767px), (max-width: 1179px) and (max-height: 500px) {
  html:not(.simochat-electron) .app-shell:has(.chat-shell) .conversation-panel {
    display: flex !important;
  }

  html:not(.simochat-electron) .app-shell:has(.chat-shell) .message-panel {
    display: none;
  }

  html:not(.simochat-electron).chat-thread-open .app-shell:has(.chat-shell) .conversation-panel {
    display: none !important;
  }

  html:not(.simochat-electron).chat-thread-open .app-shell:has(.chat-shell) .message-panel {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
  }

  html:not(.simochat-electron).chat-thread-open .chat-back-btn {
    display: grid;
    place-items: center;
  }

}

/* Tablet: split lista + conversa */
@media (min-width: 768px) and (max-width: 1179px) and (min-height: 501px) {
  html:not(.simochat-electron) .chat-shell {
    display: grid !important;
    flex-direction: unset;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr);
  }

  html:not(.simochat-electron) .conversation-panel {
    display: flex !important;
    border-right: 1px solid var(--line);
    height: auto !important;
    min-height: 0;
  }

  html:not(.simochat-electron) .message-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  html:not(.simochat-electron) .chat-back-btn {
    display: none !important;
  }
}

@media (max-width: 1179px) and (display-mode: standalone),
       (max-width: 1179px) and (display-mode: fullscreen) {
  html:not(.simochat-electron) {
    --simochat-tabbar-h: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  html:not(.simochat-electron) .app-shell {
    padding-top: env(safe-area-inset-top, 0px);
  }

  html:not(.simochat-electron) .simochat-tabbar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  html:not(.simochat-electron) .skip-link {
    display: none !important;
  }

  html:not(.simochat-electron) body.auth-page {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

html.simochat-installed:not(.simochat-electron) .skip-link {
  display: none !important;
}
