/* ============================================================
   צ'אט אנונימי — Anonymous Chat
   Theme: numbers-station radio. Dark set, amber signal glow,
   monospace digits standing in for the whole identity system.
   RTL / Hebrew interface.
   ============================================================ */

:root {
  --bg:        #0b0d0f;
  --panel:     #14171b;
  --panel-2:   #1b1f24;
  --line:      #262b31;
  --amber:     #f5a623;
  --amber-dim: #8a6423;
  --text:      #e8e6e1;
  --text-dim:  #8a8f96;
  --danger:    #e2574c;
  --danger-dim:#7a2e28;
  --ok:        #5ecb8a;

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Heebo', system-ui, -apple-system, sans-serif;

  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over component display rules
   (several elements below use `display: flex` for their visible state,
   which would otherwise silently cancel out `[hidden]`). */
[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* faint scan/static overlay for atmosphere, purely decorative */
.static-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: repeating-linear-gradient(
    0deg, #fff 0px, transparent 1px, transparent 2px, #fff 3px
  );
  animation: flicker 6s steps(2) infinite;
}
@keyframes flicker { 0%, 92%, 100% { opacity: 0.035; } 94% { opacity: 0.06; } }

@media (prefers-reduced-motion: reduce) {
  .static-overlay { animation: none; }
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- screens ---------- */
.screen {
  display: none;
  min-height: 100dvh;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}
.screen.active { display: flex; }

/* ---------- brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px 2px rgba(245, 166, 35, 0.6);
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.05em;
  font-size: 14px;
  color: var(--text-dim);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-btn {
  font-size: 18px;
  color: var(--text-dim);
}
.settings-btn:active { background: var(--panel-2); }

/* ---------- id card ---------- */
.id-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  margin-bottom: 28px;
  overflow: hidden;
}
.id-label {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}
.id-display {
  font-family: var(--mono);
  font-size: clamp(26px, 8.5vw, 40px);
  font-weight: 600;
  letter-spacing: clamp(0.04em, 1.2vw, 0.12em);
  color: var(--amber);
  text-shadow: 0 0 18px rgba(245, 166, 35, 0.35);
  white-space: nowrap;
}
.id-display.small { font-size: clamp(22px, 7vw, 30px); }
.id-hint {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---------- actions ---------- */
.actions { display: flex; flex-direction: column; gap: 16px; }

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 15px 18px;
  font-size: 15.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.08s ease, filter 0.15s ease;
  width: 100%;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--amber);
  color: #191307;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled {
  background: var(--amber-dim);
  color: #191307aa;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  width: auto;
  padding: 15px 20px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger-dim);
}
.btn-danger.armed {
  background: var(--danger);
  color: #1a0d0b;
  border-color: var(--danger);
}

.btn.small { padding: 10px 16px; font-size: 14px; }

.dial-mini {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #191307;
  border-top-color: transparent;
  display: inline-block;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.connect-form {
  display: flex;
  gap: 10px;
}
.id-input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.1em;
  padding: 14px 16px;
  text-align: center;
}
.id-input:focus {
  outline: none;
  border-color: var(--amber-dim);
}
.id-input::placeholder { color: #4a4f56; }

.status-line {
  min-height: 20px;
  margin: 18px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--text-dim);
}
.status-line.error { color: var(--danger); }
.status-line.ok { color: var(--ok); }

.footnote {
  margin-top: auto;
  padding-top: 24px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #565b62;
  text-align: center;
}

/* ---------- settings screen ---------- */
.settings-header { border-bottom: 1px solid var(--line); margin: -20px -20px 20px; padding-inline: 16px; }
.settings-body { display: flex; flex-direction: column; gap: 24px; }
.settings-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
}
.settings-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}
.settings-text {
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-dim);
}

/* ---------- searching screen ---------- */
#screen-search {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.dial-wrap { margin-bottom: 28px; }
.dial {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, var(--panel-2), var(--panel) 70%);
  border: 1px solid var(--line);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 6px #0000004d inset,
    0 0 40px rgba(245, 166, 35, 0.08);
}
.dial::before {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px dashed #33383e;
}
.dial-face {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dial-needle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 78px;
  background: linear-gradient(to top, var(--amber), transparent);
  transform-origin: bottom center;
  transform: translate(-50%, -100%) rotate(0deg);
  animation: sweep 2.4s linear infinite;
  box-shadow: 0 0 10px rgba(245, 166, 35, 0.7);
}
@keyframes sweep {
  0%   { transform: translate(-50%, -100%) rotate(0deg); }
  100% { transform: translate(-50%, -100%) rotate(360deg); }
}
.dial-center {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  white-space: nowrap;
}
.scan-text {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--amber);
  margin: 0 0 28px;
}
@media (prefers-reduced-motion: reduce) {
  .dial-needle { animation: none; }
}

