/* Media caption styling */
.media-caption {
  margin-top: 4px;
  font-size: 14px;
  color: #444;
  white-space: pre-wrap;
}
/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:      #128C7E;
  --green-dark: #075E54;
  --border:     #e9edef;
  --text:       #111b21;
  --muted:      #667781;
  --bubble-out: #d9fdd3;
  --bubble-in:  #ffffff;
  --chat-bg:    #efeae2;
  --sidebar-bg: #ffffff;
  --bg:         #f0f2f5;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

/* ── Utilities ────────────────────────────────────────────── */
.hidden  { display: none !important; }
.loading { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }
.empty   { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }
.error   { color: #e53e3e;      text-align: center; padding: 12px; font-size: 14px; }

/* ── Login page ───────────────────────────────────────────── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  width: 360px;
  text-align: center;
  box-shadow: 0 2px 20px rgba(0, 0, 0, .08);
}

.login-logo { font-size: 52px; margin-bottom: 16px; }
.login-card h1 { font-size: 22px; color: var(--green-dark); margin-bottom: 8px; }
.login-card > p { color: var(--muted); margin-bottom: 28px; font-size: 14px; }

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color .2s;
}
.login-card input:focus { border-color: var(--green); }

.login-card button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
}
.login-card button[type="submit"]:hover { background: var(--green-dark); }

#error-msg { color: #e53e3e; font-size: 13px; margin-top: 10px; display: block; }

/* ── App layout ───────────────────────────────────────────── */
body.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 360px;
  min-width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  background: var(--green-dark);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-header h2 { font-size: 18px; font-weight: 600; }
.sidebar-header button {
  background: rgba(255, 255, 255, .18);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
  margin-left: auto;
}
.sidebar-header button:hover { background: rgba(255, 255, 255, .3); }

.chat-list { flex: 1; overflow-y: auto; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.chat-item:hover  { background: #f5f6f6; }
.chat-item.active { background: #e9edef; }

.chat-avatar { font-size: 20px; flex-shrink: 0; }
.chat-info   { flex: 1; min-width: 0; }

.chat-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }

/* ── Search bars ──────────────────────────────────────────── */
.sidebar-search {
  padding: 8px 12px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-search input,
.msg-search-bar input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667781' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 10px center;
  transition: border-color .15s;
}
.sidebar-search input:focus,
.msg-search-bar input:focus { border-color: var(--green); }

.msg-search-bar {
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Search result highlight + flash animation ──────────────────── */
mark.search-highlight {
  background: #fff176;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.message.search-result {
  cursor: pointer;
}
.message.search-result:hover {
  box-shadow: 0 0 0 2px rgba(18, 140, 126, 0.4);
}

@keyframes msg-flash {
  0%, 15% { box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.75), 0 1px 2px rgba(0,0,0,.08); background: rgba(18, 140, 126, 0.12); }
  100%     { box-shadow: 0 1px 2px rgba(0,0,0,.08);                                     background: transparent; }
}
.message.message-highlight {
  animation: msg-flash 2.2s ease-out forwards;
}

/* ── Main area ────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--chat-bg);
  gap: 10px;
}
.empty-state .empty-icon { font-size: 48px; }
.empty-state p { font-size: 16px; }

.message-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.message-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  flex-shrink: 0;
}
.message-header h3 { font-size: 16px; font-weight: 600; }
.message-header span { font-size: 13px; color: var(--muted); }

/* ── Messages ─────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--chat-bg);
}

.message {
  max-width: 65%;
  padding: 7px 12px 4px;
  border-radius: 8px;
  word-wrap: break-word;
}

.message.from-them {
  align-self: flex-start;
  background: var(--bubble-in);
  border-radius: 0 8px 8px 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 3px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.message-body { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; }
.message-time {
    font-size: 11px;
    color: var(--muted);
    background: rgba(0, 0, 0, .06);
    padding: 2px 8px;
    border-radius: 9999px;
    white-space: nowrap;
}

.deleted { color: var(--muted); font-style: italic; }
.edited  { font-size: 11px; color: var(--muted); }
.mention { color: #0035ff; font-weight: 600; }
.no-body { color: var(--muted); font-style: italic; font-size: 13px; }

/* ── Quote bubble ─────────────────────────────────────────── */
.quote-bubble {
  border-left: 3px solid var(--green);
  background: rgba(0, 0, 0, .06);
  border-radius: 0 6px 6px 0;
  padding: 4px 8px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 100%;
}
.quote-sender { font-weight: 600; color: var(--green-dark); font-size: 12px; }
.quote-text   { color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }

/* ── Thread reply strips ──────────────────────────────────── */
.thread-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, .08);
}
.thread-toggle {
  background: none;
  border: none;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  line-height: 1.4;
}
.thread-toggle:hover { text-decoration: underline; }
.thread-body {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.thread-reply {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px;
  border-left: 2px solid var(--green);
  border-radius: 0 4px 4px 0;
  background: rgba(0, 0, 0, .04);
  font-size: 12.5px;
}
.thread-reply-sender { font-weight: 600; color: var(--green-dark); flex-shrink: 0; }
.thread-reply-text   { flex: 1; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.thread-reply-thumb  { height: 36px; width: 36px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.thread-reply-time   { font-size: 11px; color: var(--muted); flex-shrink: 0; background: rgba(0, 0, 0, .06); padding: 2px 6px; border-radius: 9999px; display: inline-block }

/* ── Media ────────────────────────────────────────────────── */
.media-img       { display: block; max-width: 100%; max-height: 300px; border-radius: 8px; cursor: zoom-in; }
.media-img:hover { opacity: .9; }

/* ── Lightbox ─────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 6px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
  opacity: .8;
}
.lightbox-close:hover { opacity: 1; }
.media-audio { width: 240px; margin: 2px 0; }
.media-video { max-width: 280px; max-height: 200px; border-radius: 6px; display: block; }
.media-link  { color: var(--green-dark); text-decoration: none; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.media-link:hover { text-decoration: underline; }

/* ── Load more ────────────────────────────────────────────── */
.load-more-wrap {
  text-align: center;
  padding: 10px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.scroll-bottom-wrap {
  text-align: center;
  padding: 10px;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.scroll-bottom-wrap button {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}
.scroll-bottom-wrap button:hover { background: var(--green-dark); }
.load-more-wrap button {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}
.load-more-wrap button:hover { background: var(--green-dark); }

.chat-window-toggle svg { display: none; }
.chat-window-toggle {
  background-image: url('/images/PFP.jpeg');
  background-size: cover;
  background-position: center;
  border-radius: 50% !important;
  overflow: hidden;
}

.chat-window{
  width: 500px !important
}
