/* =========================
   NursingUnity – Chat (full CSS)
   ========================= */
:root{
  --bg: #000000;
  --bg-1: #021317;
  --bg-2: #0b1e29;
  --panel: #11242e;
  --brand: #49c2f2;
  --brand-2: #bce9fa;
  --text: #f5f5f5;
  --text-strong: #ffffff;
  --border: rgba(73,194,242,.75);
  --border-soft: rgba(73,194,242,.35);
  --radius: 12px;
  --shadow: 0 0 12px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

/* ===== Top nav (same theme as Connect) ===== */
.nav-header {
  background-color: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-bottom: 2px solid var(--brand);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo-title.brand-block{ display:flex; align-items:center; gap:clamp(6px,1.2vw,12px); margin-left:clamp(8px,2vw,50px); }
.site-logo{ height: clamp(36px, 5.5vw, 60px); width: auto; object-fit: contain; }
.site-name{ font-weight: 800; color: var(--text-strong); font-size: clamp(1.25rem,3.2vw,2rem); }
.nav-header nav ul{ display:flex; flex-wrap:wrap; align-items:center; gap:1.25rem; list-style:none; margin:0; padding:0; }
.nav-header nav a{ color: var(--brand); text-decoration:none; font-size:1rem; padding:.5rem; border-radius:6px; }
.nav-header nav a:hover, .nav-header nav a.active{ background:rgba(73,194,242,.1); }

/* Optional banner like Connect */
.breakroom-banner{
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(73,194,242,.08), transparent);
  padding: 18px clamp(1rem, 3vw, 2rem);
}
.breakroom-title{ margin:0 0 6px; color: var(--text-strong); }
.breakroom-subtitle{ margin:0; color: var(--brand-2); }

/* ===== Layout ===== */
.chat-app { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 60px); }
.chat-sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border-soft);
  background: var(--bg-2);
}

/* Make the top search area stick and the conversations scroll */
.sidebar-section { padding: 14px; border-bottom: 1px solid var(--border-soft); }
.search-section { position: sticky; top: 0; background: var(--bg-2); z-index: 2; }
.conversations-section { flex: 1; overflow: auto; }

.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#user-search {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--bg-1);
  color: var(--text);
  outline: none;
}
#user-search:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(73,194,242,.25); }

#search-btn {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
#search-btn:hover { outline: 1px solid var(--border); }

/* Search results must always be visible + scrollable */
.search-results {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  max-height: 42vh;               /* stays under the banner */
  overflow-y: auto;
  padding-right: 4px;
}

.search-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
}
.search-item:hover { outline: 1px solid var(--border); }
.search-item img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #0a0a0a; }
.handle { color: var(--text-strong); font-weight: 600; }
.subtle { color: var(--brand-2); font-size: 12px; }

.conversations-section h2 { margin: 0 0 8px; font-size: 14px; color: var(--brand-2); font-weight: 600; }
.conversation-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.conversation-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px; align-items: center;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--bg-1);
  cursor: pointer;
}
.conversation-item:hover { outline: 1px solid var(--border); }
.conversation-item img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.conv-meta { display: grid; gap: 2px; }
.conv-username { font-weight: 600; color: var(--text-strong); }
.conv-last { color: var(--brand-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--brand-2); }

.chat-main { display: flex; flex-direction: column; height: 100%; }
.empty-state { margin: auto; text-align: center; color: var(--brand-2); }

