/* ZERO PRIVACY — Minimal Low-Brightness Dark Mode (Default) & Clean Light Mode */

:root {
  --bg: #0e1116;
  --surface: #151921;
  --surface-2: #1c222d;
  --surface-hover: #232a37;
  --border: #262e3d;
  --text: #e4e9f1;
  --text-muted: #8b95a7;
  --accent: #4f8ef7;
  --accent-hover: #3d7be6;
  --accent-soft: rgba(79, 142, 247, 0.14);
  --bubble-me: #1d3557;
  --bubble-me-text: #eef4fc;
  --bubble-other: #1a202b;
  --online: #34c77b;
  --danger: #e05252;
  --danger-soft: rgba(224, 82, 82, 0.14);
  --warning: #d99b26;
  --warning-soft: rgba(217, 155, 38, 0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
}

[data-theme="light"] {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-hover: #e5e9f0;
  --border: #d9dfe8;
  --text: #18202c;
  --text-muted: #5c6778;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --bubble-me: #2563eb;
  --bubble-me-text: #ffffff;
  --bubble-other: #eef1f5;
  --online: #16a34a;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warning: #b45309;
  --warning-soft: rgba(180, 83, 9, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }

/* Buttons & Inputs */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(224,82,82,0.28); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; padding: 10px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

/* Login Screen */
.login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 26px;
  text-align: center;
}
.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-title { margin: 0; font-size: 20px; letter-spacing: 0.08em; font-weight: 700; }
.brand-tagline { margin: 6px 0 22px; color: var(--text-muted); font-size: 13px; }
.stack-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-muted); }
.login-footnote { margin: 18px 0 0; font-size: 12px; color: var(--text-muted); }

