/* SANA - app.css
   Dark, minimal, RTL-first. System fonts only - ZERO external resources
   (privacy + camouflage: the page loads nothing from third parties). */

:root {
  --bg: #0f1216;
  --bg2: #161b22;
  --bg3: #1d242e;
  --line: #2a3340;
  --fg: #e6e9ee;
  --muted: #8b96a5;
  --accent: #3d9a6b;
  --accent2: #2f7a53;
  --danger: #c8544a;
  --warn: #c9a13d;
  --info: #4a8fc9;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Vazirmatn", "Segoe UI", Tahoma, "Noto Sans", system-ui, sans-serif;
  font-size: 15px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: "Sarasa Mono SC", "Cascadia Mono", Consolas, monospace; letter-spacing: 1px; }

.view { height: 100vh; display: flex; flex-direction: column; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 9px 16px;
  font: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #232c38; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); }
.btn.primary:hover { background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.linklike {
  background: none; border: none; color: var(--muted);
  font: inherit; cursor: pointer; padding: 4px 6px;
}
.linklike:hover { color: var(--fg); text-decoration: underline; }
.linklike.danger:hover { color: var(--danger); }

input, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: none; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13.5px; }

.error {
  background: rgba(200, 84, 74, .12);
  border: 1px solid rgba(200, 84, 74, .5);
  color: #e8a49e;
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 12px;
  font-size: 13.5px;
}

/* ============ COVER (decoy notes app) ============ */
.cover { background: var(--bg); }
.cover-top {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.cover-top h1 { font-size: 18px; margin: 0; font-weight: 600; }
.logo {
  width: 14px; height: 14px; border-radius: 4px;
  background: var(--accent); display: inline-block;
}
.cover-body { flex: 1; display: flex; min-height: 0; }
.cover-list-wrap {
  width: 270px; border-inline-end: 1px solid var(--line);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0;
}
.cover-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.cover-list li {
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fg);
}
.cover-list li.active { background: var(--bg3); }
.cover-list li .t { display: block; font-size: 14px; }
.cover-list li .d { display: block; font-size: 12px; color: var(--muted); }
.cover-editor { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; gap: 12px; min-width: 0; }
.cover-title { font-size: 17px; font-weight: 600; background: transparent; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 6px 2px; }
.cover-text { flex: 1; min-height: 0; background: transparent; border: none; padding: 8px 2px; line-height: 1.9; }
.cover-status { display: flex; justify-content: space-between; align-items: center; }
.cover-foot {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 10px; border-top: 1px solid var(--line);
  user-select: none; cursor: default;
}

/* ============ AUTH ============ */
.auth { align-items: center; justify-content: center; }
.auth-card {
  width: min(420px, 92vw);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card > p { margin: 0 0 18px; }
.auth-switch { margin-top: 12px; text-align: center; }

/* ============ APP ============ */
.app { flex-direction: row; }
.sidebar {
  width: 280px; border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px; gap: 10px; min-height: 0;
}
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px; }
.contact-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.contact-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; color: var(--fg);
}
.contact-item:hover { background: var(--bg2); }
.contact-item.active { background: var(--bg3); }
.contact-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-item .preview { font-size: 12px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.side-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--accent); }
.dot.warn { background: var(--warn); }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--line); gap: 10px;
}
.chat-head-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-head-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  font-size: 11px; border-radius: 6px; padding: 2px 7px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: #9fdcb8; border-color: var(--accent2); background: rgba(61,154,107,.12); }
.badge.no { color: #e8c99e; border-color: var(--warn); background: rgba(201,161,61,.1); }

.alerts { position: absolute; top: 60px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 30; }
.alert {
  pointer-events: auto;
  max-width: min(640px, 90vw);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13.5px;
  border: 1px solid;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
  cursor: pointer;
}
.alert.critical { background: #3a1b18; border-color: var(--danger); color: #f1b7b1; }
.alert.warn { background: #38300f; border-color: var(--warn); color: #ead9a9; }
.alert.info { background: #12283a; border-color: var(--info); color: #b4d4ec; }

.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.msg {
  max-width: min(560px, 78%);
  border-radius: 14px;
  padding: 9px 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg.out { align-self: flex-start; background: #1f3b2d; border: 1px solid #2b543f; }
.msg.in { align-self: flex-end; background: var(--bg3); border: 1px solid var(--line); }
.msg .meta { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.msg .meta .st-pending { color: var(--warn); }
.msg .meta .st-failed { color: var(--danger); }

.composer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { max-height: 140px; min-height: 44px; }
.composer .btn { min-width: 90px; height: 44px; }

/* ============ DIALOGS ============ */
.dlg {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  width: min(480px, 92vw);
}
.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg h2 { margin: 0 0 10px; font-size: 17px; }
.dlg p { margin: 0 0 14px; line-height: 1.9; }
.dlg-row { display: flex; gap: 10px; justify-content: flex-start; margin-top: 14px; flex-wrap: wrap; }
.dlg-col { display: flex; flex-direction: column; gap: 10px; }
.dlg hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }

.safety-number {
  font-size: 24px; text-align: center; direction: ltr;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 8px; margin: 10px 0 8px;
}
.danger-text { color: #e8a49e; }

/* mobile */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: 44vh; border-inline-end: none; border-bottom: 1px solid var(--line); }
  .msg { max-width: 88%; }
  .cover-list-wrap { width: 38%; }
}
