/* Lab Infra Map — same visual language as k8s-configurator. */

.lim-root, .lim-root * { box-sizing: border-box; }

/* === Full-bleed на фронтенде ===
 * Тема (GeneratePress) даёт .entry-content max-width ~1100px + sidebar +
 * padding'и .inside-article и т.д. Шапку и подвал темы оставляем —
 * распахиваем только контентную зону между ними. Сам .lim-root остаётся
 * нормальным flow-элементом без margin-хаков. */
.lim-root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
  background: transparent;
  padding: 0.8rem 1rem;
  border-radius: 0;
  width: 100%;
  max-width: none;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 4rem);
}

/* Frontend-only: разворачиваем все content-обёртки темы на 100% и
 * убираем их фон/тень/рамку. Жёлтый highlight на hover у GeneratePress
 * в `separate-containers` идёт от .inside-article background + admin-bar
 * editable hover — оба сбрасываем здесь. wp-admin исключён. */
body:not(.wp-admin):has(.lim-root) :is(
  .site-content, .content-area, #primary, main, article,
  .inside-article, .entry-content, .post, .page
) {
  max-width: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  float: none !important;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
}
body:not(.wp-admin):has(.lim-root) :is(
  .site-content, .content-area, #primary, main, article,
  .inside-article, .entry-content, .post, .page
):hover,
body:not(.wp-admin):has(.lim-root) :is(
  .site-content, .content-area, #primary, main, article,
  .inside-article, .entry-content, .post, .page
):focus,
body:not(.wp-admin):has(.lim-root) :is(
  .site-content, .content-area, #primary, main, article,
  .inside-article, .entry-content, .post, .page
):focus-within {
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}
/* Прячем sidebar/widget-area — карте нужна вся ширина. */
body:not(.wp-admin):has(.lim-root) :is(
  .sidebar, .widget-area, #secondary, aside.widget-area
) { display: none !important; }
/* Прячем заголовок поста, мету и навигацию записи — оставляем только
 * шапку/подвал темы и наш собственный .lim-header. */
body:not(.wp-admin):has(.lim-root) :is(
  .entry-header, .entry-meta, .entry-footer, .post-navigation, .nav-below
) { display: none !important; }
/* Защита от случайного горизонтального скролла, пока шрифты/SVG ещё
 * докручиваются. */
body:has(.lim-root) { overflow-x: hidden; }

/* Admin / .wrap → constrained layout (карта внутри tools.php). */
body.wp-admin .lim-root,
.wrap .lim-root {
  border-radius: 8px;
}
.lim-locked { padding: 1rem; background: #fff8e0; border: 1px solid #e0c060; border-radius: 6px; }

/* Header — small, neutral, doesn't compete with the diagram. */
.lim-header { background: transparent; border: none; padding: 0 0 0.4rem 0; margin: 0; }
.lim-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; color: #1e293b; }
.lim-header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.lim-header-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.lim-root .lim-btn {
  padding: 0.4rem 0.9rem !important;
  background: #2b5cb5 !important;
  color: #fff !important;
  border: 1px solid #2b5cb5 !important;
  border-radius: 5px !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  text-shadow: none !important;
  font-size: 0.9rem !important;
}
.lim-root .lim-btn:hover:not([disabled]) { background: #224994 !important; }
.lim-root .lim-btn[disabled] { opacity: 0.45 !important; cursor: not-allowed !important; }
.lim-root .lim-btn-link { background: #ffffff !important; color: #2b5cb5 !important; }
.lim-root .lim-btn-link:hover { background: #eef3fb !important; }

.lim-stats { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; padding: 0.4rem 0 0; }
.lim-badge { padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.85rem; font-weight: 600; }
.lim-alive   { background: #dff5d8; color: #134e1a; }
.lim-dead    { background: #fad4d4; color: #5b0000; }
.lim-timeout { background: #fdf0c2; color: #663400; }
.lim-skip    { background: #ececec; color: #444; }
.lim-meta { color: #777; font-size: 0.85rem; }

.lim-status-error { padding: 0.6rem 0.9rem; background: #fde9e9; color: #720000; border-radius: 6px; margin: 0.5rem 0; font-size: 0.9rem; }

.lim-diagram-wrap {
  /* No frame around the diagram — the schema speaks for itself. The wrap
   * is invisible; its only job is to be the pan-zoom hit area and provide
   * the flex height. Itself flex so that .lim-diagram (the SVG host)
   * actually stretches to fill the rubber-grown wrap height — without
   * `display: flex` here a child's `height: 100%` collapses because flex
   * parents don't propagate computed height to %-children. */
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-top: 0.6rem;
  flex: 1 1 auto;
  min-height: 28rem;
  position: relative;
  overflow: hidden;
  display: flex;
}
.lim-diagram {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  width: 100%;
  cursor: grab;
  position: relative;
}
/* The SVG mermaid drops in — force it to fill its host on both axes.
 * Mermaid sets width="…" height="…" attrs which app.js strips; this CSS
 * is a belt-and-suspenders so even on first paint before app.js runs
 * the svg already wants to fill. */
.lim-diagram > svg {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  display: block;
  position: absolute;
  inset: 0;
}
.lim-diagram:active { cursor: grabbing; }
.lim-diagram svg {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  display: block;
}

/* Floating zoom controls (rendered by app.js when svg-pan-zoom loads) */
.lim-zoom-ctrl {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}
.lim-zoom-ctrl button {
  width: 36px; height: 36px;
  border: 1px solid #b6c4dd !important;
  background: #fff !important;
  color: #1a2548 !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
}
.lim-zoom-ctrl button:hover { background: #eef3fb !important; }

/* Help line under the diagram explaining pan+zoom */
.lim-diagram-help {
  color: #777;
  font-size: 0.8rem;
  margin-top: 0.3rem;
  text-align: center;
  font-style: italic;
}
.lim-loading { color: #888; text-align: center; padding: 3rem; font-size: 1rem; }

.lim-raw { margin-top: 1rem; }
.lim-raw summary { cursor: pointer; color: #555; font-size: 0.9rem; }
.lim-mermaid-src {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  background: #1d1d22;
  color: #eaeaea;
  padding: 0.8rem;
  border: 1px solid #2a2a30;
  border-radius: 6px;
  overflow: auto;
  width: 100%;
  max-height: 26rem;
  white-space: pre;
  margin: 0.4rem 0;
  box-sizing: border-box;
  resize: vertical;
  outline: none;
  tab-size: 2;
}
.lim-mermaid-src:focus { border-color: #2b5cb5; }
.lim-raw-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.4rem 0 0;
}

.lim-footer {
  margin-top: 1.4rem;
  padding-top: 0.8rem;
  border-top: 1px solid #ddd;
  font-size: 0.82rem;
  color: #777;
  text-align: center;
}
.lim-footer code {
  background: #eef0f7;
  color: #2b3b66;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
}
.lim-footer a { color: #2453b5; text-decoration: none; }
.lim-footer a:hover { text-decoration: underline; }
