/* Kunden-Text-Editor — Overlay Styles
   Wird nur aktiv, wenn <html> die Klasse .kte-active trägt. */

html.kte-active [data-kte-editable] {
  outline: 1px dashed rgba(99, 102, 241, 0.45);
  outline-offset: 2px;
  cursor: text;
  transition: outline-color 120ms ease, background-color 120ms ease;
}

html.kte-active [data-kte-editable]:hover {
  outline: 1.5px dashed rgba(99, 102, 241, 0.9);
  background-color: rgba(99, 102, 241, 0.06);
}

html.kte-active [data-kte-editable][contenteditable="true"] {
  outline: 2px solid #6366f1;
  background-color: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
  border-radius: 3px;
}

html.kte-active [data-kte-editable][data-kte-changed="true"] {
  outline-color: #16a34a;
  background-color: rgba(22, 163, 74, 0.06);
}

/* Floating panel */
.kte-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2147483647;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  user-select: none;
}

.kte-panel__header {
  padding: 10px 12px;
  background: #0f172a;
  color: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kte-panel__header button {
  background: transparent;
  border: 0;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
}

.kte-panel__header button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.kte-panel__body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kte-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 12px;
}

.kte-status__count {
  font-weight: 700;
  color: #16a34a;
}

.kte-status__count--zero {
  color: #64748b;
}

/* Live-Sync status badge */
.kte-sync {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.kte-sync[data-status="syncing"] {
  background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe;
}
.kte-sync[data-status="queued"] {
  background: #fffbeb; color: #b45309; border-color: #fde68a;
}
.kte-sync[data-status="error"] {
  background: #fef2f2; color: #b91c1c; border-color: #fecaca;
}

.kte-btn {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}

.kte-btn:hover { background: #f8fafc; }

.kte-btn--primary {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.kte-btn--primary:hover { background: #1e293b; }

.kte-btn--ghost {
  border-color: transparent;
  color: #64748b;
  padding: 6px 8px;
  font-size: 12px;
}

.kte-btn--ghost:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.kte-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kte-hint {
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
}

.kte-panel--collapsed .kte-panel__body {
  display: none;
}

/* Diff modal */
.kte-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.kte-modal__dialog {
  background: #ffffff;
  color: #0f172a;
  border-radius: 14px;
  width: min(720px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}

.kte-modal__header {
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.kte-modal__body {
  padding: 12px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kte-diff {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  background: #f8fafc;
}

.kte-diff__label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.kte-diff__old {
  color: #b91c1c;
  text-decoration: line-through;
  white-space: pre-wrap;
  word-break: break-word;
}

.kte-diff__new {
  color: #166534;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 4px;
  font-weight: 500;
}

.kte-modal__footer {
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Splashscreen (first activation) */
.kte-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483645;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.kte-splash__box {
  background: #ffffff;
  padding: 24px 26px;
  border-radius: 14px;
  max-width: 440px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}

.kte-splash__box h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.kte-splash__box p {
  margin: 0 0 10px;
  color: #334155;
  line-height: 1.55;
  font-size: 14px;
}

.kte-splash__box ul {
  margin: 0 0 16px;
  padding-left: 18px;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .kte-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 12px;
  }
}

/* Hide the editor chrome when printing */
@media print {
  .kte-panel,
  .kte-modal,
  .kte-splash { display: none !important; }
  html.kte-active [data-kte-editable] { outline: none !important; background: none !important; }
}
