/* ========================================
   SAYDI HEALTH COACH — Inline edit mode

   Only ever active on ?edit=1 for a signed-in admin. Visitors never load the
   markup this styles.
   ======================================== */

:root {
  --edit-accent: #15803d;
  --edit-accent-soft: rgba(34, 197, 94, 0.14);
  --edit-ink: #0a3419;
}

/* ---------- editable text ---------- */

.edit-mode .editable-text {
  outline: 1px dashed rgba(34, 197, 94, 0.42);
  outline-offset: 3px;
  border-radius: 3px;
  cursor: text;
  transition: outline-color 0.15s ease, background-color 0.15s ease;
}

.edit-mode .editable-text:hover {
  outline: 1px dashed var(--edit-accent);
  background-color: var(--edit-accent-soft);
}

.edit-mode .editable-text:focus {
  outline: 2px solid var(--edit-accent);
  outline-offset: 3px;
  background-color: rgba(34, 197, 94, 0.1);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.1);
}

/* A quiet marker on strings that differ from the shipped copy. */
.edit-mode .editable-text.edited {
  outline-style: solid;
  outline-color: rgba(212, 168, 83, 0.85);
}
.edit-mode .editable-text.edited:focus {
  outline-color: var(--edit-accent);
}

/* One language changed, the other still on the old wording. */
.edit-mode .editable-text.lang-out-of-sync {
  outline-style: solid;
  outline-color: rgba(217, 119, 6, 0.9);
  background-image: radial-gradient(circle at 100% 0, #d97706 0 4px, transparent 4px);
  background-repeat: no-repeat;
}

/* Text owned by the admin panel's structured editors (service, plan and course
   cards). Visibly distinct so it never reads as "I clicked but nothing happened". */
.edit-mode .managed-text {
  outline: 1px dotted rgba(115, 115, 115, 0.5);
  outline-offset: 3px;
  border-radius: 3px;
  cursor: not-allowed;
}

.edit-mode .managed-text:hover {
  outline-color: rgba(115, 115, 115, 0.85);
  background-color: rgba(115, 115, 115, 0.08);
}

/* Links and buttons must not look clickable while they are being edited. */
.edit-mode a.editable-text,
.edit-mode button.editable-text,
.edit-mode .editable-text a,
.edit-mode .editable-text button {
  cursor: text !important;
}

/* Keep the page clear of the fixed toolbar. */
.edit-mode {
  padding-bottom: 84px;
}

/* ---------- toolbar ---------- */

.edit-bar {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 99999;

  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.75rem 0.6rem 1.1rem;

  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(21, 128, 61, 0.16);
  border-radius: 999px;
  box-shadow: 0 12px 40px -8px rgba(10, 52, 25, 0.28), 0 2px 8px rgba(10, 52, 25, 0.08);

  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 0.82rem;
  color: var(--edit-ink);
  max-width: calc(100vw - 2rem);
}

.edit-bar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  white-space: nowrap;
}

.edit-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--edit-accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}

.edit-bar-langs {
  display: inline-flex;
  background: rgba(10, 52, 25, 0.07);
  border-radius: 999px;
  padding: 2px;
}

.edit-bar-langs button {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: rgba(10, 52, 25, 0.62);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.edit-bar-langs button:hover { color: var(--edit-ink); }

.edit-bar-langs button.active {
  background: #fff;
  color: var(--edit-accent);
  box-shadow: 0 1px 3px rgba(10, 52, 25, 0.16);
}

.edit-bar-status {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--edit-accent);
}

