/* ═══ MESSENGER LAYOUT ═══ */

/* Scope body changes to messenger page if possible, or just apply them globally if they don't break things.
   For now, we'll assume the messenger page will have a specific class on body or just use these styles. */

.msg-page-body {
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--bg) !important;
}

.msg-page-body .nav {
  flex: 0 0 auto !important;
  position: relative !important;
}

.msg-page-body .nav-inner {
  max-width: 1400px !important;
}

.msg-page-body main[role="main"] {
  flex: 1 1 0% !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
}

.msg-page-body footer.footer {
  display: none !important;
}

.msg {
  flex: 1 1 0%;
  display: flex;
  background: var(--bg);
  overflow: hidden;
  min-height: 0px;
  position: relative;
}

/* ═══ SIDEBAR ═══ */
.msg-sidebar {
  width: 360px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0px;
}

.msg-sidebar-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
}

.msg-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.024em;
  margin: 0px;
  color: var(--ink);
}

.msg-search {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.msg-search-icon {
  width: 14px;
  height: 14px;
  color: var(--ink-3);
  flex-shrink: 0;
  transition: color 0.2s var(--ease);
}

.msg-search:focus-within .msg-search-icon {
  color: var(--ink-2);
}

.msg-search-input {
  flex: 1 1 0%;
  padding: 4px 0px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  letter-spacing: -0.005em;
  min-width: 0px;
}

.msg-search-input::placeholder {
  color: var(--ink-3);
}

.msg-list {
  flex: 1 1 0%;
  overflow-y: auto;
  padding: 8px 12px 16px;
  min-height: 0px;
}

.msg-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  border: 1px solid transparent;
  text-decoration: none;
  color: inherit;
}

.msg-item:hover {
  background: var(--section-bg);
}

.msg-item.is-active {
  background: var(--muted-tint);
}

.msg-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--muted-tint);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.msg-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.msg-item-avatar.is-system {
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.msg-item-avatar-mark {
  width: 22px;
  height: 22px;
  color: white;
}

.msg-item-body {
  flex: 1 1 0%;
  min-width: 0px;
}

.msg-item-row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.msg-item-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-item-time {
  font-size: 11.5px;
  color: var(--ink-3);
  flex-shrink: 0;
  letter-spacing: 0.005em;
}

.msg-item-row3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.msg-item-last {
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 0%;
}

.msg-item-status {
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: -0.005em;
  flex: 1 1 0%;
}

.msg-item.is-incoming .msg-item-status {
  color: var(--ink);
  font-weight: 500;
}

.msg-item-dot {
  width: 7px;
  height: 7px;
  background: var(--ink);
  border-radius: 50%;
  flex-shrink: 0;
}

.msg-item.is-unread .msg-item-last {
  color: var(--ink);
  font-weight: 500;
}

/* ═══ THREAD ═══ */
.msg-thread {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  background: white;
  min-height: 0px;
}

.msg-thread-header {
  flex: 0 0 auto;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: white;
}

.msg-thread-header-inner {
  max-width: 940px;
  margin: 0px auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.msg-back {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease);
}

.msg-back:hover {
  background: var(--muted-tint);
}

.msg-back svg {
  width: 18px;
  height: 18px;
}

.msg-thread-info {
  flex: 1 1 0%;
  min-width: 0px;
}

.msg-thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--muted-tint);
  overflow: hidden;
  flex-shrink: 0;
}

.msg-thread-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.msg-thread-name {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.014em;
  line-height: 1.25;
}

.msg-thread-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--moss);
  flex-shrink: 0;
}

.msg-thread-badge svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.msg-thread-sub {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: -0.003em;
  margin-top: 2px;
  line-height: 1.3;
}

.msg-thread-links {
  margin-top: 4px;
  font-size: 11.5px;
  letter-spacing: -0.003em;
  line-height: 1.4;
}

