/* ============================================================
   MedCifra · Tweaks / Edit-mode styles
   Loaded on top of site.css. Visible only when the body has
   .tw-on; the floating panel is always present once mounted.
   ============================================================ */

/* ---------- Tweaks panel (always present once mounted) ---------- */
.tw-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100000;
  width: 320px;
  max-height: calc(100vh - 40px);
  background: var(--mc-navy);
  color: var(--mc-cream);
  border-radius: 18px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .55),
              0 4px 12px rgba(0, 0, 0, .2);
  font-family: var(--mc-font-family);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .25s var(--mc-ease), opacity .2s var(--mc-ease);
}
.tw-panel.collapsed {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
}
.tw-panel.collapsed .tw-body,
.tw-panel.collapsed .tw-head-title,
.tw-panel.collapsed .tw-head-close { display: none; }
.tw-panel.collapsed .tw-head {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--mc-green);
  color: var(--mc-navy);
}
.tw-panel.collapsed .tw-head-toggle { display: grid; }

.tw-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--mc-line-navy);
  background: linear-gradient(180deg, #0a2c52 0%, var(--mc-navy) 100%);
}
.tw-head-toggle {
  display: none;
  width: 26px;
  height: 26px;
  color: currentColor;
}
.tw-head-toggle svg { width: 22px; height: 22px; }
.tw-head-icon {
  width: 30px; height: 30px;
  border-radius: 30% / 28%;
  background: var(--mc-green);
  color: var(--mc-navy);
  display: grid; place-items: center;
  flex: 0 0 30px;
}
.tw-head-icon svg { width: 16px; height: 16px; }
.tw-head-title {
  flex: 1;
  min-width: 0;
}
.tw-head-title b {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.005em;
}
.tw-head-title span {
  font-size: 11.5px;
  color: rgba(246, 248, 237, .6);
}
.tw-head-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: rgba(246, 248, 237, .7);
  transition: background .15s var(--mc-ease), color .15s var(--mc-ease);
}
.tw-head-close:hover {
  background: rgba(246, 248, 237, .08);
  color: #fff;
}
.tw-head-close svg { width: 16px; height: 16px; }

.tw-body {
  padding: 14px 16px 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Master toggle */
.tw-master {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(246, 248, 237, .04);
  border: 1px solid var(--mc-line-navy);
  border-radius: 12px;
}
.tw-master-text { flex: 1; min-width: 0; }
.tw-master-text b {
  display: block;
  font-size: 13.5px;
  color: #fff;
  font-weight: 600;
}
.tw-master-text span {
  font-size: 11.5px;
  color: rgba(246, 248, 237, .55);
}
.tw-switch {
  position: relative;
  width: 40px; height: 22px;
  flex: 0 0 40px;
  border-radius: 999px;
  background: rgba(246, 248, 237, .15);
  transition: background .2s var(--mc-ease);
  cursor: pointer;
}
.tw-switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s var(--mc-ease);
}
.tw-switch.on { background: var(--mc-green); }
.tw-switch.on::after { transform: translateX(18px); }

/* Section in the panel */
.tw-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tw-section-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(246, 248, 237, .5);
}

/* Image swap rows */
.tw-img-list { display: flex; flex-direction: column; gap: 8px; }
.tw-img-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(246, 248, 237, .03);
  border: 1px solid var(--mc-line-navy);
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s var(--mc-ease), border-color .15s var(--mc-ease);
  text-align: left;
}
.tw-img-row:hover {
  background: rgba(246, 248, 237, .08);
  border-color: var(--mc-green-deep);
}
.tw-img-thumb {
  width: 42px; height: 42px;
  border-radius: 8px;
  background: var(--mc-cream) center / cover no-repeat;
  flex: 0 0 42px;
  border: 1px solid var(--mc-line-navy);
}
.tw-img-row-text { flex: 1; min-width: 0; }
.tw-img-row-text b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tw-img-row-text span {
  font-size: 11px;
  color: rgba(246, 248, 237, .5);
}
.tw-img-row-action {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--mc-green);
  color: var(--mc-navy);
  display: grid; place-items: center;
  flex: 0 0 28px;
}
.tw-img-row-action svg { width: 14px; height: 14px; }