.error-banner {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(224, 82, 82, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
}
.warning-banner {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid rgba(217, 155, 38, 0.3);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12px;
  margin-bottom: 12px;
}

/* Main App Layout */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Desktop Left Rail */
.nav-rail {
  width: 68px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 8px;
  flex-shrink: 0;
}
.rail-top, .rail-bottom { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.rail-brand {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.rail-btn {
  width: 52px;
  padding: 8px 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  cursor: pointer;
}
.rail-btn svg { width: 19px; height: 19px; }
.rail-btn:hover { background: var(--surface-hover); color: var(--text); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }

/* Chats Layout */
.chats-layout { display: flex; height: 100%; width: 100%; overflow: hidden; }
.chat-sidebar {
  width: 310px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.sidebar-title { margin: 0; font-size: 14px; letter-spacing: 0.06em; font-weight: 700; }
.sidebar-user { font-size: 11px; color: var(--text-muted); }
.sidebar-search { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.conversation-list { flex: 1; overflow-y: auto; padding: 6px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 2px;
}
.conv-item:hover { background: var(--surface-hover); }
.conv-item.active { background: var(--accent-soft); }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--surface);
  position: absolute;
  bottom: 0;
  right: 0;
}
.conv-meta { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.conv-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.conv-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* Chat Stage */
.chat-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.inspect-notice {
  background: var(--warning-soft);
  color: var(--warning);
  border-bottom: 1px solid rgba(217, 155, 38, 0.28);
  padding: 7px 14px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.inspect-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.empty-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
}
.empty-mark {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.empty-stage h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }

.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header-info h3 { margin: 0; font-size: 15px; }
.status-text { margin: 1px 0 0; font-size: 12px; color: var(--text-muted); }

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row { display: flex; flex-direction: column; max-width: 74%; }
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row.other { align-self: flex-start; align-items: flex-start; }

.msg-sender { font-size: 11px; color: var(--text-muted); margin: 0 4px 2px; }
.msg-bubble {
  background: var(--bubble-other);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  position: relative;
  word-wrap: break-word;
  max-width: 100%;
}
.msg-row.mine .msg-bubble {
  background: var(--bubble-me);
  color: var(--bubble-me-text);
  border-color: transparent;
}
.msg-deleted { font-style: italic; opacity: 0.65; font-size: 13px; }

.msg-reply-quote {
  border-left: 2px solid var(--accent);
  background: rgba(0, 0, 0, 0.14);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 12px;
  cursor: pointer;
}
.msg-reply-quote strong { display: block; font-size: 11px; }

.msg-media-img {
  max-width: 280px;
  max-height: 260px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
  margin-bottom: 4px;
}
.msg-media-video {
  max-width: 300px;
  max-height: 240px;
  border-radius: 8px;
  display: block;
  margin-bottom: 4px;
  background: #000;
}
.msg-doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  margin-bottom: 4px;
}
.view-once-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.view-once-pill.viewed {
  border-color: var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: default;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  font-size: 10.5px;
  opacity: 0.72;
  margin-top: 4px;
}

.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 3px;
  opacity: 0;
  transition: opacity 0.12s;
}
.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions { opacity: 1; }
.msg-act-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}
.msg-act-btn:hover { color: var(--text); border-color: var(--accent); }

.reaction-strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction-chip {
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.reaction-chip.mine { border-color: var(--accent); background: var(--accent-soft); }

.typing-indicator {
  padding: 4px 16px 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Composer & Bars */
.upload-progress, .reply-bar, .file-stage-bar {
  padding: 8px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.upload-progress-meta { display: flex; justify-content: space-between; margin-bottom: 5px; }
.progress-track { height: 5px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.1s; }

.reply-bar, .file-stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reply-bar-content { border-left: 2px solid var(--accent); padding-left: 8px; min-width: 0; }
.reply-bar-content strong { display: block; font-size: 11px; color: var(--accent); }
.reply-bar-content span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }

.file-stage-info { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.staged-filename { font-weight: 600; }
.view-once-toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--accent); }
.view-once-hint { color: var(--warning); font-size: 11.5px; }

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* Page Views (Vault & Admin) */
.page-view {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 80px;
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
}
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.page-header h2 { margin: 0; font-size: 20px; }

.filter-pills, .admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
}
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Media Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.media-thumb {
  height: 145px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(14, 17, 22, 0.8);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}
.media-card-body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.media-card-title { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-meta { font-size: 11px; color: var(--text-muted); }
.media-card-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Admin Cards & Tables */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 22px; font-weight: 700; }
.online-num { color: var(--online); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }

.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: center;
}
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.feedback-text { margin-top: 8px; font-size: 12.5px; color: var(--accent); min-height: 16px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--text-muted); font-weight: 500; font-size: 12px; }
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.tag-online { background: rgba(52, 199, 123, 0.15); color: var(--online); }
.tag-disabled { background: var(--danger-soft); color: var(--danger); }
.tag-admin { background: var(--accent-soft); color: var(--accent); }

.inspect-control-card { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.switch-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.backup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.restore-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-wide { max-width: 760px; }
.modal-sm { max-width: 380px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { margin-top: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog-input { margin-top: 10px; }

.user-picker-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.picker-item:hover { background: var(--surface-hover); }

.media-modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  max-height: 66vh;
  overflow: auto;
  background: var(--bg);
  border-radius: 8px;
  padding: 8px;
}
.media-modal-body img, .media-modal-body video { max-width: 100%; max-height: 62vh; border-radius: 6px; }
.media-modal-body iframe { width: 100%; height: 60vh; border: none; border-radius: 6px; background: #fff; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  z-index: 200;
}

/* Mobile Bottom Nav & Responsive */
.mobile-bottom-nav { display: none; }
.mobile-only { display: none; }

@media (max-width: 820px) {
  .nav-rail { display: none; }
  .mobile-only { display: inline-flex; }
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 50;
  }
  .mnav-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
  }
  .mnav-btn.active { color: var(--accent); font-weight: 600; }

  .workspace { padding-bottom: 56px; }
  .chat-sidebar { width: 100%; border-right: none; }
  .chat-stage { display: none; width: 100%; }
  .chats-layout.mobile-thread-open .chat-sidebar { display: none; }
  .chats-layout.mobile-thread-open .chat-stage { display: flex; }
  .msg-row { max-width: 86%; }
  .msg-actions { opacity: 1; }
  .page-view { padding: 16px 14px 76px; }
  .toast { bottom: 70px; right: 14px; left: 14px; text-align: center; }
}
