/* === Modal: Product edit dialog === */

/* === Pipeline description bar === */
.mps-desc-bar {
  padding: 5px 18px;
  font-size: 0.74rem;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  min-height: 24px;
  transition: opacity 0.15s;
  opacity: 0;
  line-height: 1.5;
}

.mps-desc-bar--visible { opacity: 1; }

.mps-desc-cur  { color: var(--accent); font-weight: 600; }
.mps-desc-back { color: var(--text-tertiary); font-weight: 500; }
.mps-desc-fwd  { color: var(--status-dev); font-weight: 500; }

/* === AI panel tooltips === */
.map-tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.map-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 0.72rem;
  line-height: 1.55;
  width: 220px;
  white-space: normal;
  z-index: 4000;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.map-tooltip--left {
  left: auto;
  right: 0;
  transform: none;
}

.map-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
}

.map-tooltip--left::after {
  left: auto;
  right: 14px;
  transform: none;
}

.map-tooltip-wrap:hover .map-tooltip { display: block; }

.map-tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.73rem;
  color: #fff;
}

.map-tooltip em {
  display: block;
  margin-top: 5px;
  opacity: 0.7;
  font-style: normal;
  font-size: 0.68rem;
}

/* === Pipeline status strip === */
.modal-pipeline-strip {
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  scrollbar-width: none;
  gap: 0;
  min-height: 38px;
}

.modal-pipeline-strip::-webkit-scrollbar { display: none; }

.mps-step {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  color: var(--text-tertiary);
  background: transparent;
  cursor: default;
  flex-shrink: 0;
  transition: background 0.25s, color 0.25s, transform 0.25s;
  position: relative;
}

/* Прошедшие шаги */
.mps-step.mps-done {
  color: var(--text-secondary);
}

/* Кликабельные шаги (все кроме текущего) */
.mps-step.mps-clickable:hover {
  background: var(--bg);
  color: var(--text);
  opacity: 0.85;
}

/* Текущий шаг — подсвечивается цветом статуса */
.mps-step.mps-current {
  background: var(--step-color, var(--accent));
  color: #fff;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--step-color, var(--accent)) 30%, transparent);
}

.mps-step.mps-current.mps-advancing {
  animation: mps-pulse 0.5s ease-in-out;
}

@keyframes mps-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Цвета для каждого статуса */
.mps-step[data-status="IDEA"].mps-current     { --step-color: var(--status-idea); }
.mps-step[data-status="RESEARCH"].mps-current { --step-color: var(--status-research); }
.mps-step[data-status="SPEC"].mps-current     { --step-color: var(--status-spec); }
.mps-step[data-status="DEV"].mps-current      { --step-color: var(--status-dev); }
.mps-step[data-status="TEST"].mps-current     { --step-color: var(--status-test); }
.mps-step[data-status="DOCS"].mps-current     { --step-color: var(--status-docs); }
.mps-step[data-status="PACKAGE"].mps-current  { --step-color: var(--status-package); }
.mps-step[data-status="REVIEW"].mps-current   { --step-color: var(--status-review); }
.mps-step[data-status="PUBLISHED"].mps-current{ --step-color: var(--status-published); }
.mps-step[data-status="PROMO"].mps-current    { --step-color: var(--status-promo); }

.mps-arrow {
  color: var(--border);
  font-size: 0.65rem;
  padding: 0 1px;
  flex-shrink: 0;
  user-select: none;
}

.mps-arrow::after { content: '›'; }



.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 960px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

.modal-body fieldset {
  border: none;
  border-top: 1px solid var(--border-light);
  border-radius: 0;
  padding: 18px 0;
  margin-bottom: 0;
}

.modal-body fieldset:first-child {
  border-top: none;
  padding-top: 0;
}

