/* Admin Chat — "Onyx & Gold" theme
   Deep black surfaces, white type, brushed-gold accents. */

:root {
  --black: #070707;
  --ink: #0e0e0f;
  --ink-2: #151517;
  --ink-3: #1d1d20;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  --gold: #d4af37;
  --gold-light: #f1d67a;
  --gold-deep: #a8842a;
  --gold-line: rgba(212, 175, 55, 0.35);
  --gold-glow: rgba(212, 175, 55, 0.22);
  --gold-grad: linear-gradient(135deg, #f3dc8a 0%, #d4af37 45%, #b58f2c 100%);

  --text: #f5f3ee;
  --text-dim: rgba(245, 243, 238, 0.62);
  --text-faint: rgba(245, 243, 238, 0.4);
  --on-gold: #1a1400;

  --mine: linear-gradient(135deg, #2a2415 0%, #1c1a12 100%);
  --theirs: var(--ink-3);
  --online: #d4af37;
  --danger: #ff6b6b;
  --warn: #ffc466;

  --radius: 18px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

/* Explicit display values below would otherwise defeat the hidden attribute. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--black);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* Subtle gold ambience: one soft radial glow at the top, faint grain-free
   vignette at the bottom. Purely decorative, fixed behind everything. */
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(70% 45% at 50% -10%, rgba(212, 175, 55, 0.16) 0%, transparent 70%),
    radial-gradient(60% 40% at 50% 110%, rgba(212, 175, 55, 0.07) 0%, transparent 70%),
    var(--black);
}

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

button { font: inherit; color: inherit; cursor: pointer; }

/* gold hairline utility */
.hairline { height: 1px; background: linear-gradient(90deg, transparent, var(--gold-line), transparent); }

/* ---------- login ---------- */

#login-view { align-items: center; justify-content: center; padding: 20px; }

.login-box {
  width: 100%; max-width: 380px;
  padding: 34px 28px 26px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink) 100%);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), 0 0 0 1px rgba(212,175,55,.08) inset;
  position: relative;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
/* thin gold top edge */
.login-box::before {
  content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.login-box h1 {
  margin: 0 0 6px;
  font-size: 28px; font-weight: 700; letter-spacing: .01em;
  background: var(--gold-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-sub {
  margin: 0 0 24px;
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--text-dim);
}

.login-cards { display: grid; gap: 12px; }

.login-card {
  padding: 18px;
  font-size: 16px; font-weight: 600; letter-spacing: .04em;
  background: var(--ink-3);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.login-card:hover { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
.login-card:active { transform: scale(.98); }

#passcode-form { display: grid; gap: 10px; margin-top: 8px; }
#passcode-label { margin: 0; font-weight: 600; }

#passcode-input {
  padding: 13px 14px;
  font: inherit; color: var(--text);
  background: var(--black);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  text-align: center; letter-spacing: .08em;
  transition: border-color .15s, box-shadow .15s;
}
#passcode-input::placeholder { color: var(--text-faint); letter-spacing: normal; }
#passcode-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }

.btn-primary {
  padding: 13px;
  background: var(--gold-grad);
  border: none; border-radius: 12px;
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 13px;
  color: var(--on-gold);
  box-shadow: 0 8px 22px rgba(212,175,55,.28);
  transition: transform .08s, filter .15s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.98); }

.btn-ghost {
  padding: 8px 12px;
  background: none; border: none;
  color: var(--text-dim);
  border-radius: 10px;
}
.btn-ghost:hover { color: var(--gold-light); background: rgba(255,255,255,.05); }

.login-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 13px; }

/* ---------- chat header ---------- */

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  flex-shrink: 0;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 3;
}
.chat-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-line) 50%, transparent 100%);
}

.peer-info { display: flex; align-items: center; gap: 10px; }
.peer-name { font-weight: 700; letter-spacing: .02em; }
.peer-status { font-size: 12px; color: var(--text-dim); }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,.22); flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}
.dot.online { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow), 0 0 12px var(--gold); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.conn-status { font-size: 12px; color: var(--warn); }

/* ---------- messages ---------- */

.messages {
  flex: 1; overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 2px;
  outline: none;
  scrollbar-width: thin; scrollbar-color: rgba(212,175,55,.35) transparent;
}

.empty-state {
  margin: auto; text-align: center;
  padding: 24px 28px;
  border-radius: 18px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.empty-state p { margin: 0 0 4px; }
.empty-sub { font-size: 13px; color: var(--text-dim); }

.day-sep {
  align-self: center;
  margin: 14px 0 6px;
  padding: 4px 14px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold);
  background: var(--ink-2);
  border: 1px solid var(--gold-line);
  border-radius: 20px;
}

.msg {
  max-width: min(78%, 560px);
  margin-top: 6px;
  padding: 9px 13px;
  border-radius: var(--radius);
  word-wrap: break-word; overflow-wrap: anywhere;
  box-shadow: var(--shadow-soft);
  animation: pop .18s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.msg.mine {
  align-self: flex-end;
  background: var(--mine);
  border: 1px solid var(--gold-line);
  border-bottom-right-radius: 6px;
}
.msg.theirs {
  align-self: flex-start;
  background: var(--theirs);
  border: 1px solid var(--line-strong);
  border-bottom-left-radius: 6px;
}
.msg.pending { opacity: .6; }

.msg-body { white-space: pre-wrap; }
.msg-body a { color: var(--gold-light); text-decoration-color: rgba(241,214,122,.45); }

.msg-meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px;
  margin-top: 3px;
  font-size: 11px; color: var(--text-faint);
  user-select: none;
}
.ticks { letter-spacing: -2px; }
.ticks.seen { color: var(--gold); }

