/* Standalone Klyde People Database — opaque panels (no bg animation bleed-through) */

#view-people-database .people-db-warning-notice {
  margin-top: 0;
  margin-bottom: 1rem;
}

#view-people-database .people-db-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  min-height: 0;
}

#view-people-database .people-db-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

#view-people-database .people-db-search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  flex: 1 1 280px;
}

#view-people-database .people-db-search-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 220px;
  font-size: 0.8rem;
  color: var(--text-muted, #9aa8bc);
}

#view-people-database .people-db-search-form input {
  width: 100%;
  min-height: 2.4rem;
}

#view-people-database .people-db-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

#view-people-database .people-db-count {
  font-size: 0.85rem;
  color: var(--text-muted, #9aa8bc);
  margin: 0 0 0.5rem;
}

#view-people-database .people-db-status {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted, #9aa8bc);
}

#view-people-database .people-db-status-error {
  color: #f87171;
}

#view-people-database .people-db-panel {
  /* Solid surface so background animation is not visible through the panel */
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  min-height: 420px;
  max-height: calc(100vh - 220px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--panel-shadow);
  isolation: isolate;
}

#view-people-database .people-db-panel-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

#view-people-database .people-db-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-height: 0;
}

#view-people-database .people-db-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  text-align: left;
  width: 100%;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#view-people-database .people-db-card:hover {
  border-color: var(--border);
  background: var(--bg-hover);
}

#view-people-database .people-db-card.is-selected {
  border-color: var(--accent);
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

#view-people-database .people-db-card-body {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

#view-people-database .people-db-card-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}

#view-people-database .people-db-card-name {
  display: inline;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Active Wants pill — left of name in search results; red/blue emergency pulse */
#view-people-database .people-db-active-wants-pill {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  color: #fff;
  background: #b91c1c;
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: people-db-active-wants-pill-pulse 1.1s ease-in-out infinite;
}

@keyframes people-db-active-wants-pill-pulse {
  0%,
  100% {
    background: #b91c1c;
    color: #fff;
    box-shadow:
      0 0 0 1px rgba(239, 68, 68, 0.85),
      0 0 10px rgba(239, 68, 68, 0.55);
  }
  50% {
    background: #1d4ed8;
    color: #fff;
    box-shadow:
      0 0 0 1px rgba(59, 130, 246, 0.9),
      0 0 12px rgba(59, 130, 246, 0.65);
  }
}

@media (prefers-reduced-motion: reduce) {
  #view-people-database .people-db-active-wants-pill {
    animation: none;
    background: #b91c1c;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.85);
  }
}

#view-people-database .people-db-photo-expandable,
#view-people-database img.record-photo {
  cursor: zoom-in;
}

#view-people-database .people-db-detail-header .people-db-photo-expandable,
#view-people-database .people-db-detail-header img.record-photo {
  cursor: zoom-in;
  border-radius: 12px;
}

/* Large mugshot frame (left side of profile detail) */
#view-people-database .people-db-photo-frame {
  flex-shrink: 0;
  display: inline-flex;
  border-radius: 14px;
  padding: 0;
  background: transparent;
  line-height: 0;
}

#view-people-database .people-db-photo-frame-lg .people-db-avatar,
#view-people-database .people-db-photo-frame-lg .dispatch-person-avatar,
#view-people-database .people-db-photo-frame-lg img {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

/* Critical offender tag — entire detail panel outline pulses red */
#view-people-database #people-db-detail.people-db-detail--critical,
#view-people-database .people-db-panel.people-db-detail.people-db-detail--critical {
  border-color: #ef4444;
  box-shadow:
    0 0 0 1px rgba(239, 68, 68, 0.85),
    0 0 18px rgba(239, 68, 68, 0.55);
  animation: people-db-critical-panel-pulse 1.35s ease-in-out infinite;
}

/* Active Want — blue/red emergency pulse (matches Dispatch emergency priority glow) */
#view-people-database #people-db-detail.people-db-detail--want,
#view-people-database .people-db-panel.people-db-detail.people-db-detail--want {
  border-color: #ef4444;
  animation: people-db-want-emergency-pulse 1.1s ease-in-out infinite;
}

@keyframes people-db-critical-panel-pulse {
  0%,
  100% {
    border-color: rgba(239, 68, 68, 0.95);
    box-shadow:
      0 0 0 1px rgba(239, 68, 68, 0.9),
      0 0 12px rgba(239, 68, 68, 0.5),
      0 0 28px rgba(239, 68, 68, 0.28);
  }
  50% {
    border-color: rgba(248, 113, 113, 1);
    box-shadow:
      0 0 0 2px rgba(239, 68, 68, 0.98),
      0 0 22px rgba(239, 68, 68, 0.85),
      0 0 44px rgba(239, 68, 68, 0.45);
  }
}

