/* messaging.css */
/* Stylesheet for SchoolIn messaging system, extending style.css design variables */

.messaging-page-body {
  background-color: var(--light-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Container Adjustment --- */
.messaging-container {
  flex-grow: 1;
  max-width: 1240px;
  width: 100%;
  margin: 80px auto 30px auto; /* space below sticky header */
  padding: 0 24px;
  display: flex;
  height: calc(100vh - 120px);
}

.messaging-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  transition: all 0.2s ease;
}

/* --- Left Column: Sidebar --- */
.inbox-sidebar {
  width: 25%;
  min-width: 250px;
  max-width: 320px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--white);
  flex-shrink: 0;
}

.inbox-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.inbox-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--dark-bg);
  letter-spacing: -0.01em;
}

.inbox-search {
  position: relative;
  display: flex;
  align-items: center;
}

.inbox-search svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}

.inbox-search input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  background-color: var(--light-bg);
  transition: var(--transition-fast);
}

.inbox-search input:focus {
  border-color: var(--primary);
  background-color: var(--white);
  box-shadow: 0 0 0 3px var(--border-focus);
}

/* --- Inbox Tabs Toggle --- */
.inbox-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--white);
}

.inbox-tab-btn {
  flex-grow: 1;
  border: none;
  background: none;
  padding: 14px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.inbox-tab-btn:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

.inbox-tab-btn.active {
  color: var(--primary);
}

.inbox-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: var(--primary);
}

