/* MeshCore Client – style.css */

:root {
  --bg:     #0d1117;
  --bg2:    #161b22;
  --bg3:    #21262d;
  --border: #30363d;
  --text:   #e6edf3;
  --muted:  #8b949e;
  --green:  #238636;
  --green2: #3fb950;
  --blue:   #1f6feb;
  --blue2:  #58a6ff;
  --orange: #d29922;
  --red:    #da3633;
  --card:   #11161d;
  --shadow: 0 8px 24px rgba(0,0,0,0.3);
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

body { display: flex; flex-direction: column; }

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  height: 58px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,17,23,0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  letter-spacing: -0.01em;
}

.brand-ver {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Inputs, selects, pills ──────────────────────── */
.input, .select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--blue2); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  font-size: 13px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg3); transform: translateY(-1px); }
.btn.primary { background: var(--green); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #2ea043; }
.btn.danger  { background: var(--red);   border-color: transparent; color: #fff; font-weight: 600; }
.btn.danger:hover  { background: #b62324; }
.btn.blue    { background: var(--blue);  border-color: transparent; color: #fff; font-weight: 600; }
.btn.btn-sm  { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }

/* ── Status dot ──────────────────────────────────── */
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(210,153,34,0.2);
  display: inline-block;
  transition: background 0.3s;
}
.status-dot.online {
  background: var(--green2);
  box-shadow: 0 0 0 3px rgba(63,185,80,0.2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(63,185,80,0.2); }
  50%      { box-shadow: 0 0 0 5px rgba(63,185,80,0.05); }
}

/* ── Layout ──────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 270px 1fr 300px;
  height: calc(100vh - 58px);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.search {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}
.search:focus { border-color: var(--blue2); }

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  flex: 1;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: var(--blue);
  color: #fff;
  border-color: transparent;
}

.side-panel { flex: 1; overflow-y: auto; }

/* ── Contact list ────────────────────────────────── */
.list { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.list-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--bg3);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.list-item:hover { transform: translateY(-1px); border-color: #3b4552; }
.list-item.active {
  border-color: rgba(31,111,235,0.5);
  background: rgba(31,111,235,0.1);
}

.li-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.li-name { font-size: 13px; font-weight: 700; }

.li-meta { font-size: 11px; color: var(--muted); }

/* ── Type tags ───────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  white-space: nowrap;
}
.tag.CLI  { color: #79c0ff; border-color: rgba(121,192,255,0.3); }
.tag.REP  { color: #f2cc60; border-color: rgba(242,204,96,0.3);  }
.tag.ROOM { color: #7ee787; border-color: rgba(126,231,135,0.3); }
.tag.SENS { color: #ffa657; border-color: rgba(255,166,87,0.3);  }
.tag.NONE { color: var(--muted); }

/* ── Center content ──────────────────────────────── */
.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
}

/* ── Info cards ──────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  flex-shrink: 0;
}

.mini-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.mini-label {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mini-value {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
}

/* ── Chat panel ──────────────────────────────────── */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  border-radius: var(--radius) var(--radius) 0 0;
}

.chat-header-tabs { width: auto !important; }
.chat-header-tabs .tab { font-size: 12px; height: 28px; }

.chat-title-wrap { display: flex; flex-direction: column; gap: 3px; }
.chat-title { font-size: 16px; font-weight: 800; }
.chat-subtitle { font-size: 12px; color: var(--muted); }

/* ── Chat window ─────────────────────────────────── */
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(circle at top right, rgba(31,111,235,0.06), transparent 30%),
    radial-gradient(circle at bottom left, rgba(35,134,54,0.05), transparent 28%);
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 3px;
}
.msg-row.self { align-self: flex-end; text-align: right; }

.msg-sender { font-size: 11px; color: var(--muted); font-weight: 700; }

.bubble {
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--bg3);
  word-break: break-word;
}
.msg-row.self .bubble {
  background: rgba(31,111,235,0.18);
  border-color: rgba(31,111,235,0.4);
}
.msg-row.channel .bubble {
  background: rgba(35,134,54,0.1);
  border-color: rgba(35,134,54,0.3);
}

.msg-meta { font-size: 11px; color: var(--muted); }