@keyframes people-db-want-emergency-pulse {
  0%,
  100% {
    border-color: rgba(239, 68, 68, 0.95);
    box-shadow:
      0 0 14px 2px rgba(239, 68, 68, 0.78),
      0 0 34px 9px rgba(239, 68, 68, 0.44),
      0 0 56px 18px rgba(239, 68, 68, 0.2);
  }
  50% {
    border-color: rgba(59, 130, 246, 0.95);
    box-shadow:
      0 0 14px 2px rgba(59, 130, 246, 0.78),
      0 0 34px 9px rgba(59, 130, 246, 0.44),
      0 0 56px 18px rgba(59, 130, 246, 0.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  #view-people-database #people-db-detail.people-db-detail--critical,
  #view-people-database .people-db-panel.people-db-detail.people-db-detail--critical {
    animation: none;
    box-shadow:
      0 0 0 2px rgba(239, 68, 68, 0.95),
      0 0 18px rgba(239, 68, 68, 0.6);
  }

  #view-people-database #people-db-detail.people-db-detail--want,
  #view-people-database .people-db-panel.people-db-detail.people-db-detail--want {
    animation: none;
    border-color: #ef4444;
    box-shadow:
      0 0 0 2px rgba(239, 68, 68, 0.85),
      0 0 16px rgba(59, 130, 246, 0.55);
  }
}

/* Officer notes (forum-style) */
#view-people-database .people-db-officer-notes-section {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

#view-people-database .people-db-officer-notes-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

#view-people-database .people-db-officer-notes-toggle:hover {
  border-color: var(--border);
  background: var(--bg-hover);
}

#view-people-database .people-db-officer-notes-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.95rem;
}

#view-people-database .people-db-notes-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
  background: #2563eb;
}

#view-people-database .people-db-officer-notes-chevron {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#view-people-database .people-db-officer-notes-panel {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.75rem;
}

#view-people-database .people-db-officer-note-composer {
  display: grid;
  gap: 0.5rem;
}

#view-people-database .people-db-officer-note-composer label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#view-people-database .people-db-officer-note-composer textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
  resize: vertical;
}

#view-people-database .people-db-officer-note-composer-actions {
  display: flex;
  justify-content: flex-end;
}

#view-people-database .people-db-officer-notes-thread {
  display: grid;
  gap: 0.65rem;
}

#view-people-database .people-db-officer-note {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  padding: 0.7rem 0.8rem;
  display: grid;
  gap: 0.45rem;
}

#view-people-database .people-db-officer-note-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#view-people-database .people-db-officer-note-author {
  display: block;
  font-size: 0.92rem;
}

#view-people-database .people-db-officer-note-agency {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

#view-people-database .people-db-officer-note-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

#view-people-database .people-db-officer-note-body {
  margin: 0;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Wants section */
#view-people-database .people-db-wants-section {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.75rem;
}

#view-people-database .people-db-wants-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#view-people-database .people-db-wants-title {
  margin: 0;
  font-size: 1rem;
}

#view-people-database .people-db-want-disclaimer {
  margin-bottom: 0;
}

#view-people-database .people-db-wants-list {
  display: grid;
  gap: 0.65rem;
}

#view-people-database .people-db-want-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  padding: 0.75rem 0.85rem;
  display: grid;
  gap: 0.45rem;
}

#view-people-database .people-db-want-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

#view-people-database .people-db-want-meta,
#view-people-database .people-db-want-body {
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

#view-people-database .people-db-want-meta span,
#view-people-database .people-db-want-body span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

#view-people-database .people-db-want-footer {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Add Want modal */
.people-db-want-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.people-db-want-modal.hidden {
  display: none;
}

.people-db-want-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.people-db-want-modal-shell {
  position: relative;
  z-index: 1;
  width: min(96vw, 560px);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0a0a;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  isolation: isolate;
}

html[data-theme="light"] .people-db-want-modal-shell {
  background: #ffffff;
}

.people-db-want-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;
}

.people-db-want-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.people-db-want-modal-body {
  padding: 1rem 1.1rem 1.15rem;
  display: grid;
  gap: 0.85rem;
}

.people-db-want-modal-body label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.people-db-want-modal-body input,
.people-db-want-modal-body select,
.people-db-want-modal-body textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.people-db-want-modal-body input[readonly] {
  opacity: 0.9;
  cursor: not-allowed;
}

.people-db-want-modal-body input.people-db-want-agency-editable {
  opacity: 1;
  cursor: text;
}

.people-db-want-target {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-word;
}

.people-db-want-error {
  margin: 0;
  color: #f87171;
  font-size: 0.88rem;
}

.people-db-want-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

#view-people-database .people-db-card-lines {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#view-people-database .people-db-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted, #9aa8bc);
}

#view-people-database .people-db-avatar,
#view-people-database .people-db-avatar-placeholder,
#view-people-database .dispatch-person-avatar {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

#view-people-database .people-db-avatar.lg,
#view-people-database .dispatch-person-avatar.lg {
  width: 96px;
  height: 96px;
  border-radius: 12px;
}

#view-people-database .people-db-avatar-placeholder {
  display: grid;
  place-items: center;
  background: var(--bg-hover);
  font-weight: 700;
  font-size: 0.85rem;
}

#view-people-database .people-db-empty {
  margin: 0.5rem 0;
  color: var(--text-muted, #9aa8bc);
  font-size: 0.9rem;
}