.request-badge {
  background-color: #EF4444;
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

/* --- Conversations List --- */
.conversation-list {
  flex-grow: 1;
  overflow-y: auto;
}

.list-loading {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.list-loading p {
  margin-top: 10px;
  font-size: 0.88rem;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.conversation-item:hover {
  background-color: var(--light-bg);
}

.conversation-item.active {
  background-color: var(--primary-light);
}

/* Unread dot style */
.unread-dot-indicator {
  width: 8px;
  height: 8px;
  background-color: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 8px;
}

.conversation-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid rgba(0,0,0,0.05);
}

.conversation-info {
  flex-grow: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1px;
}

.conversation-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--dark-bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

.conversation-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.conversation-last-msg {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.unread .conversation-last-msg {
  font-weight: 700;
  color: var(--dark-bg);
}

.conversation-badges-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.category-card-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.category-card-badge.admission {
  background-color: #FEF2F2;
  color: #EF4444;
  border: 1.5px solid rgba(239, 68, 68, 0.1);
}

.category-card-badge.event {
  background-color: #FFFBEB;
  color: #D97706;
  border: 1.5px solid rgba(217, 119, 6, 0.1);
}

.category-card-badge.networking {
  background-color: #EFF6FF;
  color: #2563EB;
  border: 1.5px solid rgba(37, 99, 235, 0.1);
}

.category-card-badge.mentorship {
  background-color: #F5F3FF;
  color: #7C3AED;
  border: 1.5px solid rgba(124, 58, 237, 0.1);
}

.status-badge-sent {
  font-size: 0.65rem;
  background-color: #F8FAFC;
  color: #64748B;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.list-empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
}

.list-empty-state span {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 8px;
}

/* --- Right Column: Chat Viewport --- */
.chat-viewport {
  background-color: var(--white);
  height: 100%;
  position: relative;
  flex-grow: 1;
  width: 75%;
  transition: width 0.2s ease;
  display: flex;
  flex-direction: column;
}

.messaging-card.profile-panel-open .chat-viewport {
  width: 50%;
}

/* Empty View */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
}

.empty-illustration {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.85;
}

.chat-empty-state h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--dark-bg);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.chat-empty-state p {
  color: var(--text-muted);
  max-width: 420px;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Active Chat View */
.chat-active-interface {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 14px;
  background-color: var(--white);
}

.btn-chat-back {
  display: none; /* Desktop hidden */
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

.btn-chat-back:hover {
  color: var(--primary);
}

.chat-recipient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid rgba(0,0,0,0.05);
}

.chat-recipient-info {
  flex-grow: 1;
}

.chat-recipient-info h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--dark-bg);
  margin-bottom: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-recipient-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggle profile button */
.btn-toggle-profile {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-toggle-profile:hover {
  background-color: var(--light-bg);
  color: var(--primary);
}

/* Message Requests Overlay Bar */
.message-request-bar {
  background-color: var(--primary-light);
  border-bottom: 1px solid rgba(0, 102, 200, 0.1);
  padding: 12px 24px;
}

.request-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.request-bar-content p {
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 600;
}

.request-actions {
  display: flex;
  gap: 8px;
}

.request-actions .btn {
  padding: 6px 14px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  height: auto;
}

/* Message History Board */
.message-history {
  flex-grow: 1;
  min-height: 0; /* Prevents overflow pushing the input panel off-screen */
  padding: 24px;
  overflow-y: auto;
  background-color: var(--light-bg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message-date-separator {
  text-align: center;
  margin: 12px 0;
  position: relative;
}

.message-date-separator::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background-color: var(--border-color);
  z-index: 1;
}

.message-date-separator span {
  background-color: var(--light-bg);
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  position: relative;
  z-index: 2;
  border-radius: var(--radius-full);
}

.message-bubble-row {
  display: flex;
  margin-bottom: 4px;
}

.message-bubble-row.sent {
  justify-content: flex-end;
}

.message-bubble-row.received {
  justify-content: flex-start;
}

.message-bubble-wrapper {
  max-width: 65%;
  display: flex;
  flex-direction: column;
}

.message-bubble {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
}

.message-bubble-row.sent .message-bubble {
  background: var(--primary);
  color: var(--white);
  border-bottom-right-radius: 2px;
  box-shadow: var(--shadow-sm);
}

.message-bubble-row.received .message-bubble {
  background-color: var(--white);
  color: var(--dark-bg);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.message-time-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-bubble-row.sent .message-time-meta {
  justify-content: flex-end;
}

.read-status-indicator {
  display: inline-flex;
  align-items: center;
}

.read-status-indicator svg {
  color: var(--text-muted);
}

.read-status-indicator.read svg {
  color: var(--accent);
}

/* Message Input Panel */
.chat-input-panel {
  padding: 16px 24px;
  background-color: var(--white);
  border-top: 1px solid var(--border-color);
}

.chat-input-panel textarea {
  flex-grow: 1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.92rem;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  transition: var(--transition-fast);
}

.chat-input-panel textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

.chat-input-panel .btn-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Verified badges gold and general styling */
.verified-badge {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--primary);
  vertical-align: middle;
}

.verified-badge.gold {
  color: #D97706 !important;
}

/* --- Right-side Profile Panel --- */
.chat-profile-panel {
  width: 25%;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  background-color: var(--white);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: opacity 0.2s ease;
}

.panel-header-close {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}

.btn-panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: var(--transition-fast);
}

.btn-panel-close:hover {
  color: var(--dark-bg);
}

.panel-content-scroll {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
}

.panel-identity-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.panel-user-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 2px solid var(--border-color);
}

.panel-user-avatar-letter {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
}

.panel-school-logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border-color);
}

.panel-school-logo-letter {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
}

.panel-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
  line-height: 1.25;
}

.panel-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-details-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-color: var(--light-bg);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  text-align: left;
}

.panel-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 0.88rem;
  color: var(--dark-bg);
  font-weight: 600;
}

.panel-actions-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-align: center;
}

