/* Prior — закрытый чат */
:root {
  --pr-bg:       #0d1117;
  --pr-surface:  #161b22;
  --pr-border:   #21262d;
  --pr-accent:   #1a5fb4;
  --pr-accent2:  #3584e4;
  --pr-text:     #e6edf3;
  --pr-muted:    #8b949e;
  --pr-bubble-me:#1a5fb4;
  --pr-bubble-in:#21262d;
  --pr-danger:   #da3633;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--pr-bg); color: var(--pr-text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 15px; }

/* ── SPLASH / LOGIN ─────────────────────────────────────────────── */
#pr-login-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 24px; padding: 24px;
}
.pr-logo-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pr-logo-wrap img { width: 80px; height: 80px; }
.pr-logo-wrap .pr-brand { font-size: 2rem; font-weight: 700; color: var(--pr-text); letter-spacing: 2px; }
.pr-login-box {
  background: var(--pr-surface); border: 1px solid var(--pr-border);
  border-radius: 12px; padding: 32px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 14px;
}
.pr-login-box h2 { text-align: center; font-size: 1.15rem; color: var(--pr-muted); font-weight: 400; }
.pr-input {
  background: var(--pr-bg); border: 1px solid var(--pr-border); border-radius: 8px;
  color: var(--pr-text); padding: 11px 14px; font-size: 15px; width: 100%;
  transition: border-color .15s;
}
.pr-input:focus { outline: none; border-color: var(--pr-accent2); }
.pr-btn {
  background: var(--pr-accent); color: #fff; border: none; border-radius: 8px;
  padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
  transition: background .15s;
}
.pr-btn:hover { background: var(--pr-accent2); }
.pr-btn:disabled { opacity: .5; cursor: default; }
.pr-btn-ghost {
  background: transparent; color: var(--pr-muted); border: 1px solid var(--pr-border);
  border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.pr-btn-ghost:hover { border-color: var(--pr-accent2); color: var(--pr-text); }
.pr-error { color: #f85149; font-size: 13px; text-align: center; }
.pr-hint { color: var(--pr-muted); font-size: 12px; text-align: center; }

/* ── MAIN LAYOUT ─────────────────────────────────────────────────── */
#pr-app { display: flex; height: 100vh; }

/* sidebar */
#pr-sidebar {
  width: 300px; min-width: 300px; background: var(--pr-surface);
  border-right: 1px solid var(--pr-border);
  display: flex; flex-direction: column;
}
.pr-sidebar-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--pr-border);
}
.pr-sidebar-hdr img { width: 28px; height: 28px; }
.pr-sidebar-hdr .pr-brand-sm { font-weight: 700; font-size: 1rem; letter-spacing: 1px; flex: 1; }
.pr-me-info { font-size: 12px; color: var(--pr-muted); }
.pr-icon-btn {
  background: none; border: none; color: var(--pr-muted); cursor: pointer;
  font-size: 18px; padding: 4px 6px; border-radius: 6px;
  transition: background .15s, color .15s;
}
.pr-icon-btn:hover { background: var(--pr-border); color: var(--pr-text); }
#pr-chat-list { flex: 1; overflow-y: auto; }
.pr-chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--pr-border);
  transition: background .1s;
}
.pr-chat-item:hover { background: rgba(255,255,255,.04); }
.pr-chat-item.active { background: rgba(26,95,180,.2); }
.pr-chat-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--pr-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; flex-shrink: 0; color: #fff;
}
.pr-chat-meta { flex: 1; min-width: 0; }
.pr-chat-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-chat-last { font-size: 12px; color: var(--pr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-new-chat-btn {
  margin: 12px 16px; background: var(--pr-accent); color: #fff; border: none;
  border-radius: 8px; padding: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.pr-new-chat-btn:hover { background: var(--pr-accent2); }

/* chat panel */
#pr-chat-panel {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
#pr-chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--pr-border);
  background: var(--pr-surface);
}
#pr-chat-title { font-weight: 600; font-size: 15px; flex: 1; }
#pr-chat-subtitle { font-size: 12px; color: var(--pr-muted); }
#pr-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.pr-msg-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.pr-msg-group.me { align-items: flex-end; }
.pr-msg-group.other { align-items: flex-start; }
.pr-msg-sender { font-size: 11px; color: var(--pr-muted); padding: 0 10px; margin-bottom: 2px; }
.pr-bubble {
  max-width: 65%; background: var(--pr-bubble-in); border-radius: 12px;
  padding: 8px 12px; font-size: 14px; line-height: 1.45; word-break: break-word;
  position: relative;
}
.pr-msg-group.me .pr-bubble { background: var(--pr-bubble-me); border-bottom-right-radius: 3px; }
.pr-msg-group.other .pr-bubble { border-bottom-left-radius: 3px; }
.pr-bubble time { display: block; font-size: 11px; color: rgba(255,255,255,.45); text-align: right; margin-top: 4px; }
.pr-msg-group.me .pr-bubble time { color: rgba(255,255,255,.55); }
.pr-reply-preview {
  border-left: 3px solid var(--pr-accent2); padding: 4px 8px; margin-bottom: 6px;
  background: rgba(255,255,255,.06); border-radius: 4px; font-size: 12px; color: var(--pr-muted);
}
.pr-reply-preview strong { color: var(--pr-text); }

/* media in bubbles */
.pr-bubble img.pr-media { max-width: 240px; max-height: 240px; border-radius: 8px; display: block; cursor: zoom-in; }
.pr-bubble video.pr-media { max-width: 280px; max-height: 220px; border-radius: 8px; display: block; }
.pr-bubble audio.pr-media { width: 220px; }
.pr-file-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--pr-text); }
.pr-file-link .pr-file-ico { font-size: 22px; }
.pr-file-info { display: flex; flex-direction: column; }
.pr-file-name { font-size: 13px; font-weight: 500; }
.pr-file-size { font-size: 11px; color: var(--pr-muted); }

