/* ── AUTH MODAL ─────────────────────────────────────────────── */
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }

/* ── GOOGLE SIGN-IN ──────────────────────────────────────────── */
.gsi-btn-wrap {
  display: flex; justify-content: center;
  margin-bottom: 4px;
}
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0 18px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-divider span {
  font-size: 0.72rem; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap;
}

/* Google complete panel */
.google-user-info {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 14px;
  background: #f8f9fa; border: 1.5px solid var(--border);
  margin-bottom: 20px;
}
.google-complete-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.google-user-details { min-width: 0; }
.google-complete-name { font-weight: 700; font-size: 0.95rem; color: var(--navy); }
.google-complete-email { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.google-hint {
  font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 20px; line-height: 1.55;
}
.auth-tab {
  flex: 1; padding: 12px; text-align: center;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: all 0.2s; background: none; border-top: none; border-left: none; border-right: none;
  font-family: 'DM Sans', sans-serif;
}
.auth-tab.active { color: var(--navy); border-bottom-color: var(--teal); }
.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* ── NAV AUTH STATE ─────────────────────────────────────────── */
.nav-user {
  display: flex; align-items: center; gap: 12px;
}
.nav-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal); color: #fff;
  font-size: 0.82rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif; cursor: pointer;
  flex-shrink: 0;
}
.nav-logout {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); padding: 6px 14px; border-radius: 100px;
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: all 0.2s;
}
.nav-logout:hover { border-color: var(--coral); color: var(--coral); }

/* ── MESSAGES NAV ICON ──────────────────────────────────────── */
.nav-messages-btn {
  position: relative; cursor: pointer;
  background: none; border: none; padding: 6px;
  color: var(--text-muted); display: flex; align-items: center;
  transition: color 0.2s;
}
.nav-messages-btn:hover { color: var(--navy); }
.nav-messages-btn svg { width: 20px; height: 20px; }
.unread-badge {
  position: absolute; top: 0; right: 0;
  background: var(--coral); color: #fff;
  border-radius: 100px; font-size: 0.65rem; font-weight: 700;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace;
}
.unread-badge.hidden { display: none; }