/* ── Contact info view ───────────────────────────── */
.contact-info-view {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}
.contact-info-view pre {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Composer ────────────────────────────────────── */
.composer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.composer input {
  flex: 1;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  padding: 0 14px;
  font-size: 13px;
  outline: none;
}
.composer input:focus { border-color: var(--blue2); }

/* ── Right panel ─────────────────────────────────── */
.rightpanel {
  border-left: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
}

.panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-title { font-size: 13px; font-weight: 700; }
.panel-body  { padding: 12px 14px; }

/* ── Quick actions ───────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Settings ────────────────────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.setting-row label { font-size: 12px; color: var(--muted); min-width: 28px; }
.setting-row .input { height: 30px; font-size: 12px; flex: 1; min-width: 0; }

/* ── Log box ─────────────────────────────────────── */
.logbox {
  flex: 1;
  padding: 10px 12px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  min-height: 140px;
  max-height: 260px;
}
.log-ok   { color: #7ee787; }
.log-warn { color: #f2cc60; }
.log-err  { color: #ff7b72; }
.log-cmd  { color: #79c0ff; }
.log-recv { color: #bc8cff; }
.log-sent { color: #58a6ff; }

/* ── Sidebar split (no tabs) ────────────────────── */
.sidebar {
  gap: 0;
  padding: 0;
}

.sidebar-top {
  padding: 10px 12px 8px;
  flex-shrink: 0;
}

.sidebar-sect {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.sidebar-sect.sidebar-contacts {
  flex: 1;
  border-bottom: 2px solid var(--border);
}

.sidebar-sect.sidebar-chans {
  flex: 0 0 auto;
  min-height: 170px;
  max-height: 260px;
}

.sidebar-sect-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  flex-shrink: 0;
}

.sidebar-sect-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ── Contact row with avatar ─────────────────────── */
.li-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.li-avatar-sm {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.li-chan-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.li-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.li-key {
  font-size: 10px;
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.li-activity {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.route-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 4px;
}
.route-pill.Flood  { color: var(--blue2);  background: rgba(88,166,255,0.1); }
.route-pill.Direct { color: var(--green2); background: rgba(63,185,80,0.1); }
.route-pill.hop    { color: var(--orange); background: rgba(210,153,34,0.1); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 250px 1fr; }
  .rightpanel { display: none; }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Unread badge ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* ── Avatar ──────────────────────────────────────── */
.msg-with-avatar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-body { display: flex; flex-direction: column; gap: 3px; }

/* ── Date separator ──────────────────────────────── */
.date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-sep::before, .date-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Path chain ─────────────────────────────────── */
.path-chain {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 5px;
  font-size: 10px;
}
.path-node {
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.path-src  { background: rgba(242,204,96,.15);  color: #f2cc60; border: 1px solid rgba(242,204,96,.3);  }
.path-via  { background: rgba(139,148,158,.12); color: #8b949e; border: 1px solid rgba(139,148,158,.25); }
.path-dst  { background: rgba(63,185,80,.15);   color: #3fb950; border: 1px solid rgba(63,185,80,.3);   }
.path-arr  { color: var(--muted); font-size: 9px; }
.path-hop.direct { color: var(--green2); font-weight: 700; font-size: 10px; }
.path-node.path-unknown { color: var(--muted); border-style: dashed; opacity: 0.7; }

/* ── Reply ───────────────────────────────────────── */
.reply-quote {
  font-size: 11px;
  color: var(--muted);
  border-left: 2px solid var(--blue2);
  padding-left: 8px;
  margin-bottom: 4px;
  font-style: italic;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-btn {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

.msg-row:hover .reply-btn { opacity: 1; }
.reply-btn:hover { color: var(--blue2); }

/* ── Path modal ──────────────────────────────────── */
.path-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}

.path-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 420px; max-width: 95vw;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  overflow: hidden;
}

.path-modal-hdr {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-shrink: 0;
}

.path-modal-title { font-size: 16px; font-weight: 800; }
.path-modal-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }

.path-modal-body {
  flex: 1; overflow-y: auto;
  padding: 12px 18px;
}

.path-hop-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}

/* Vertical connector line between hops */
.path-hop-row:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 17px; top: 44px;
  width: 2px; height: calc(100% - 8px);
  background: var(--border);
}

.path-hop-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  z-index: 1;
}

.path-hop-info { flex: 1; min-width: 0; }

.path-hop-name {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.path-hop-label {
  font-size: 11px; color: var(--muted);
  margin-top: 2px;
}

.path-hop-badge {
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  margin-top: 3px; display: inline-block;
}

.path-hop-prefix {
  font-size: 10px; font-family: "Cascadia Code", monospace;
  color: var(--muted); margin-top: 1px;
}

.path-modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  flex-shrink: 0;
}

/* Clickable hops in chat */
.hops-link {
  cursor: pointer;
  color: var(--blue2);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.hops-link:hover { color: #fff; }

/* ── Mini-card multi-line ────────────────────────── */
.mini-value { white-space: pre-line; }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Material Symbols ────────────────────────────── */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  vertical-align: middle;
  user-select: none;
}

/* ── Node type icon colours ──────────────────────── */
.node-icon { font-size: 16px; vertical-align: middle; }
.node-icon.CLI  { color: #79c0ff; }
.node-icon.REP  { color: #f2cc60; }
.node-icon.ROOM { color: #7ee787; }
.node-icon.SENS { color: #ffa657; }
.node-icon.NONE { color: var(--muted); }

/* ── Composer mode label ─────────────────────────── */
.composer-mode {
  font-size: 11px;
  font-weight: 700;
  color: var(--orange);
  white-space: nowrap;
  padding: 0 4px;
}