/* Removed items list */
.tw-removed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.tw-removed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(194, 67, 58, .08);
  border: 1px solid rgba(194, 67, 58, .25);
  border-radius: 8px;
  font-size: 12px;
  color: rgba(246, 248, 237, .8);
}
.tw-removed-row span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tw-removed-row button {
  font-size: 11px;
  font-weight: 600;
  color: var(--mc-green-mint);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(148, 230, 144, .12);
  white-space: nowrap;
}
.tw-removed-row button:hover { background: rgba(148, 230, 144, .22); }
.tw-removed-empty {
  font-size: 11.5px;
  color: rgba(246, 248, 237, .4);
  font-style: italic;
  padding: 6px 0;
}

.tw-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(246, 248, 237, .05);
  border: 1px solid var(--mc-line-navy);
  border-radius: 10px;
  color: rgba(246, 248, 237, .85);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
}
.tw-reset:hover { background: rgba(246, 248, 237, .1); color: #fff; }
.tw-reset svg { width: 14px; height: 14px; }

.tw-hint {
  font-size: 11.5px;
  color: rgba(246, 248, 237, .5);
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(246, 248, 237, .03);
  border-radius: 8px;
  border-left: 2px solid var(--mc-green);
}

/* ---------- Edit-mode visual affordances ---------- */
body.tw-on [data-tweak] {
  outline: 1.5px dashed rgba(116, 195, 101, .45);
  outline-offset: 4px;
  border-radius: 4px;
  transition: outline-color .15s var(--mc-ease);
  position: relative;
}
body.tw-on [data-tweak]:hover {
  outline-color: var(--mc-green);
  outline-style: solid;
  outline-width: 2px;
  z-index: 1;
}
body.tw-on [data-tweak][data-tw-removed] {
  display: none !important;
}

/* Element toolbar (injected into each tweakable) — anchored to the
   block's top-right corner, ALWAYS visible while edit mode is on so
   you don't lose it when the cursor moves toward a button. */
.tw-toolbar {
  position: absolute;
  top: 4px;
  right: 4px;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--mc-navy);
  border-radius: 999px;
  box-shadow: 0 6px 18px -4px rgba(0, 31, 62, .45),
              0 0 0 1px rgba(116, 195, 101, .55);
  z-index: 100;
  white-space: nowrap;
  pointer-events: auto;
  opacity: .55;
  transition: opacity .15s var(--mc-ease), box-shadow .15s var(--mc-ease);
}
body.tw-on [data-tweak] > .tw-toolbar { display: inline-flex; }
body.tw-on [data-tweak]:hover > .tw-toolbar,
.tw-toolbar:hover {
  opacity: 1;
  z-index: 101;
  box-shadow: 0 10px 28px -6px rgba(0, 31, 62, .55),
              0 0 0 1px var(--mc-green);
}

.tw-toolbar-btn {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: transparent;
  color: var(--mc-cream);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .15s var(--mc-ease), color .15s var(--mc-ease);
}
.tw-toolbar-btn:hover { background: var(--mc-green); color: var(--mc-navy); }
.tw-toolbar-btn.danger:hover { background: var(--mc-danger); color: #fff; }
.tw-toolbar-btn:disabled {
  opacity: .35;
  pointer-events: none;
}
.tw-toolbar-btn svg { width: 15px; height: 15px; }

.tw-toolbar-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(246, 248, 237, .7);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0 10px 0 8px;
  border-right: 1px solid rgba(246, 248, 237, .15);
  margin-right: 2px;
}

/* Toast notifications */
.tw-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  z-index: 100001;
  padding: 12px 18px;
  background: var(--mc-navy);
  color: var(--mc-cream);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px -8px rgba(0, 31, 62, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--mc-ease), transform .25s var(--mc-ease);
}
.tw-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Avoid breaking print */
@media print {
  .tw-panel, .tw-toolbar, .tw-toast { display: none !important; }
  body.tw-on [data-tweak] { outline: none !important; }
}