.edit-bar-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.edit-bar-status.saving { color: #a16207; }
.edit-bar-status.saving::before { animation: editBlink 1s ease-in-out infinite; }
.edit-bar-status.error { color: #b91c1c; }

@keyframes editBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.edit-bar-hint {
  color: rgba(10, 52, 25, 0.5);
  white-space: nowrap;
}

.edit-bar-exit {
  background: var(--edit-accent);
  color: #fff !important;
  text-decoration: none;
  font-weight: 700;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.18s ease, transform 0.18s ease;
}

.edit-bar-exit:hover {
  background: #166534;
  transform: translateY(-1px);
}

/* ---------- transient warning ---------- */

.edit-flash {
  position: absolute;
  z-index: 100000;
  background: #b91c1c;
  color: #fff;
  font: 600 0.75rem/1 system-ui, sans-serif;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  animation: editFlashIn 0.18s ease;
}

@keyframes editFlashIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- locked-out notice ---------- */

.edit-locked {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  background: #fff;
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-left: 4px solid #b91c1c;
  border-radius: 10px;
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.25);
  font: 0.84rem/1.4 system-ui, sans-serif;
  color: #1e293b;
  max-width: calc(100vw - 2rem);
  flex-wrap: wrap;
}

.edit-locked strong { color: #b91c1c; }

.edit-locked a {
  color: var(--edit-accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.edit-locked a:hover { text-decoration: underline; }

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .edit-bar {
    gap: 0.6rem;
    padding: 0.5rem 0.6rem 0.5rem 0.85rem;
    font-size: 0.75rem;
    border-radius: 14px;
  }
  .edit-bar-hint { display: none; }
  .edit-bar-brand { font-size: 0; gap: 0; }
  .edit-bar-status { font-size: 0; gap: 0; }
  .edit-bar-status::before { width: 8px; height: 8px; }
}

/* ---------- the other language ---------- */

/* Opens under a string the moment it changes, holding the same sentence in the
   opposite language so the pair is written in one go. */
.edit-companion {
  position: absolute;
  z-index: 99998;

  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.55rem 0.5rem 0.8rem;

  background: #fff;
  border: 1px solid rgba(21, 128, 61, 0.22);
  border-radius: 12px;
  box-shadow: 0 14px 38px -10px rgba(10, 52, 25, 0.35), 0 2px 6px rgba(10, 52, 25, 0.1);

  font: 0.82rem/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--edit-ink);
  animation: editCompanionIn 0.16s ease;
}

@keyframes editCompanionIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.edit-companion-label {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--edit-accent);
  white-space: nowrap;
}

.edit-companion-input {
  font: inherit;
  color: var(--edit-ink);
  width: min(46ch, 60vw);
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(10, 52, 25, 0.18);
  border-radius: 8px;
  background: #fbfdfb;
}

.edit-companion-input:focus {
  outline: 0;
  border-color: var(--edit-accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.edit-companion button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease;
}

.edit-companion-save {
  background: var(--edit-accent);
  color: #fff;
}
.edit-companion-save:hover { background: #166534; }

.edit-companion-skip {
  background: transparent;
  color: rgba(10, 52, 25, 0.55);
}
.edit-companion-skip:hover { color: var(--edit-ink); background: rgba(10, 52, 25, 0.06); }

/* ---------- the scrolling strip ---------- */

/* Standing still, wrapped and always on screen, it edits like any other line.
   Its second half is a clone of the first, so only one copy is shown here. */
.edit-mode .marquee-strip {
  display: block;
  padding: 1rem 1.25rem;
}

.edit-mode .marquee-inner {
  animation: none;
  width: auto;
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 0.5rem;
}

.edit-mode .marquee-inner [data-marquee-clone] { display: none; }

/* The strip is green, so the outline states are restated in colours that read
   against it: white = untouched, gold = changed, amber = one language missing. */
.edit-mode .marquee-inner .editable-text,
.edit-mode .marquee-inner .editable-text:hover {
  outline-color: rgba(255, 255, 255, 0.62);
}
.edit-mode .marquee-inner .editable-text.edited,
.edit-mode .marquee-inner .editable-text.edited:hover {
  outline-color: #fde68a;
}
.edit-mode .marquee-inner .editable-text.lang-out-of-sync,
.edit-mode .marquee-inner .editable-text.lang-out-of-sync:hover {
  outline-color: #fbbf24;
  background-image: radial-gradient(circle at 100% 0, #fbbf24 0 4px, transparent 4px);
}
.edit-mode .marquee-inner .editable-text:hover {
  background-color: rgba(255, 255, 255, 0.18);
}
.edit-mode .marquee-inner .editable-text:focus {
  outline-color: #fff;
  background-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.14);
}

@media (max-width: 720px) {
  .edit-companion {
    left: 8px !important;
    right: 8px;
    flex-wrap: wrap;
  }
  .edit-companion-input { width: 100%; }
}
