/* ─── Szerzői admin — alap elrendezés ────────────────────────────────────── */
/* Ugyanazokat a CSS-változókat használja, mint a css/styles.css (--bg, --text,
   --card, --border, --accent, --muted) — az admin.html mindkettőt betölti. */

/* `.admin-view` a meglévő `.view` (flex:1, overflow-y:auto, lásd styles.css)
   mellett él az admin-view elemen — itt csak a keskenyebb max-width-ot írjuk felül. */
.admin-view {
  max-width: 720px;
  box-sizing: border-box;
}

.admin-tabbar {
  display: flex;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--card);
  padding-bottom: env(safe-area-inset-bottom);
}

.admin-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.admin-tab-btn.active {
  color: var(--accent);
  font-weight: 600;
}

.admin-tab-icon {
  position: relative;
  font-size: 18px;
}

.admin-tab-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* ─── Bejelentkezés / státusz-képernyők ──────────────────────────────────── */

.admin-signin,
.admin-status {
  text-align: center;
  padding: 40px 16px;
}

.admin-signin h1,
.admin-status h1 {
  font-size: 22px;
  margin-bottom: 10px;
}

.admin-signin p,
.admin-status p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  max-width: 420px;
  margin: 0 auto 16px;
}

.admin-signin-btn {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 10px;
}

.admin-signin-hint {
  font-size: 13px;
  margin-top: 18px;
}

/* ─── Eszköztár + lista ──────────────────────────────────────────────────── */

.admin-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-empty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 30px 0;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-group {
  margin-bottom: 18px;
}

.admin-group h3 {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.admin-row-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-row-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.admin-row-head {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-row-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.admin-icon-btn {
  border: none;
  background: transparent;
  font-size: 16px;
  padding: 4px 6px;
  color: var(--text);
}

.admin-icon-btn:disabled {
  opacity: 0.3;
}

/* ─── Szerkesztő ─────────────────────────────────────────────────────────── */

.admin-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.admin-field input,
.admin-field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.admin-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.admin-hint {
  color: var(--muted);
  font-size: 13px;
}

.admin-editor-tools {
  display: flex;
  gap: 16px;
}

.admin-link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

.admin-link-btn-danger {
  color: #ff3b30;
}

.admin-body-editor {
  min-height: 320px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.admin-preview {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-family: var(--reader-font, Georgia, serif);
  font-size: 16px;
  line-height: 1.6;
}

.admin-preview p {
  margin: 0 0 12px;
}

/* ─── Profil fotó ────────────────────────────────────────────────────────── */

.admin-photo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-photo-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card);
  border: 1px solid var(--border);
}

.admin-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.admin-photo-pick {
  cursor: pointer;
}

/* ─── Üzenetszál ─────────────────────────────────────────────────────────── */

.admin-thread-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-thread-bubbles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-bubble {
  align-self: flex-start;
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 14px;
  position: relative;
}

.admin-bubble.mine {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 15%, var(--card));
}

/* Teljesen a buborék sarkán KÍVÜLRE, egy kis piros körbe pozícionálva (negatív
   eltolás) — így sosem lóg rá a szöveg első sorára, szemben a korábbi, a padding-
   dobozon belüli elhelyezéssel. */
.admin-bubble .admin-icon-btn {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 20px;
  height: 20px;
  font-size: 11px;
  line-height: 20px;
  padding: 0;
  border-radius: 50%;
  background: #ff3b30;
  color: #fff;
}

.admin-reply-form {
  display: flex;
  gap: 8px;
}

.admin-reply-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.admin-status-msg {
  color: var(--muted);
  font-size: 13px;
}

/* ─── Életjel ────────────────────────────────────────────────────────────── */