/* input bar */
#pr-input-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 16px; border-top: 1px solid var(--pr-border);
  background: var(--pr-surface);
}
#pr-reply-strip {
  display: none; background: var(--pr-border); border-radius: 8px 8px 0 0;
  padding: 6px 12px; font-size: 13px; color: var(--pr-muted);
  border-left: 3px solid var(--pr-accent2); margin: 0 16px;
  display: flex; align-items: center; gap: 8px;
}
#pr-reply-strip.active { display: flex; }
#pr-reply-cancel { background: none; border: none; color: var(--pr-muted); cursor: pointer; font-size: 16px; }
#pr-attach-wrap { position: relative; flex-shrink: 0; }
#pr-attach-btn { font-size: 20px; }
#pr-attach-menu {
  display: none; position: absolute; bottom: 44px; left: 0;
  background: var(--pr-surface); border: 1px solid var(--pr-border);
  border-radius: 10px; overflow: hidden; width: 200px; z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
#pr-attach-menu button {
  display: block; width: 100%; background: none; border: none; color: var(--pr-text);
  padding: 11px 16px; text-align: left; cursor: pointer; font-size: 14px;
  transition: background .1s;
}
#pr-attach-menu button:hover { background: rgba(255,255,255,.06); }
#pr-msg-input {
  flex: 1; background: var(--pr-bg); border: 1px solid var(--pr-border); border-radius: 10px;
  color: var(--pr-text); padding: 10px 14px; font-size: 15px; resize: none;
  max-height: 120px; overflow-y: auto; line-height: 1.4;
}
#pr-msg-input:focus { outline: none; border-color: var(--pr-accent2); }
#pr-send-btn {
  background: var(--pr-accent); color: #fff; border: none; border-radius: 50%;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; flex-shrink: 0; transition: background .15s;
}
#pr-send-btn:hover { background: var(--pr-accent2); }
.pr-voice-btn { font-size: 20px; }