/* long message collapse */
.msg-expand {
  display: block; margin-top: 4px;
  background: none; border: none; padding: 0;
  color: var(--gold-light); font-size: 13px;
}
.msg-body.collapsed {
  max-height: 320px; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 75%, transparent);
          mask-image: linear-gradient(#000 75%, transparent);
}

/* ---------- attachments ---------- */

.att-image {
  display: block;
  max-width: 100%; height: auto;
  border-radius: 12px; margin-top: 4px;
  background: var(--black);
  border: 1px solid var(--line-strong);
  cursor: zoom-in;
  transition: transform .15s, border-color .15s;
}
.att-image:hover { transform: scale(1.01); border-color: var(--gold-line); }

.att-file {
  display: flex; align-items: center; gap: 10px;
  margin-top: 4px; padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit; text-decoration: none;
  transition: border-color .15s, background .15s;
}
.att-file:hover { border-color: var(--gold-line); background: rgba(0,0,0,.5); }
.att-file-icon { font-size: 26px; }
.att-file-name {
  font-weight: 600; font-size: 14px;
  max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-file-size { font-size: 12px; color: var(--text-dim); }
.att-file-dl { margin-left: auto; font-size: 18px; color: var(--gold); }

/* ---------- link preview card ---------- */

.link-preview {
  display: block;
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 8px 10px;
  color: inherit; text-decoration: none;
  overflow: hidden;
  transition: background .15s;
}
.link-preview:hover { background: rgba(0, 0, 0, 0.5); }
.lp-site { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: .1em; }
.lp-title { font-weight: 600; font-size: 14px; margin: 2px 0; }
.lp-desc {
  font-size: 13px; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.lp-img { max-width: 100%; max-height: 180px; border-radius: 8px; margin-top: 6px; object-fit: cover; }

/* ---------- typing / upload / pill ---------- */

.typing-bar {
  align-self: flex-start;
  margin: 0 14px 6px;
  padding: 5px 12px;
  font-size: 13px; color: var(--text-dim);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  flex-shrink: 0;
}
.typing-dots i {
  display: inline-block; width: 4px; height: 4px; margin-left: 3px;
  background: var(--gold); border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-4px); } }

.upload-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 14px 6px;
  padding: 8px 14px; font-size: 13px; flex-shrink: 0;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.upload-bar progress { flex: 1; height: 6px; accent-color: var(--gold); }
#upload-name { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.new-msgs-pill {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 92px;
  padding: 9px 16px;
  background: var(--gold-grad);
  color: var(--on-gold);
  border: none; border-radius: 20px;
  font-weight: 700; font-size: 13px;
  box-shadow: 0 8px 22px rgba(212,175,55,.35);
  z-index: 5;
}

/* ---------- composer ---------- */

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  flex-shrink: 0;
  background: var(--ink);
  border-top: 1px solid var(--line);
  position: relative;
  z-index: 3;
}
.composer::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-line) 50%, transparent 100%);
}

#composer-input {
  flex: 1;
  max-height: 160px;
  padding: 11px 15px;
  font: inherit; color: var(--text);
  background: var(--black);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  resize: none; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#composer-input::placeholder { color: var(--text-faint); }
#composer-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }

.icon-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 19px;
  background: var(--ink-3);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.icon-btn:hover { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.send {
  background: var(--gold-grad);
  border-color: transparent; color: var(--on-gold);
  box-shadow: 0 6px 18px rgba(212,175,55,.35);
}
.icon-btn:disabled { opacity: .4; cursor: default; }

/* ---------- drag & drop ---------- */

.drop-overlay {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgba(7, 7, 7, .88);
  border: 2px dashed var(--gold);
  color: var(--gold-light);
  font-size: 22px; font-weight: 700; letter-spacing: .06em;
  z-index: 40;
  pointer-events: none;
}

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .94);
  z-index: 50;
}
#lb-img {
  max-width: 96vw; max-height: 92dvh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,.7), 0 0 0 1px var(--gold-line);
}
.lb-btn {
  position: fixed;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  background: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: 50%;
  color: #fff; font-size: 22px;
  text-decoration: none;
  z-index: 51;
  transition: border-color .15s, color .15s;
}
.lb-btn:hover { border-color: var(--gold); color: var(--gold-light); }
.lb-close { top: 14px; right: 14px; }
.lb-download { top: 14px; right: 70px; font-size: 18px; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 24px;
  max-width: 90vw;
  padding: 10px 18px;
  background: var(--ink-2);
  border: 1px solid var(--danger);
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow-soft);
  z-index: 60;
}

/* ---------- wider screens ---------- */

@media (min-width: 700px) {
  .messages { padding: 18px max(14px, calc((100vw - 860px) / 2)); }
  .composer { padding-left: max(12px, calc((100vw - 860px) / 2)); padding-right: max(12px, calc((100vw - 860px) / 2)); }
  .typing-bar, .upload-bar { margin-left: max(14px, calc((100vw - 860px) / 2)); }
}

@media (prefers-reduced-motion: reduce) {
  .msg, .login-box { animation: none; }
}