/* ── INBOX PANEL ────────────────────────────────────────────── */
.inbox-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(13,27,42,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.inbox-overlay.open { opacity: 1; pointer-events: all; }

.inbox-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 301;
  width: 400px; max-width: 100vw;
  background: #fff;
  box-shadow: -20px 0 60px rgba(13,27,42,0.18);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.inbox-overlay.open .inbox-panel { transform: translateX(0); }

.inbox-header {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  background: var(--navy);
}
.inbox-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem; font-weight: 900; color: #fff;
  letter-spacing: -0.3px;
}
.inbox-close {
  background: rgba(255,255,255,0.12); border: none; border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer; font-size: 0.9rem; color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.inbox-close:hover { background: rgba(255,255,255,0.22); }

.inbox-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: #fafafa;
}
.inbox-tab {
  flex: 1; padding: 13px 10px; text-align: center;
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: all 0.2s; background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: 'DM Sans', sans-serif; letter-spacing: 0.2px;
}
.inbox-tab.active { color: var(--navy); border-bottom-color: var(--teal); background: #fff; }

.inbox-list { flex: 1; overflow-y: auto; }
.inbox-list::-webkit-scrollbar { width: 3px; }
.inbox-list::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

.inbox-empty {
  padding: 56px 28px; text-align: center; color: var(--text-muted);
  font-size: 0.88rem; line-height: 1.7;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.inbox-empty::before {
  content: '✦'; font-size: 1.8rem; color: var(--teal); opacity: 0.4;
  display: block; margin-bottom: 4px;
}

/* ── CONVERSATION ITEMS ─────────────────────────────────────── */
.conversation-item {
  padding: 14px 20px; cursor: pointer;
  border-bottom: 1px solid rgba(13,27,42,0.06);
  transition: background 0.15s;
  display: flex; align-items: center; gap: 13px;
}
.conversation-item:hover { background: #f8fffe; }
.conversation-item:last-child { border-bottom: none; }

.conv-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  background-size: cover; background-position: center;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.88rem; font-weight: 700; flex-shrink: 0;
  font-family: 'Playfair Display', serif;
  box-shadow: 0 2px 8px rgba(10,191,163,0.25);
  overflow: hidden;
}
.conv-body { flex: 1; min-width: 0; }
.conv-name {
  font-size: 0.9rem; font-weight: 700; color: var(--navy);
  letter-spacing: -0.1px;
}
.conv-preview {
  font-size: 0.78rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px; line-height: 1.4;
}
.conv-connect-msg {
  font-size: 0.78rem; color: var(--teal);
  font-style: italic; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.conv-time { font-size: 0.7rem; color: #b0b8c1; font-family: 'DM Mono', monospace; }
.conv-unread {
  background: var(--teal); color: #fff;
  border-radius: 100px; font-size: 0.68rem; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace;
  box-shadow: 0 2px 6px rgba(10,191,163,0.4);
}

/* ── PENDING REQUESTS ───────────────────────────────────────── */
.pending-item {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(13,27,42,0.06);
  display: flex; align-items: center; gap: 13px;
  transition: background 0.15s;
}
.pending-item:hover { background: #f8fffe; }
.pending-item:last-child { border-bottom: none; }
.pending-item .conv-body { flex: 1; }
.pending-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-accept {
  background: var(--teal); color: #fff; border: none;
  padding: 7px 16px; border-radius: 100px;
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.1px;
}
.btn-accept:hover {
  background: var(--teal-dark);
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(10,191,163,0.35);
}
.btn-decline {
  background: none; color: var(--text-muted);
  border: 1.5px solid var(--border);
  padding: 7px 14px; border-radius: 100px;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: all 0.2s;
}
.btn-decline:hover { border-color: var(--coral); color: var(--coral); }

/* ── CHAT WINDOW ────────────────────────────────────────────── */
.chat-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(13,27,42,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.chat-overlay.open { opacity: 1; pointer-events: all; }

.chat-window {
  width: 580px; max-width: calc(100vw - 48px);
  height: 700px; max-height: calc(100vh - 48px);
  background: #fff; border-radius: 28px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 40px 100px rgba(13,27,42,0.4),
    0 8px 32px rgba(13,27,42,0.15);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(28px) scale(0.96);
  transition: transform 0.4s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.3s ease;
}
.chat-overlay.open .chat-window {
  transform: translateY(0) scale(1);
}

/* ── CHAT HEADER ────────────────────────────────────────────── */
.chat-header {
  padding: 18px 20px 18px 20px;
  display: flex; align-items: center; gap: 14px; flex-shrink: 0;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.chat-header .conv-avatar {
  width: 42px; height: 42px; font-size: 0.9rem;
  background: linear-gradient(135deg, rgba(10,191,163,0.9) 0%, rgba(8,148,131,0.9) 100%);
  color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  font-size: 1rem; font-weight: 700; color: #fff;
  letter-spacing: -0.2px; line-height: 1.2;
}
.chat-header-exam {
  font-size: 0.72rem; color: var(--teal);
  margin-top: 3px; font-weight: 600; letter-spacing: 0.4px;
  text-transform: uppercase;
}
.chat-close {
  background: rgba(255,255,255,0.1); border: none; border-radius: 50%;
  width: 34px; height: 34px; cursor: pointer; font-size: 0.9rem; color: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, color 0.2s; flex-shrink: 0;
}
.chat-close:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ── MESSAGE AREA ───────────────────────────────────────────── */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px 18px 12px;
  display: flex; flex-direction: column; gap: 2px;
  background: #F5F1EC;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(10,191,163,0.04) 0%, transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(13,27,42,0.03) 0%, transparent 60%);
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(13,27,42,0.12); border-radius: 2px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

/* ── MESSAGE ROWS & BUBBLES ─────────────────────────────────── */
.msg-row {
  display: flex; flex-direction: column;
  margin-bottom: 1px;
}
.msg-row.sent { align-items: flex-end; }
.msg-row.received { align-items: flex-start; }

/* Group spacing: tighten consecutive same-sender messages */
.msg-row + .msg-row.sent,
.msg-row.sent + .msg-row.sent { margin-top: 2px; }
.msg-row + .msg-row.received,
.msg-row.received + .msg-row.received { margin-top: 2px; }
.msg-row.sent + .msg-row.received,
.msg-row.received + .msg-row.sent { margin-top: 10px; }

.msg-bubble {
  max-width: 72%; padding: 10px 15px;
  border-radius: 20px;
  font-size: 0.92rem; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
  position: relative;
}

/* Sent — teal */
.msg-bubble.sent {
  background: var(--teal);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 8px rgba(10,191,163,0.3);
}

/* Received — white card */
.msg-bubble.received {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 6px rgba(13,27,42,0.08);
}

.msg-time {
  font-size: 0.67rem; color: #b0b8c1;
  margin: 4px 5px 6px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.2px;
}

/* ── DATE DIVIDER ───────────────────────────────────────────── */
.msg-date-divider {
  text-align: center; font-size: 0.68rem;
  color: #bbb; font-family: 'DM Mono', monospace;
  margin: 16px 0 10px; position: relative;
  display: flex; align-items: center; gap: 10px;
}
.msg-date-divider::before, .msg-date-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, #ddd 40%, #ddd 60%, transparent);
}

/* ── EMPTY CHAT STATE ───────────────────────────────────────── */
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 32px;
}
.chat-empty-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(135deg, rgba(10,191,163,0.15) 0%, rgba(10,191,163,0.05) 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--teal); opacity: 0.8;
}
.chat-empty div:last-child {
  font-size: 0.88rem; color: #b0b8c1;
  text-align: center; line-height: 1.65; max-width: 200px;
}

/* ── CHAT INPUT ROW ─────────────────────────────────────────── */
.chat-input-row {
  display: flex; gap: 10px; padding: 14px 16px;
  border-top: 1px solid rgba(13,27,42,0.07);
  flex-shrink: 0; background: #fff;
  align-items: flex-end;
}
.chat-input {
  flex: 1; padding: 11px 16px; border-radius: 20px;
  border: 1.5px solid rgba(13,27,42,0.1);
  outline: none; font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem; color: var(--text);
  background: #f8f8f8;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  resize: none; max-height: 120px; line-height: 1.5;
  overflow-y: auto;
}
.chat-input:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(10,191,163,0.1);
}
.chat-input::placeholder { color: #c0c8d0; }

.chat-send-btn {
  background: var(--teal); color: #fff; border: none;
  width: 42px; height: 42px; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  flex-shrink: 0;
}
.chat-send-btn:hover {
  background: var(--teal-dark);
  transform: scale(1.07);
  box-shadow: 0 4px 16px rgba(10,191,163,0.4);
}
.chat-send-btn:active { transform: scale(0.96); }
.chat-send-btn svg { width: 17px; height: 17px; }

/* ── TYPING INDICATOR ───────────────────────────────────────── */
.typing-dots {
  display: flex; align-items: center; gap: 5px;
  padding: 12px 16px; min-width: 52px;
}
.typing-dots span {
  display: inline-block;
  width: 7px; height: 7px;
  background: #aab4be;
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── CONNECT BUTTON STATES ──────────────────────────────────── */
.connect-btn.pending {
  background: #e8edf2; color: #94a3b8;
  cursor: default; opacity: 1;
}
.connect-btn.matched {
  background: var(--teal);
}
.connect-btn.matched:hover {
  background: var(--teal-dark);
}

/* ── MOBILE ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Inbox panel: full-width slide-in */
  .inbox-panel { width: 100vw; }

  /* Chat window: full-screen bottom sheet */
  .chat-overlay { padding: 0; align-items: flex-end; }
  .chat-window {
    width: 100vw; max-width: 100vw;
    height: 92svh; max-height: 92svh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -8px 40px rgba(13,27,42,0.25);
  }
  .chat-overlay.open .chat-window { transform: translateY(0); }

  /* Larger touch targets in chat */
  .chat-input { font-size: 1rem; padding: 13px 16px; }
  .chat-send-btn { width: 48px; height: 48px; border-radius: 14px; }

  /* Pending request buttons stack on small screens */
  .pending-actions { flex-direction: column; gap: 6px; }
  .btn-accept, .btn-decline { padding: 10px 18px; font-size: 0.82rem; }
}