/* voice recording overlay */
#pr-voice-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex;
  align-items: center; justify-content: center; z-index: 500;
}
.pr-voice-box {
  background: var(--pr-surface); border: 1px solid var(--pr-border); border-radius: 16px;
  padding: 40px; display: flex; flex-direction: column; align-items: center; gap: 20px;
  min-width: 260px;
}
.pr-voice-anim { width: 60px; height: 60px; border-radius: 50%; background: var(--pr-danger); animation: pr-pulse 1.2s infinite; }
@keyframes pr-pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.2);opacity:.7} }
.pr-voice-timer { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.pr-voice-actions { display: flex; gap: 16px; }
.pr-voice-cancel { background: transparent; border: 1px solid var(--pr-border); color: var(--pr-muted); border-radius: 8px; padding: 10px 20px; cursor: pointer; }
.pr-voice-send   { background: var(--pr-accent); color: #fff; border: none; border-radius: 8px; padding: 10px 20px; cursor: pointer; font-weight: 600; }

/* ── MODAL ────────────────────────────────────────────────────────── */
.pr-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.pr-modal {
  background: var(--pr-surface); border: 1px solid var(--pr-border); border-radius: 12px;
  padding: 24px; min-width: 320px; max-width: 480px; width: 90%; display: flex; flex-direction: column; gap: 16px;
}
.pr-modal h3 { font-size: 1.1rem; }
.pr-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.pr-label { font-size: 13px; color: var(--pr-muted); margin-bottom: 4px; }
.pr-user-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--pr-border); border-radius: 20px; padding: 4px 10px; font-size: 13px;
}
.pr-user-pill button { background: none; border: none; color: var(--pr-muted); cursor: pointer; font-size: 14px; }
.pr-user-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pr-user-list label {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  cursor: pointer; border-radius: 8px; transition: background .1s;
}
.pr-user-list label:hover { background: rgba(255,255,255,.05); }
.pr-user-list input[type=checkbox] { accent-color: var(--pr-accent2); width: 16px; height: 16px; }

/* ── ADMIN PANEL ─────────────────────────────────────────────────── */
#pr-admin-panel {
  flex: 1; display: flex; flex-direction: column; padding: 24px; overflow-y: auto; gap: 20px;
}
#pr-admin-panel h2 { font-size: 1.2rem; border-bottom: 1px solid var(--pr-border); padding-bottom: 12px; }
.pr-admin-section { background: var(--pr-surface); border: 1px solid var(--pr-border); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.pr-admin-section h3 { font-size: 1rem; color: var(--pr-muted); }
.pr-toggle-row { display: flex; align-items: center; gap: 14px; }
.pr-switch { position: relative; width: 44px; height: 24px; }
.pr-switch input { opacity: 0; width: 0; height: 0; }
.pr-switch-slider {
  position: absolute; inset: 0; background: var(--pr-border); border-radius: 24px; cursor: pointer; transition: .2s;
}
.pr-switch-slider:before {
  content:''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.pr-switch input:checked + .pr-switch-slider { background: var(--pr-accent2); }
.pr-switch input:checked + .pr-switch-slider:before { transform: translateX(20px); }
.pr-users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pr-users-table th { text-align: left; padding: 8px 10px; color: var(--pr-muted); font-weight: 500; border-bottom: 1px solid var(--pr-border); }
.pr-users-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.05); }
.pr-users-table tr:hover td { background: rgba(255,255,255,.03); }
.pr-tag { display: inline-block; background: var(--pr-border); border-radius: 4px; padding: 2px 7px; font-size: 11px; }
.pr-tag.first { background: rgba(248,81,73,.2); color: #f85149; }
.pr-add-user-form { display: flex; gap: 10px; flex-wrap: wrap; }
.pr-add-user-form input { flex: 1; min-width: 140px; }

/* ── EMPTY STATE ─────────────────────────────────────────────────── */
#pr-empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; color: var(--pr-muted);
}
#pr-empty-state img { width: 64px; height: 64px; opacity: .4; }
#pr-empty-state p { font-size: 15px; }

/* ── LIGHTBOX ─────────────────────────────────────────────────────── */
#pr-lightbox {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.92);
  align-items: center; justify-content: center; z-index: 2000; cursor: zoom-out;
}
#pr-lightbox.open { display: flex; }
#pr-lightbox img { max-width: 95vw; max-height: 90vh; border-radius: 8px; }

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

/* ── RESPONSIVE ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #pr-sidebar { display: none; width: 100%; min-width: 100%; }
  #pr-sidebar.visible { display: flex; }
  #pr-chat-panel.hidden { display: none; }
  #pr-app { display: block; height: 100vh; overflow: hidden; }
  #pr-sidebar { height: 100vh; }
  #pr-chat-panel { height: 100vh; }
}