.dispatch-camera-video {
  width: 100%;
  max-height: 280px;
  border-radius: 12px;
  background: #000;
  /* Tükrözött előnézet — mint egy önkamerás appban —, hogy a user helyesen,
     "tükörként" lássa saját magát felvétel közben (a `capture()` ugyanígy
     tükrözi a kész fotót, lásd media/camera.js). */
  transform: scaleX(-1);
  object-fit: cover;
}

.dispatch-photo-preview {
  max-width: 100%;
  max-height: 280px;
  border-radius: 12px;
  object-fit: contain;
}

.dispatch-audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Hely a jobb felső sarkon kívül lebegő törlés-jelvénynek — enélkül az időkijelzés
     (pl. "0:03") szövege túl közel ér a doboz széléhez, és a jelvény ráfedne. */
  padding-right: 16px;
}

/* A fotó/hang előnézet jobb felső sarkán KÍVÜL lebegő, piros körös "eltávolítás"
   jelvény — ugyanaz a minta, mint az üzenet-visszavonásnál (.admin-bubble
   .admin-icon-btn), hogy a gomb sosem lógjon rá magára az előnézetre. */
.dispatch-media-wrap {
  position: relative;
  display: inline-block;
}

.media-remove-btn {
  position: absolute;
  top: -9px;
  right: -14px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  padding: 0;
}

.dispatch-preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dispatch-preview-overlay.open {
  display: flex;
}

.dispatch-preview-box {
  position: relative;
  max-width: 480px;
  width: 100%;
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dispatch-preview-photo {
  width: 100%;
  border-radius: 12px;
  object-fit: contain;
}

.dispatch-preview-audio {
  display: flex;
  justify-content: center;
}

.dispatch-preview-box .chat-close {
  position: absolute;
  top: -10px;
  right: -10px;
}

/* ─── Szuperadmin ──────────────────────────────────────────────────────── */

.sa-overview {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.sa-stat {
  flex: 1;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.sa-stat strong { font-size: 22px; font-family: Georgia, serif; }
.sa-stat span { font-size: 12px; color: var(--muted); }

.sa-stat-attn {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
}

.sa-refresh { align-self: center; width: 40px; height: 40px; font-size: 18px; }

.sa-tabs { margin-bottom: 14px; }

.sa-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
}

.seg-btn.active .sa-count { background: #fff; color: var(--accent); }

.sa-error { color: #ff3b30; }

.sa-h2 {
  font-family: Georgia, serif;
  font-size: 18px;
  margin: 18px 0 10px;
}

.sa-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sa-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sa-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sa-card-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sa-card-title strong { font-size: 17px; }

.sa-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sa-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.sa-badge-green  { color: #34c759; background: color-mix(in srgb, #34c759 15%, transparent); }
.sa-badge-red    { color: #ff3b30; background: color-mix(in srgb, #ff3b30 15%, transparent); }
.sa-badge-orange { color: #ff9500; background: color-mix(in srgb, #ff9500 15%, transparent); }
.sa-badge-blue   { color: #0a84ff; background: color-mix(in srgb, #0a84ff 15%, transparent); }
.sa-badge-gray   { color: var(--muted); background: color-mix(in srgb, var(--muted) 15%, transparent); }

.sa-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.sa-details p { margin: 8px 0 0; font-size: 14px; line-height: 1.5; }

.sa-worklist {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
}

.sa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.sa-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  font-family: inherit;
}

.sa-btn-danger {
  color: #ff3b30;
  border-color: color-mix(in srgb, #ff3b30 40%, var(--border));
}

.sa-reason {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.sa-author-row { cursor: pointer; }
.sa-row-hidden .admin-row-main { opacity: 0.5; }
.sa-profile-panel { margin-bottom: 14px; }

/* Szuperadmin kapu — középre igazított űrlap (az .admin-signin text-align:center
   csak a szöveget középezi, a blokk-elemű formot nem). */
.sa-gate-form {
  max-width: 360px;
  margin: 0 auto;
  text-align: left;
}

.sa-gate-form .chat-btn { align-self: stretch; }