/* --- Responsive Adaptations --- */
@media (max-width: 900px) {
  /* ── 1. Reduce top gap: messaging card starts closer to header ── */
  body.messaging-page-body {
    padding-top: 52px !important;
  }

  .messaging-container {
    padding: 0 !important;
    margin-top: 0 !important;    /* align directly below header */
    margin-bottom: 0 !important;
    height: calc(100vh - 52px) !important;
    height: calc(100dvh - 52px) !important;
    border-radius: 0 !important;
  }

  .messaging-card {
    flex-direction: column;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    height: 100%;
  }

  /* ── 2. Inbox: full-width stacked layout ── */
  .inbox-sidebar, .chat-viewport, .chat-profile-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Default: show inbox, hide chat pane */
  .inbox-sidebar {
    display: flex;
    height: 100% !important;
  }

  .chat-viewport {
    display: none;
  }

  .chat-profile-panel {
    display: none !important;
  }

  /* ── 3. Chat-Open mode: full-screen immersive experience ── */
  /* Hide global top header */
  body:has(.messaging-card.chat-open) header {
    display: none !important;
  }

  /* Hide ALL bottom navigation (both old and new mobile nav) */
  body:has(.messaging-card.chat-open) .mobile-bottom-nav,
  body:has(.messaging-card.chat-open) .global-mobile-nav {
    display: none !important;
  }

  /* Remove body top padding so chat fills edge-to-edge */
  body:has(.messaging-card.chat-open) {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* Container fills full viewport when chat is open */
  .messaging-container:has(.messaging-card.chat-open) {
    margin-top: 0 !important;
    height: 100dvh !important;      /* dynamic viewport height for mobile browsers */
    padding: 0 !important;
    max-width: 100% !important;
  }

  /* Chat viewport takes full screen */
  .messaging-card.chat-open .inbox-sidebar {
    display: none;
  }

  .messaging-card.chat-open .chat-viewport {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 10;
  }

  /* ── 4. Compact conversation list items ── */
  .conversation-item {
    padding: 10px 14px !important;
    gap: 10px !important;
  }

  .conversation-avatar {
    width: 40px !important;
    height: 40px !important;
    font-size: 0.9rem !important;
  }

  .conversation-name {
    font-size: 0.85rem !important;
  }

  .conversation-time {
    font-size: 0.68rem !important;
  }

  .conversation-last-msg {
    font-size: 0.78rem !important;
  }

  .category-card-badge {
    font-size: 0.65rem !important;
    padding: 1px 6px !important;
  }

  /* ── 5. Compact chat header with back button ── */
  .chat-header {
    padding: 0 12px !important;
    gap: 10px !important;
    height: 56px !important;
    min-height: 56px !important;
    flex-shrink: 0 !important;
    border-bottom: 1px solid var(--border-color) !important;
    background: var(--white) !important;
    /* Safe area top on notched phones */
    padding-top: env(safe-area-inset-top, 0px) !important;
  }

  /* Back arrow: visible and properly sized */
  .btn-chat-back {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    margin-left: -6px !important;
    color: var(--text-main) !important;
    transition: background-color 0.15s ease !important;
  }

  .btn-chat-back:hover,
  .btn-chat-back:active {
    background-color: rgba(15, 23, 42, 0.06) !important;
    color: var(--primary) !important;
  }

  .btn-chat-back svg {
    width: 20px !important;
    height: 20px !important;
    stroke-width: 2.2 !important;
  }

  /* Chat recipient avatar: compact */
  .chat-recipient-avatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.88rem !important;
    flex-shrink: 0 !important;
  }

  /* Recipient name and headline */
  .chat-recipient-info {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .chat-recipient-info h4 {
    font-size: 0.92rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .chat-recipient-info p {
    font-size: 0.7rem !important;
    max-width: none !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Header actions: compact icon buttons */
  .chat-header-actions {
    flex-shrink: 0 !important;
    gap: 4px !important;
  }

  .btn-toggle-profile {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
  }

  /* ── 6. Optimised message viewport: maximise conversation area ── */
  .chat-active-interface {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
  }

  .message-history {
    flex: 1 !important;
    min-height: 0 !important;
    padding: 12px 10px !important;
    gap: 8px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .message-bubble-wrapper {
    max-width: 82% !important;
  }

  .message-bubble {
    padding: 8px 12px !important;
    font-size: 0.88rem !important;
    line-height: 1.4 !important;
  }

  .message-time-meta {
    font-size: 0.65rem !important;
  }

  /* ── 7. Message composer: full-width, safe-area aware ── */
  .chat-input-panel {
    flex-shrink: 0 !important;
    padding: 8px 12px !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--white) !important;
    border-top: 1px solid var(--border-color) !important;
  }

  #chat-send-form {
    display: flex !important;
    gap: 8px !important;
    align-items: flex-end !important;
    width: 100% !important;
  }

  .chat-input-panel textarea {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 10px 14px !important;
    font-size: 0.9rem !important;
    border-radius: 22px !important;
    max-height: 100px !important;
    resize: none !important;
    line-height: 1.4 !important;
  }

  .chat-input-panel .btn-icon {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ── 8. Message request bar: compact ── */
  .message-request-bar {
    padding: 8px 12px !important;
    flex-shrink: 0 !important;
  }

  .request-bar-content {
    gap: 8px !important;
  }

  .request-bar-content p {
    font-size: 0.82rem !important;
  }

  .request-actions .btn {
    font-size: 0.75rem !important;
    padding: 5px 12px !important;
  }

  /* ── Inbox header: tighten spacing ── */
  .inbox-header {
    padding: 12px 16px !important;
  }

  .inbox-header h3 {
    font-size: 1.1rem !important;
    margin-bottom: 10px !important;
  }

  .inbox-tab-btn {
    padding: 10px !important;
    font-size: 0.82rem !important;
  }
}

/* ── Extra compact at 375px and below ── */
@media (max-width: 375px) {
  .chat-header {
    height: 52px !important;
    min-height: 52px !important;
    padding: 0 8px !important;
  }

  .btn-chat-back svg {
    width: 18px !important;
    height: 18px !important;
  }

  .chat-recipient-avatar {
    width: 32px !important;
    height: 32px !important;
  }

  .chat-recipient-info h4 {
    font-size: 0.85rem !important;
  }

  .chat-recipient-info p {
    font-size: 0.65rem !important;
  }

  .message-history {
    padding: 8px !important;
  }

  .chat-input-panel {
    padding: 6px 8px !important;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .chat-input-panel textarea {
    font-size: 0.85rem !important;
    padding: 8px 12px !important;
  }
}

/* ── 320px: smallest phone support ── */
@media (max-width: 320px) {
  .chat-header {
    height: 48px !important;
    min-height: 48px !important;
    gap: 6px !important;
  }

  .chat-recipient-avatar {
    width: 28px !important;
    height: 28px !important;
  }

  .message-bubble {
    font-size: 0.82rem !important;
    padding: 6px 10px !important;
  }

  .message-bubble-wrapper {
    max-width: 88% !important;
  }

  .chat-input-panel .btn-icon {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
  }
}

/* ── Mobile-only layout tweaks below 768px ── */
@media (max-width: 768px) {
  body.messaging-page-body {
    padding-top: 60px !important; /* matches mobile header height (60px) in style.css */
  }

  .messaging-container {
    margin-top: 0 !important;
    height: calc(100vh - 60px) !important;
    height: calc(100dvh - 60px) !important;
  }

  /* Remove duplicate "Messaging" page title and tighten header spacing */
  .inbox-header {
    padding: 8px 12px !important;
  }

  .inbox-header h3 {
    display: none !important;
  }

  /* Remove "Messaging" text label from the top mobile header */
  #nav-messaging-link span {
    display: none !important;
  }

  /* Compact tabs and list items to show more conversations above the fold */
  .inbox-tab-btn {
    padding: 8px 10px !important;
  }

  .conversation-item {
    padding: 8px 12px !important;
    gap: 8px !important;
  }

  .conversation-avatar {
    width: 36px !important;
    height: 36px !important;
  }
}
