/* modals.css — Modal overlays, profile cards, context menu, toasts, pin list */

/* ── Help Modal ── */
#help-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#help-modal-overlay.open { display: flex; }

#help-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.2rem;
  position: relative;
}

#help-modal h2 {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: var(--space-lg);
}

#help-modal h4 {
  font-size: var(--text-sm);
  color: var(--text);
  margin: var(--space-lg) 0 var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#help-modal .cmd {
  font-size: var(--text-sm);
  padding: var(--space-xs) 0;
  color: var(--text-muted);
  line-height: 1.5;
}

#help-modal .cmd code {
  background: var(--bg-hover);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: monospace;
  font-size: var(--text-sm);
}

#help-close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-xl);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-xl);
  cursor: pointer;
}
#help-close:hover { color: var(--text); }

/* ── Context Menu ── */
#user-context-menu {
  display: none;
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 150px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  padding: var(--space-sm) 0;
}
#user-context-menu.open { display: block; }
.ctx-item {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.ctx-item:hover { background: var(--bg-hover); color: var(--accent); }
.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: var(--space-xs) 0;
}

/* ── Profile Modals ── */
.profile-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  align-items: center;
  justify-content: center;
}
.profile-modal-overlay.open { display: flex; }

.profile-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.2rem;
  position: relative;
}

.profile-modal h2 {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: var(--space-lg);
}

.profile-modal label {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  margin-top: var(--space-lg);
}

.profile-modal textarea,
.profile-modal input[type="text"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  outline: none;
  resize: vertical;
}

.profile-modal textarea:focus,
.profile-modal input[type="text"]:focus { border-color: var(--accent); }

.profile-modal .bio-counter {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: right;
  margin-top: var(--space-xs);
}
.profile-modal .bio-counter.warn { color: var(--warning); }
.profile-modal .bio-counter.over { color: var(--danger); font-weight: 600; }

.profile-modal .btn-row {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  justify-content: flex-end;
}

.profile-modal .btn-save {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.45rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  font-weight: 600;
}
.profile-modal .btn-save:hover { background: var(--accent-hover); }

.profile-modal .btn-cancel {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.45rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
}
.profile-modal .btn-cancel:hover { color: var(--text); border-color: var(--text-muted); }

.profile-modal .close-btn {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-xl);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-xl);
  cursor: pointer;
}
.profile-modal .close-btn:hover { color: var(--text); }

/* ── Edit Profile: field row with privacy toggle ── */
.profile-field-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
}
.profile-field-row label { margin: 0; flex: 1; }
/* Lock/globe button that toggles per-field privacy. */
.privacy-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-xs) var(--space-sm);
  line-height: 1.2;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.privacy-toggle:hover { color: var(--accent); border-color: var(--accent); }
/* When marked private the icon shows a lock and the border turns accent-coloured. */
.privacy-toggle.is-private { color: var(--accent); border-color: var(--accent); }

/* ── View Profile Card: banner + avatar ── */
.profile-card-banner {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: -36px; /* let avatar overlap the banner */
  display: block;
}
.profile-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg-secondary);
  flex-shrink: 0;
}
.profile-card-badge {
  display: inline-block;
  font-size: var(--text-xs);
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: var(--space-xs) var(--space-md);
  color: var(--text-muted);
  margin-left: var(--space-sm);
}

/* ── View Profile Card ── */
.profile-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.profile-card-header .identicon-large {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
}
.profile-card-header .profile-name {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text);
}
.profile-card-bio {
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.5;
  margin-bottom: var(--space-lg);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.profile-card-socials {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.profile-card-socials a {
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
}
.profile-card-socials a:hover { text-decoration: underline; }
.profile-card-socials .social-item {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.profile-card-socials .social-label {
  color: var(--text-muted);
  min-width: 70px;
  display: inline-block;
}
.profile-card-key {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: monospace;
  cursor: pointer;
  word-break: break-all;
}
.profile-card-key:hover { color: var(--accent); }
.profile-card-empty {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
  margin: var(--space-lg) 0;
}

/* ── Pin Bar ── */
#pin-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
  cursor: pointer;
  display: none;
  user-select: none;
}
#pin-bar:hover { background: var(--bg-hover); }
#pin-bar .pin-summary {
  color: var(--text-muted);
}
#pin-bar .pin-summary .pin-icon { color: var(--accent); }

#pin-list {
  display: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
}
#pin-list.open { display: block; }