.modal-body legend {
  padding: 0 0 0 0;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.field-row:last-child {
  margin-bottom: 0;
}

.field-row label {
  width: 160px;
  min-width: 160px;
  padding-top: 9px;
  font-size: 0.82rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

.field-row input,
.field-row select,
.field-row textarea {
  flex: 1;
  width: 100%;
}

.modal-body textarea {
  min-height: 56px;
}

.modal-body select {
  cursor: pointer;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

.btn-delete {
  color: var(--status-test);
  border-color: var(--status-test);
}

.btn-delete:hover {
  background: rgba(201, 66, 66, 0.1);
  color: var(--status-test);
}

/* Кнопка "Следующий шаг pipeline" */
.btn-next-step {
  border-color: var(--accent);
  color: var(--accent);
  font-size: 0.76rem;
  white-space: nowrap;
}

.btn-next-step:hover {
  background: var(--accent-light);
}

#btn-deploy-and-test {
  font-size: 0.78rem;
}

@media (max-width: 768px) {
  .modal-content {
    margin: 8px;
    max-height: calc(100vh - 16px);
  }

  .field-row {
    flex-direction: column;
    gap: 4px;
  }

  .field-row label {
    width: auto;
    min-width: auto;
    padding-top: 0;
  }
}

/* === Status advance hint panel === */
.status-advance-hint {
  padding: 10px 20px;
  background: color-mix(in srgb, var(--status-published) 8%, var(--bg));
  border-top: 1px solid color-mix(in srgb, var(--status-published) 20%, transparent);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sah-done {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--status-published);
  font-weight: 500;
}

.sah-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.sah-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.sah-btn:hover {
  background: var(--accent-light);
}

/* === Docker info in modal === */

.modal-docker-info {
  font-size: 0.85rem;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.modal-docker-info code {
  font-size: 0.8rem;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
}

.modal-docker-links {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-basis: 100%;
}

.modal-docker-links a {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.modal-docker-links a:hover {
  background: var(--accent-light);
}

/* === Deploy / Test result panel === */
.deploy-result-panel {
  padding: 10px 16px;
  font-size: 0.8rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.deploy-summary {
  font-weight: 600;
  font-size: 0.82rem;
  padding: 4px 0 6px;
}

.deploy-summary.ok { color: var(--status-published); }
.deploy-summary.fail { color: var(--status-test); }

.deploy-step {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  flex-wrap: wrap;
}

.deploy-step.fail span { color: var(--status-test); }
.deploy-step.ok span { color: var(--text); }

.deploy-step small {
  color: var(--text-tertiary);
  font-size: 0.75rem;
  flex-basis: 100%;
  padding-left: 18px;
}

/* === Hybrid: activity log, diff === */
.modal-ai-details { margin-top: 6px; font-size: 0.8rem; }
.modal-ai-details summary { cursor: pointer; color: var(--text-secondary); }
.modal-ai-files { list-style: none; padding: 4px 0 0 12px; margin: 0; }
.modal-ai-files li { padding: 1px 0; font-family: var(--font-mono, monospace); font-size: 0.75rem; }
.modal-ai-files .file-added::before { content: "+ "; color: var(--status-dev); font-weight: 600; }
.modal-ai-files .file-modified::before { content: "~ "; color: var(--status-spec); font-weight: 600; }
.modal-ai-actions { margin-top: 6px; display: flex; gap: 8px; }

.diff-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
}
.diff-panel {
  background: var(--bg); border-radius: 10px; width: min(900px, 90vw); max-height: 80vh;
  display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.diff-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: space-between; align-items: center; font-weight: 500;
}
.diff-content { overflow-y: auto; padding: 12px 16px; }
.diff-content details { margin-bottom: 12px; }
.diff-content summary { cursor: pointer; font-weight: 500; font-size: 0.85rem; padding: 4px 0; }
.diff-block {
  font-family: var(--font-mono, monospace); font-size: 0.75rem; line-height: 1.5;
  background: var(--bg-secondary, #f7f5f0); border-radius: 6px; padding: 8px 10px;
  overflow-x: auto; white-space: pre; margin: 4px 0 0;
}
.diff-add { color: #16a34a; background: #dcfce7; display: block; }
.diff-del { color: #dc2626; background: #fee2e2; display: block; }
.diff-hunk { color: var(--text-tertiary); font-style: italic; display: block; }

/* Prod Deploy */
.btn-prod { border-color: var(--status-published); color: var(--status-published); }
.btn-prod:hover { background: var(--status-published); color: white; }
.prod-deploy-menu {
  position: absolute; z-index: 1000; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.12); padding: 4px 0; min-width: 220px;
}
.prod-deploy-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 14px;
  border: none; background: none; cursor: pointer; font-size: 0.82rem; text-align: left;
}
.prod-deploy-menu-item:hover { background: var(--bg-secondary); }
.prod-target-type {
  font-size: 0.65rem; font-weight: 600; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-secondary); color: var(--text-secondary);
}