#view-people-database .people-db-load-more-wrap {
  margin-top: 0.6rem;
}

#view-people-database .people-db-detail {
  overflow: auto;
  min-height: 0;
}

#view-people-database .people-db-detail-empty {
  display: grid;
  gap: 0.75rem;
  place-content: center;
  text-align: center;
  min-height: 280px;
  padding: 1.5rem;
  color: var(--text-muted, #9aa8bc);
}

#view-people-database .people-db-detail-empty h3 {
  margin: 0;
  color: inherit;
}

#view-people-database .people-db-detail-card {
  display: grid;
  gap: 1rem;
}

#view-people-database .people-db-detail-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: start;
}

#view-people-database .people-db-detail-name {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

#view-people-database .people-db-detail-sub {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted, #9aa8bc);
}

#view-people-database .people-db-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
  margin: 0;
}

#view-people-database .people-db-detail-grid > div {
  display: grid;
  gap: 0.2rem;
}

#view-people-database .people-db-detail-grid dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #9aa8bc);
}

#view-people-database .people-db-detail-grid dd {
  margin: 0;
  font-size: 0.95rem;
  word-break: break-word;
}

#view-people-database .people-db-detail-span {
  grid-column: 1 / -1;
}

#view-people-database .people-db-detail-notes {
  white-space: pre-wrap;
}

#view-people-database .people-db-created-when {
  display: block;
}

#view-people-database .people-db-created-by {
  display: block;
  font-weight: 600;
  margin-top: 0.15rem;
}

#view-people-database .people-db-created-agency {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.88rem;
  color: var(--text-muted, #9aa8bc);
}

#view-people-database .people-db-mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text-muted, #9aa8bc);
}

@media (max-width: 960px) {
  #view-people-database .people-db-layout {
    grid-template-columns: 1fr;
  }

  #view-people-database .people-db-panel {
    max-height: none;
  }

  #view-people-database .people-db-detail-header {
    grid-template-columns: auto 1fr;
  }

  #view-people-database .people-db-detail-actions {
    grid-column: 1 / -1;
  }

  #view-people-database .people-db-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Role on Call (call-card create only — injected, not on master People Profile) */
.dispatch-person-profile-role-on-call {
  padding: 0 1.1rem 0.75rem;
}

.dispatch-person-profile-role-on-call .dispatch-person-profile-role-field {
  display: grid;
  gap: 0.3rem;
  max-width: 280px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Staff-only delete control */
#view-people-database .people-db-delete-btn,
.people-db-delete-btn {
  background: #b91c1c !important;
  border-color: #991b1b !important;
  color: #ffffff !important;
}

#view-people-database .people-db-delete-btn:hover,
.people-db-delete-btn:hover {
  background: #991b1b !important;
  border-color: #7f1d1d !important;
  color: #ffffff !important;
}

#view-people-database .people-db-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.people-db-delete-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.people-db-delete-modal.hidden {
  display: none;
}

.people-db-delete-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.people-db-delete-modal-shell {
  position: relative;
  z-index: 1;
  width: min(96vw, 520px);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0a0a;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  isolation: isolate;
}

html[data-theme="light"] .people-db-delete-modal-shell {
  background: #ffffff;
}

.people-db-delete-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.people-db-delete-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.people-db-delete-modal-body {
  padding: 1rem 1.1rem 1.15rem;
  display: grid;
  gap: 0.85rem;
}

.people-db-delete-warning {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.people-db-delete-target {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-word;
}

.people-db-delete-reason-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.people-db-delete-reason-label textarea {
  width: 100%;
  min-height: 6rem;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

.people-db-delete-error {
  margin: 0;
  color: #f87171;
  font-size: 0.88rem;
}

.people-db-delete-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Person edit/create modal — fully opaque shell (modals live outside .view) */
#dispatch-person-modal .dispatch-submodal-shell,
#dispatch-person-modal .dispatch-person-profile-shell {
  background: var(--bg-surface) !important;
  opacity: 1 !important;
  isolation: isolate;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

#dispatch-person-modal .dispatch-person-profile-header,
#dispatch-person-modal .dispatch-submodal-body,
#dispatch-person-modal .dispatch-person-profile-form {
  background: var(--bg-surface);
}

#dispatch-duplicate-modal .dispatch-submodal-shell {
  background: var(--bg-surface) !important;
  opacity: 1 !important;
  isolation: isolate;
}

html[data-theme="light"] #view-people-database .people-db-panel,
html[data-theme="light"] #dispatch-person-modal .dispatch-submodal-shell,
html[data-theme="light"] #dispatch-person-modal .dispatch-person-profile-shell,
html[data-theme="light"] #dispatch-duplicate-modal .dispatch-submodal-shell {
  background: #ffffff !important;
  box-shadow: 0 12px 40px rgba(22, 33, 15, 0.14);
}

html[data-theme="light"] #dispatch-person-modal .dispatch-person-profile-header,
html[data-theme="light"] #dispatch-person-modal .dispatch-submodal-body,
html[data-theme="light"] #dispatch-person-modal .dispatch-person-profile-form {
  background: #ffffff;
}