/* ---------- invite toast ---------- */
.invite-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 1000;
  background: var(--panel-2);
  border: 1px solid var(--amber-dim);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-width: 448px;
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.invite-toast p {
  margin: 0 0 12px;
  font-size: 14px;
}
#invite-from {
  font-family: var(--mono);
  color: var(--amber);
  letter-spacing: 0.06em;
}
.invite-actions {
  display: flex;
  gap: 10px;
}
.invite-actions .btn { width: auto; flex: 1; }

/* ---------- chat screen ---------- */
#screen-chat { padding-left: 0; padding-right: 0; max-width: 560px; }
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  padding: 4px 8px;
  border-radius: 8px;
}
.icon-btn:active { background: var(--panel-2); }
.chat-peer {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.peer-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.peer-id {
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--amber);
  white-space: nowrap;
}
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px 1px rgba(94, 203, 138, 0.7);
  flex-shrink: 0;
}
.live-dot.offline {
  background: #5a5f66;
  box-shadow: none;
}

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

.msg {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
/* own messages sit on the right, matching common Hebrew chat-app
   convention, regardless of the page's RTL base direction */
.msg.me {
  align-self: flex-start;
  background: var(--amber);
  color: #191307;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}
.msg.them {
  align-self: flex-end;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 4px;
}
.msg.system {
  align-self: center;
  background: none;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
}

.typing-indicator {
  padding: 0 16px 6px;
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.message-form {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.message-input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  font-size: 15px;
  padding: 12px 18px;
}
.message-input:focus { outline: none; border-color: var(--amber-dim); }
.message-input::placeholder { color: #4a4f56; }

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  font-size: 16px;
}

/* ---------- small screens polish ---------- */
@media (max-width: 360px) {
  .id-display { font-size: 24px; }
  .dial { width: 180px; height: 180px; }
}

/* ============================================================
   Reporting, blocking, support chat, admin dashboard
   ============================================================ */

.report-btn {
  font-size: 16px;
  color: var(--text-dim);
}
.report-btn.armed {
  color: var(--danger);
}

.signout-btn {
  color: var(--danger);
  border: 1px solid var(--danger-dim);
}
.signout-btn:active { background: var(--danger-dim); }

/* ---------- admin undercover panel (act as a regular user) ---------- */
.admin-undercover-panel {
  margin: 14px 16px 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--amber-dim);
  border-radius: var(--radius);
}
.admin-undercover-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--amber);
  margin: 0 0 10px;
}
.admin-undercover-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.admin-undercover-row .connect-form { flex: 1; }
.admin-undercover-row .btn.small { padding: 10px 14px; }
.admin-undercover-row .id-input { padding: 10px 12px; font-size: 15px; }
.admin-premark-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
}
#admin-undercover-status { margin-top: 8px; min-height: 0; }

.admin-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  background: rgba(245, 166, 35, 0.14);
  border: 1px solid var(--amber-dim);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.admin-reveal-btn { color: var(--amber); }

.blocked-notice { text-align: center; }
#blocked-notice .settings-text { text-align: center; }

/* ---------- modal overlay (admin login / block reason) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(6, 7, 8, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
}
.admin-input {
  width: 100%;
  text-align: right;
  letter-spacing: normal;
  font-family: var(--sans);
  font-size: 15px;
  margin-bottom: 10px;
}
.block-reason-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
  padding: 12px 14px;
}

/* ---------- tabs ---------- */
.tab-bar {
  display: flex;
  gap: 8px;
  padding: 14px 16px 0;
}
.tab-btn {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 10px 8px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tab-btn.active {
  background: var(--panel-2);
  color: var(--amber);
  border-color: var(--amber-dim);
}
.tab-badge {
  background: var(--danger);
  color: #1a0d0b;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

/* ---------- admin views / lists ---------- */
.admin-view {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-empty {
  text-align: center;
  margin-top: 40px;
}
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-card, .blocked-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.card-id {
  font-family: var(--mono);
  color: var(--amber);
  letter-spacing: 0.05em;
}
.card-time { font-size: 11.5px; color: #6b7076; }

.report-messages {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 160px;
  overflow-y: auto;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.report-messages .msg { max-width: 90%; font-size: 13px; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.card-actions .btn { width: auto; flex: 1; min-width: 100px; padding: 10px 10px; font-size: 13px; }

.blocked-card .settings-text { margin: 6px 0 10px; font-size: 12.5px; }
.blocked-reason-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel-2);
  border-radius: 6px;
  padding: 4px 8px;
  margin: 4px 0 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
}
.toggle-row button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}
.toggle-row button.on {
  background: var(--amber);
  color: #191307;
  border-color: var(--amber);
}

.admin-chat-view {
  padding: 0;
  display: flex;
  flex-direction: column;
}
.admin-chat-header {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}
#admin-chat-messages {
  padding: 16px;
}

.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-inline-start: 7px;
  box-shadow: 0 0 5px 1px rgba(226, 87, 76, 0.6);
  vertical-align: middle;
}