.msg-thread-links a {
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

.msg-thread-links a:hover {
  color: var(--ink);
}

.msg-thread-links-sep {
  margin: 0px 6px;
  color: var(--border-2);
}

.msg-thread-body {
  flex: 1 1 0%;
  overflow-y: auto;
  padding: 24px 24px 12px;
  min-height: 0px;
}

.msg-thread-body-inner {
  max-width: 940px;
  margin: 0px auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-context {
  align-self: stretch;
  background: var(--section-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 28px;
}

.msg-context-eyebrow {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.msg-context-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.012em;
  line-height: 1.35;
}

.msg-context-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: -0.005em;
}

.msg-context-detail {
  color: var(--ink-2);
}

.msg-context-meta-sep {
  color: var(--border-2);
}

.msg-context-cta {
  display: inline-block;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  margin-top: 8px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--border-2);
  transition: border-color 0.2s var(--ease);
}

.msg-context-meta .msg-context-cta {
  margin-top: 0px;
}

.msg-context-cta:hover {
  border-bottom-color: var(--ink);
}

.msg-bubble + .msg-context {
  margin-top: 36px;
}

.msg-bubble {
  max-width: 680px;
  padding: 12px 16px;
  border-radius: 22px;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  overflow-wrap: break-word;
}

.msg-bubble-in {
  background: var(--muted-tint);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 8px;
}

.msg-bubble-out {
  background: rgb(21, 21, 21);
  color: rgba(255, 255, 255, 0.96);
  align-self: flex-end;
  border-bottom-right-radius: 8px;
}

.msg-bubble-in + .msg-bubble-in {
  margin-top: 2px;
  border-top-left-radius: 8px;
}

.msg-bubble-in + .msg-bubble-in:last-child:not(:only-child),
.msg-bubble-in + .msg-bubble-in + .msg-bubble-in {
  border-bottom-left-radius: 22px;
}

.msg-bubble-out + .msg-bubble-out {
  margin-top: 2px;
  border-top-right-radius: 8px;
}

.msg-bubble-in + .msg-bubble-out,
.msg-bubble-out + .msg-bubble-in {
  margin-top: 14px;
}

.msg-system-line {
  align-self: center;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: -0.003em;
  margin: 16px 0px 12px;
  padding: 4px 12px;
  line-height: 1.4;
}

.msg-timestamp {
  align-self: center;
  text-align: center;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.005em;
  margin: 14px 0px 6px;
  padding: 0px 12px;
  line-height: 1.4;
}

.msg-timestamp strong {
  font-weight: 600;
  color: var(--ink-2);
  margin-right: 2px;
}

.msg-timestamp + .msg-bubble {
  margin-top: 2px;
}

/* ═══ COMPOSER ═══ */
.msg-composer {
  flex: 0 0 auto;
  padding: 16px 24px 20px;
  background: white;
  border-top: 1px solid var(--border);
}

.msg-composer-inner {
  max-width: 940px;
  margin: 0px auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-attach {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: white;
  cursor: pointer;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.msg-attach:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.msg-attach svg {
  width: 14px;
  height: 14px;
}

.msg-input {
  flex: 1 1 0%;
  padding: 9px 16px;
  font-size: 14px;
  font-family: inherit;
  background: var(--section-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  letter-spacing: -0.005em;
  color: var(--ink);
  min-width: 0px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.msg-input:focus {
  border-color: var(--ink-3);
  background: white;
}

.msg-input::placeholder {
  color: var(--ink-3);
}

.msg-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}

.msg-send:hover {
  background: rgb(26, 26, 26);
}

.msg-send:active {
  transform: scale(0.95);
}

.msg-send svg {
  width: 14px;
  height: 14px;
}

/* ═══ REQUEST & STATUS ═══ */
.msg-request-status {
  background: var(--section-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.msg-request-status-eyebrow {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.msg-request-status-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.012em;
  line-height: 1.35;
}

.msg-request-message-block {
  margin-top: 4px;
}

.msg-request-message-label {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.msg-request-message-card {
  padding: 16px 20px;
  background: var(--muted-tint);
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.msg-request-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: flex-end;
  padding: 2px 0px;
}

.msg-composer.is-locked .msg-composer-inner,
.msg-composer.is-actions .msg-composer-inner {
  justify-content: flex-end;
}

.msg-locked-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: -0.005em;
  line-height: 1.45;
  padding: 8px 4px;
}

.msg-locked-banner svg {
  width: 15px;
  height: 15px;
  color: var(--ink-3);
  flex-shrink: 0;
}

.msg-btn-primary,
.msg-btn-secondary {
  padding: 10px 20px;
  border-radius: 0.75rem;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.msg-btn-primary {
  background: var(--ink);
  color: white;
  border: 1px solid var(--ink);
}

.msg-btn-primary:hover {
  background: rgb(26, 26, 26);
  border-color: rgb(26, 26, 26);
}

.msg-btn-secondary {
  background: white;
  color: var(--ink-2);
  border: 1px solid var(--border-2);
}

.msg-btn-secondary:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

/* ═══ OVERFLOW MENU ═══ */
.msg-overflow-wrap {
  position: relative;
  flex-shrink: 0;
}

.msg-overflow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.msg-overflow:hover {
  background: var(--muted-tint);
  color: var(--ink);
}

.msg-overflow svg {
  width: 18px;
  height: 18px;
}

.msg-overflow-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0px;
  width: 220px;
  background: white;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 4px;
  box-shadow: rgba(20, 25, 40, 0.04) 0px 1px 2px, rgba(20, 25, 40, 0.1) 0px 12px 32px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.97);
  transform-origin: right top;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0.18s;
}

.msg-overflow-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0px) scale(1);
}

.msg-overflow-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: -0.005em;
  transition: background 0.15s var(--ease);
}

.msg-overflow-item:hover {
  background: var(--muted-tint);
}

/* ═══ MODALS ═══ */
.req-modal-backdrop,
.profile-modal-backdrop,
.confirm-modal-backdrop {
  position: fixed;
  inset: 0px;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(24px) saturate(140%);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s var(--ease), visibility 0.28s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.req-modal-backdrop.is-open,
.profile-modal-backdrop.is-open,
.confirm-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.req-modal-card,
.profile-modal-card,
.confirm-modal-card {
  background: white;
  border-radius: 22px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: rgba(20, 25, 40, 0.05) 0px 1px 2px, rgba(20, 25, 40, 0.18) 0px 24px 60px;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.4s var(--ease);
  position: relative;
}

.req-modal-backdrop.is-open .req-modal-card,
.profile-modal-backdrop.is-open .profile-modal-card,
.confirm-modal-backdrop.is-open .confirm-modal-card {
  transform: translateY(0px) scale(1);
}

.req-modal-close,
.profile-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.req-modal-close:hover,
.profile-modal-close:hover {
  background: var(--muted-tint);
  color: var(--ink);
}

.req-modal-close svg,
.profile-modal-close svg {
  width: 14px;
  height: 14px;
}

.req-modal-eyebrow {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.req-modal-title {
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.024em;
  margin: 0px;
  line-height: 1.2;
}

.req-modal-sub {
  font-size: 13px;
  color: var(--ink-2);
  margin: 4px 0px 0px;
  letter-spacing: -0.005em;
}

.req-modal-form {
  margin-top: 24px;
}

.req-modal-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: -0.003em;
  margin-bottom: 8px;
}

.req-modal-textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--section-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  resize: vertical;
  letter-spacing: -0.005em;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.req-modal-textarea:focus {
  border-color: var(--ink-3);
  background: white;
}

.req-modal-textarea::placeholder {
  color: var(--ink-3);
}

.req-modal-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

.req-modal-footnote {
  margin: 16px 0px 0px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.5;
  letter-spacing: -0.003em;
  text-align: center;
}

/* ═══ MEDIA QUERIES ═══ */
@media (max-width: 768px) {
  .msg-sidebar {
    width: 100%;
    border-right: none;
  }
  .msg-thread {
    position: absolute;
    inset: 0px;
    transform: translateX(100%);
    transition: transform 0.3s var(--ease);
    background: white;
    z-index: 10;
  }
  .msg.is-conversation-open .msg-thread {
    transform: translateX(0px);
  }
  .msg-back {
    display: inline-flex;
  }
  .msg-thread-header {
    padding: 14px 18px;
  }
  .msg-thread-body {
    padding: 20px 18px 8px;
  }
  .msg-composer {
    padding: 12px 16px 14px;
  }
  .msg-bubble {
    max-width: 85%;
  }
  .msg-context {
    padding: 14px 16px;
    margin-bottom: 22px;
  }
}

/* ── Small phones (≤ 480px) ── */
@media (max-width: 480px) {
  .msg-sidebar-header {
    padding: 18px 16px 12px;
  }

  .msg-title {
    font-size: 19px;
  }

  .msg-search {
    padding: 10px 16px 12px;
  }

  .msg-list {
    padding: 6px 8px 12px;
  }

  .msg-item {
    padding: 10px;
    gap: 10px;
  }

  .msg-item-avatar {
    width: 36px;
    height: 36px;
  }

  .msg-item-name {
    font-size: 13px;
  }

  .msg-item-last,
  .msg-item-status {
    font-size: 12px;
  }

  .msg-bubble {
    max-width: 90%;
    padding: 10px 14px;
    font-size: 13.5px;
  }

  .msg-thread-name {
    font-size: 14px;
  }

  .msg-thread-sub {
    font-size: 11px;
  }

  .msg-composer {
    padding: 10px 12px 12px;
  }

  .msg-input {
    padding: 8px 14px;
    font-size: 13px;
  }

  .msg-attach,
  .msg-send {
    width: 34px;
    height: 34px;
  }

  /* Modals — bottom sheet style on phones */
  .req-modal-backdrop,
  .profile-modal-backdrop,
  .confirm-modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .req-modal-card,
  .profile-modal-card,
  .confirm-modal-card {
    border-radius: 22px 22px 0 0;
    padding: 24px 20px;
    max-width: none;
  }

  .req-modal-title {
    font-size: 19px;
  }

  .req-modal-textarea {
    min-height: 100px;
  }

  .msg-request-actions {
    flex-direction: column;
    gap: 8px;
  }

  .msg-btn-primary,
  .msg-btn-secondary {
    width: 100%;
    justify-content: center;
    text-align: center;
    display: flex;
  }
}