/* ===== Thread ===== */
.chat-thread { display: grid; grid-template-rows: auto 1fr auto auto; height: 100%; }
.thread-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); background: var(--bg-1); }
.peer-info { display: flex; gap: 12px; align-items: center; }
.peer-avatar { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #0a0a0a; }
.peer-username { font-weight: 700; color: var(--text-strong); }
.peer-role { font-size: 12px; color: var(--brand-2); }
.thread-actions { display: flex; gap: 8px; }
.btn-outline { background: transparent; border: 1px solid var(--border-soft); color: var(--text); padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.btn-outline.danger { border-color: rgba(255, 99, 99, .55); color: #ff9f9f; }
.btn-primary { background: var(--brand); color: #00151b; border: none; padding: 10px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.hidden { display: none !important; }

/* ===== Messages – modern bubbles, attachments, progress ===== */

/* container */
#message-list{
  display:flex; flex-direction:column; gap:10px;
  padding: 18px 20px 140px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  scroll-behavior: smooth;
}

/* base bubble */
.message{
  display:flex; flex-direction:column; align-self:flex-start;
  max-width:min(70%, 560px);
  line-height: 1.35;
  animation: chat-pop .12s ease-out;
}
.message.me{ align-self:flex-end; align-items:flex-end; }

/* bubble visuals */
.message .text{
  position: relative;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  word-break: break-word;
}
.message.me .text{
  background: linear-gradient(180deg, rgba(73,194,242,.35), rgba(73,194,242,.18));
  border-color: var(--border);
  color: var(--text-strong);
}

/* tails */
.message .text::after, .message.me .text::after{
  content:""; position:absolute; bottom:-4px; width:10px; height:10px;
  background: inherit; border: inherit; transform: rotate(45deg);
}
.message .text::after{ left:12px; border-top-color:transparent; border-left-color:transparent; }
.message.me .text::after{ right:12px; border-top-color:transparent; border-right-color:transparent; }

/* meta line */
.message .meta{
  margin-top: 4px;
  font-size: 12px;
  color: rgba(188,233,250,.7);
}
.message.me .meta{ color: rgba(255,255,255,.75); text-align: right; }

/* grouping consecutive messages */
.message.continued{ margin-top: -2px; }
.message.continued .text{ border-top-left-radius: 10px; }
.message.me.continued .text{ border-top-right-radius: 10px; }
.message.continued .text::after{ display:none; }

/* attachments */
.bubble-image{
  display:block; border-radius:14px; max-width:100%; height:auto;
  border:1px solid var(--border-soft);
}
.image-grid{ display:grid; gap:8px; }
.image-grid.cols-1{ grid-template-columns: 1fr; }
.image-grid.cols-2{ grid-template-columns: 1fr 1fr; }

.file-chip{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border-radius:12px;
  background: rgba(73,194,242,.08);
  border:1px dashed var(--border-soft);
  color: var(--text);
}
.file-chip .icon{ font-size:18px; }
.file-chip a{ color: var(--brand); text-decoration:none; font-weight:600; }
.file-chip a:hover{ text-decoration:underline; }
.file-chip .size{ font-size:12px; color: var(--brand-2); }

/* upload progress inside temp bubble */
.progress{
  width: 100%;
  height: 6px;
  background: rgba(73,194,242,.15);
  border-radius: 6px;
  overflow: hidden;
}
.progress .bar{
  height: 100%;
  width: 0%;
  background: var(--brand);
  transition: width .12s linear;
}

/* ===== Composer ===== */
.message-form{
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-1);
}
#message-input{
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-2);
  color: var(--text);
}
#message-input::placeholder{ color: rgba(188,233,250,.55); }

/* blocked banner */
.blocked-banner {
  text-align: center;
  padding: 8px;
  background: rgba(255, 99, 99, .08);
  color: #ff9f9f;
  border-top: 1px solid rgba(255,99,99,.25);
}

/* ===== Mobile sidebar toggle & overlay ===== */
.sidebar-toggle {
  display: none;               /* hidden by default (desktop) */
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 110;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--brand);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 105;
}

/* ===== Drag & Drop Overlay (optional; JS sets inline styles, this polishes) ===== */
#drop-overlay{
  display:none;                 /* JS toggles */
  align-items:center;
  justify-content:center;
}
#drop-overlay .drop-card{
  padding:14px 18px;
  background: var(--panel);
  border:2px dashed var(--brand);
  color: var(--text);
  border-radius:12px;
  box-shadow: var(--shadow);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .sidebar-toggle { display: inline-block; }
  .chat-app { grid-template-columns: 1fr; }

  .chat-sidebar { display: none; }
  body.show-sidebar .chat-sidebar {
    display: block;
    position: fixed;
    top: 72px;               /* ~header height */
    left: 0;
    width: min(86vw, 360px);
    height: calc(100vh - 72px);
    z-index: 120;
    box-shadow: 0 10px 30px rgba(0,0,0,.6);
  }
  body.show-sidebar .sidebar-overlay { display: block; }
}

/* Visually hidden but accessible */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Tiny entrance animation */
@keyframes chat-pop{
  from { transform: translateY(2px); opacity: .0; }
  to   { transform: translateY(0); opacity: 1; }
}
