/* Wiederverwendbare Bedienelemente: Buttons, Felder, Dialoge, Chips, Hinweise. */

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent-deep);
}

.btn:active:not(:disabled) {
  background: #dbe7e2;
}

.btn:disabled {
  color: var(--ink-muted);
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  border-color: var(--accent-deep);
  background: var(--accent);
  color: #ffffff;
}

.btn--primary:hover:not(:disabled) {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
  color: #ffffff;
}

.btn--danger {
  border-color: #dcc3c1;
  color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-wash);
  color: var(--danger);
}

.btn--quiet {
  border-color: transparent;
  background: transparent;
}

.btn--block {
  width: 100%;
  justify-content: flex-start;
}

.btn--sm {
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.btn--icon {
  min-height: 30px;
  width: 30px;
  padding: 0;
}

/* Zusammenhaengende Buttongruppe, z. B. Zoom oder Ansichtswechsel. */
.btn-group {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.btn-group .btn {
  min-height: 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.btn-group .btn + .btn {
  border-left: 1px solid var(--rule-soft);
}

.btn-group .btn[aria-pressed="true"] {
  background: var(--accent-wash);
  color: var(--accent-deep);
  font-weight: 600;
}

/* ---------- Formularfelder ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field > span {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea,
.input {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.field input:focus,
.field select:focus,
.input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.field input::placeholder,
.input::placeholder {
  color: var(--ink-muted);
}

.field-hint {
  color: var(--ink-muted);
  font-size: 12px;
}

/* Suchfeld mit Lupe als Inline-SVG-Hintergrund. */
.search-field {
  position: relative;
  display: block;
}

.search-field input {
  width: 100%;
  padding-left: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237c7568' stroke-width='1.5'%3E%3Ccircle cx='7' cy='7' r='4.25'/%3E%3Cpath d='M10.2 10.2 14 14' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px 50%;
  background-size: 14px;
}

.search-field input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent-line);
  background: var(--accent-wash);
  color: var(--accent-deep);
}

.chip__dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--male);
}

.chip__dot--female {
  background: var(--female);
}

.chip > span:not(.chip__dot) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Statusanzeige ---------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font-size: 12px;
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.status-pill.is-error {
  border-color: #dcc3c1;
  background: var(--danger-wash);
  color: var(--danger);
}

.status-pill.is-error::before {
  background: var(--danger);
}

/* ---------- Leerzustaende ---------- */

.empty-note {
  padding: 20px 16px;
  color: var(--ink-muted);
  font-size: 13px;
  text-align: center;
}

.empty-note strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- Dialoge ---------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 26, 22, 0.4);
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog {
  width: min(460px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--rule-soft);
}

.dialog__header h2 {
  font-family: var(--font-name);
  font-size: 18px;
  font-weight: 600;
}

.dialog__body {
  padding: 18px;
  overflow-y: auto;
}

.dialog__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--rule-soft);
  background: var(--surface-sunken);
}

.dialog__close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.dialog__close:hover {
  border-color: var(--rule);
  background: var(--surface-sunken);
  color: var(--ink);
}

.dialog__error {
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid #dcc3c1;
  border-radius: var(--radius);
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 13px;
}

.dialog__error:empty {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .field--wide {
  grid-column: 1 / -1;
}

/* ---------- Kontextmenue ---------- */

.context-menu {
  position: fixed;
  z-index: 70;
  min-width: 190px;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 9px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.context-menu button:hover {
  background: var(--accent-wash);
  color: var(--accent-deep);
}

.context-menu hr {
  margin: 4px 6px;
  border: 0;
  border-top: 1px solid var(--rule-soft);
}

/* ---------- Kurzmeldung ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  transform: translate(-50%, 8px);
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--ink);
  color: #f6f3ec;
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ---------- Portrait / Monogramm ---------- *
 * Ohne Foto zeigen wir die Initialen auf getoenter Flaeche.
 * Das wirkt in einer Chronik ruhiger als ein generisches Avatarbild.
 */

.portrait {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--male-wash);
  color: var(--male);
  font-family: var(--font-name);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
  user-select: none;
}

.portrait--female {
  background: var(--female-wash);
  color: var(--female);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
