/* ── HapciKanapé Live Translation Editor ── */

/* ── Toolbar ──────────────────────────────────────────────────────── */
#ht-edit-toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483640;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #1a1a2e;
  border-radius: 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,.45);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: #fff;
  user-select: none;
  white-space: nowrap;
}
#ht-edit-toolbar .ht-tb-brand {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .5px;
  color: #a78bfa;
  padding-right: 4px;
  border-right: 1px solid rgba(255,255,255,.15);
  margin-right: 2px;
}
#ht-edit-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  background: rgba(255,255,255,.1);
  color: #fff;
}
#ht-edit-toolbar button:hover { background: rgba(255,255,255,.2); }
#ht-edit-toolbar button:active { transform: scale(.95); }

#ht-edit-toolbar #ht-tb-toggle.active {
  background: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124,58,237,.4);
}
#ht-edit-toolbar #ht-tb-highlight.active { background: #dc2626; }
#ht-edit-toolbar #ht-tb-autotranslate { background: rgba(255,255,255,.08); }
#ht-edit-toolbar #ht-tb-autotranslate:hover { background: #059669; }
#ht-edit-toolbar #ht-tb-autotranslate.running { background: #d97706; cursor: wait; }
#ht-edit-toolbar #ht-tb-close {
  padding: 5px 8px;
  background: transparent;
  color: rgba(255,255,255,.5);
  font-size: 15px;
}
#ht-edit-toolbar #ht-tb-close:hover { background: rgba(255,0,0,.2); color: #fff; }
#ht-edit-toolbar #ht-tb-missing-count {
  font-size: 11px;
  color: #fbbf24;
  min-width: 26px;
  text-align: center;
}

/* ── Edit-mode active states on elements ──────────────────────────── */
body.ht-edit-active [data-i18n] {
  outline: 2px dashed rgba(124,58,237,.35) !important;
  outline-offset: 2px;
  cursor: pointer !important;
  transition: outline-color .15s;
}
body.ht-edit-active [data-i18n]:hover {
  outline-color: #7c3aed !important;
  background: rgba(124,58,237,.05) !important;
}

/* ── Missing-key highlight ────────────────────────────────────────── */
body.ht-highlight-missing [data-i18n].ht-missing {
  outline: 2px solid #ef4444 !important;
  background: rgba(239,68,68,.07) !important;
}
body.ht-highlight-missing [data-i18n].ht-translated {
  outline: 2px solid #22c55e !important;
  background: rgba(34,197,94,.04) !important;
}

/* ── Edit Popup ───────────────────────────────────────────────────── */
#ht-edit-popup {
  position: fixed;
  z-index: 2147483641;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, 96vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}
#ht-edit-popup.ht-popup-hidden { display: none !important; }

/* Header */
.ht-popup-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: #1a1a2e;
  color: #fff;
  flex-shrink: 0;
}
.ht-popup-head .ht-popup-icon { font-size: 18px; }
.ht-popup-head .ht-popup-key {
  font-size: 13px;
  font-weight: 700;
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: rgba(255,255,255,.12);
  padding: 2px 8px;
  border-radius: 6px;
  color: #a78bfa;
}
.ht-popup-head .ht-popup-section {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  margin-left: 2px;
}
.ht-popup-head .ht-popup-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,.5);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.ht-popup-head .ht-popup-close:hover { color: #fff; }

/* Lang tabs */
.ht-popup-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 14px 0;
  background: #f8f7ff;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.ht-popup-tabs::-webkit-scrollbar { display: none; }
.ht-tab {
  padding: 5px 10px;
  border-radius: 7px 7px 0 0;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #6b7280;
  white-space: nowrap;
  position: relative;
  transition: background .12s, color .12s;
}
.ht-tab:hover { background: rgba(124,58,237,.07); color: #7c3aed; }
.ht-tab.active {
  background: #fff;
  color: #7c3aed;
  border: 1px solid #e5e7eb;
  border-bottom-color: #fff;
  margin-bottom: -1px;
}
.ht-tab .ht-tab-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}
.ht-tab .ht-tab-dot.missing { background: #ef4444; }
.ht-tab .ht-tab-dot.ok      { background: #22c55e; }

/* Body */
.ht-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Source row */
.ht-source-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  border-left: 3px solid #a78bfa;
}
.ht-source-label {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  padding-top: 1px;
}
.ht-source-text {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  word-break: break-word;
}

/* Edit area */
.ht-edit-area label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.ht-edit-area textarea {
  width: 100%;
  min-height: 80px;
  max-height: 200px;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  transition: border-color .15s;
  box-sizing: border-box;
  color: #111827;
}
.ht-edit-area textarea:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124,58,237,.1);
}
.ht-edit-area textarea.changed { border-color: #f59e0b; }

/* Footer */
.ht-popup-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
  flex-shrink: 0;
}
.ht-popup-foot .ht-hint {
  font-size: 11px;
  color: #9ca3af;
  margin-right: auto;
}
.ht-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.ht-btn:active { transform: scale(.96); }
.ht-btn-primary { background: #7c3aed; color: #fff; }
.ht-btn-primary:hover { background: #6d28d9; }
.ht-btn-primary:disabled { background: #c4b5fd; cursor: not-allowed; }
.ht-btn-secondary { background: #f3f4f6; color: #374151; }
.ht-btn-secondary:hover { background: #e5e7eb; }
.ht-btn-deepl { background: #0f172a; color: #fff; }
.ht-btn-deepl:hover { background: #1e293b; }
.ht-btn-deepl:disabled { background: #94a3b8; cursor: not-allowed; }
.ht-btn-success { background: #059669; color: #fff; }

/* Save status */
.ht-save-status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  transition: opacity .3s;
}
.ht-save-status.ok    { background: #dcfce7; color: #16a34a; }
.ht-save-status.err   { background: #fee2e2; color: #dc2626; }
.ht-save-status.saving { background: #ede9fe; color: #7c3aed; }

/* ── Auto-translate modal ─────────────────────────────────────────── */
#ht-autotranslate-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483642;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px);
}
#ht-autotranslate-modal.hidden { display: none !important; }
.ht-at-box {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: min(520px, 94vw);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.ht-at-box h2 {
  font-size: 18px;
  font-weight: 800;
  color: #1a1a2e;
  margin: 0 0 6px;
}
.ht-at-box p {
  font-size: 13px;
  color: #6b7280;
  margin: 0 0 16px;
}
.ht-at-lang-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}
.ht-at-lang-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}
.ht-at-lang-item.has-missing {
  border-color: #fca5a5;
  background: #fff5f5;
  color: #dc2626;
}
.ht-at-lang-item.done {
  border-color: #86efac;
  background: #f0fdf4;
  color: #16a34a;
}
.ht-at-progress {
  width: 100%;
  height: 8px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}
.ht-at-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 4px;
  transition: width .3s ease;
  width: 0%;
}
.ht-at-status {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 16px;
  min-height: 18px;
}
.ht-at-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Scrim (popup backdrop) ───────────────────────────────────────── */
#ht-popup-scrim {
  position: fixed;
  inset: 0;
  z-index: 2147483639;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
}
#ht-popup-scrim.hidden { display: none !important; }