.pin-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  font-size: var(--text-sm);
}
.pin-card .pin-card-author {
  font-weight: 600;
  color: var(--accent);
  font-size: var(--text-sm);
}
.pin-card .pin-card-body {
  color: var(--text);
  margin-top: var(--space-xs);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 60px;
  overflow: hidden;
  cursor: pointer;
  transition: max-height 0.25s ease;
}
.pin-card.expanded .pin-card-body {
  max-height: none;
}
.pin-card .pin-expand-hint {
  font-size: 0.6rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: var(--space-xs);
  opacity: 0.7;
}
.pin-card .pin-expand-hint:hover { opacity: 1; }
.pin-card.expanded .pin-expand-hint .hint-expand { display: none; }
.pin-card:not(.expanded) .pin-expand-hint .hint-collapse { display: none; }
.pin-card .pin-card-meta {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}
.pin-card .pin-unpin {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-xs);
  padding: 0 var(--space-sm);
  border-radius: var(--radius-sm);
}
.pin-card .pin-unpin:hover { color: var(--error, #e55); background: rgba(255,255,255,0.05); }
.pin-section-header {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border);
}
.pin-section-header:not(:first-child) { margin-top: var(--space-md); }

/* ── Thread panel ── */
#thread-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 90vw);
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 2000;
  display: none;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}
#thread-panel.open { display: flex; }
#thread-panel-header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
#thread-panel-header button {
  background: none; border: none; color: var(--text-muted);
  font-size: var(--text-2xl); cursor: pointer;
}
#thread-panel-header button:hover { color: var(--text); }
#thread-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}
#thread-panel-messages .thread-msg {
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}
#thread-panel-messages .thread-msg .thread-msg-author {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--accent);
}
#thread-panel-messages .thread-msg .thread-msg-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: var(--space-md);
}
#thread-panel-messages .thread-msg .thread-msg-body {
  font-size: var(--text-sm);
  margin-top: var(--space-sm);
}
#thread-panel-messages .thread-parent {
  border-left: 3px solid var(--accent);
  margin-bottom: var(--space-xl);
}
#thread-panel-input {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-md);
}
#thread-panel-input textarea {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-sm);
  resize: none;
  min-height: 36px;
  max-height: 100px;
}
#thread-panel-input button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  padding: var(--space-md) var(--space-xl);
  cursor: pointer;
  font-size: var(--text-sm);
}

/* ── Feature 1: Message Search ── */
#search-bar {
  display: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  animation: noticeFadeIn 0.2s ease;
}
#search-bar.open { display: block; }
#search-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  outline: none;
  font-family: inherit;
}
#search-bar input:focus { border-color: var(--accent); }
#search-bar .search-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}
#search-bar .search-close:hover { color: var(--text); }
#search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  max-height: 400px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
#search-results.open { display: block; }
.search-result {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.search-result:hover { background: var(--bg-hover); }
.search-result .sr-meta {
  display: flex;
  gap: var(--space-md);
  align-items: baseline;
  margin-bottom: var(--space-xs);
}
.search-result .sr-author { font-weight: 600; color: var(--accent); }
.search-result .sr-channel { color: var(--text-muted); font-size: var(--text-xs); }
.search-result .sr-time { color: var(--text-muted); font-size: var(--text-xs); }
.search-result .sr-body { color: var(--text); }
.search-result .sr-body mark {
  background: rgba(224,112,32,0.3);
  color: var(--text);
  padding: 0 var(--space-xs);
  border-radius: 2px;
}

/* Status picker modal */
#status-picker {
  display: none;
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  z-index: 200;
  min-width: 220px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
#status-picker.open { display: block; }
#status-picker h4 {
  font-size: var(--text-sm);
  color: var(--text);
  margin-bottom: var(--space-md);
}
.status-option {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text);
}
.status-option:hover { background: var(--bg-hover); }
.status-option.active { background: var(--accent-dim); color: var(--accent); }
.status-option .status-label { flex: 1; }
#status-text-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  outline: none;
  margin-top: var(--space-md);
  font-family: inherit;
}
#status-text-input:focus { border-color: var(--accent); }
.status-clear-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  cursor: pointer;
  margin-top: var(--space-sm);
  width: 100%;
}
.status-clear-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* Mobile modal tweaks */
@media (max-width: 640px) {
  /* Profile modals: full-width on mobile */
  .profile-modal {
    width: 95%;
    max-width: none;
    max-height: 90vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  /* Help modal: full-width, scrollable */
  #help-modal {
    width: 95%;
    max-width: none;
    max-height: 85vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  /* Login page adjustments */
  #login-screen h1 { font-size: 1.5rem; }
  #login-screen p { font-size: var(--text-sm); }
  #login-screen input { width: 100%; max-width: 340px; }
  #login-screen button { width: 100%; max-width: 340px; }
}
