/* === Prompt Generator: controls, tabs, output === */

.prompt-generator {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* === Topbar: 2-рядная шапка промптов === */

.prompts-topbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Строка 1: select продукта + табы типов */
.prompts-topbar-row1 {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.prompts-product-select {
  flex: 1;
  min-width: 200px;
  width: auto !important;
}

/* Строка 2: панель выполнения (правое выравнивание) */
.prompts-execute-controls {
  display: flex !important;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  padding: 8px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

.prompts-execute-controls select {
  font-size: 0.82rem;
  width: auto !important;
}

#execute-method {
  min-width: 200px;
}

#claude-model-select {
  min-width: 110px;
}

.prompt-type-tabs {
  display: flex;
  gap: 0;
}

.prompt-tab {
  background: var(--surface);
  border: 1px solid var(--input-border);
  color: var(--text-secondary);
  padding: 8px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.prompt-tab:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.prompt-tab + .prompt-tab {
  border-left: none;
}

.prompt-tab:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.prompt-tab.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-border);
}

/* Компактная инфо-строка продукта */
.product-info-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  padding: 0 2px;
  min-height: 0;
  flex-wrap: wrap;
}

.product-info-inline:empty {
  display: none;
}

.product-info-inline strong {
  color: var(--text);
  font-weight: 600;
}

.product-info-inline .product-info-name {
  font-weight: 600;
  color: var(--text);
}

.product-info-inline .product-info-sep {
  color: var(--border);
  font-size: 1rem;
  line-height: 1;
}

.product-info-inline .product-info-action {
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.product-info-inline .blocker-warning {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--status-test);
  font-weight: 500;
  font-size: 0.8rem;
  margin-top: 0;
}

.blocker-warning {
  margin-top: 8px;
  color: var(--status-test);
  font-weight: 500;
}

.prompt-output {
  display: flex;
  flex-direction: column;
}

.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.prompt-header button {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--input-border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.prompt-header button:hover {
  background: var(--accent-light);
  color: var(--accent);
}

#prompt-text {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 32px 36px;
  min-height: 200px;
  overflow-y: auto;
  max-height: 72vh;
}

/* === Claude hint === */

.claude-hint {
  font-size: 0.78rem;
  color: var(--status-test);
  font-weight: 500;
}

.btn-outline {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--input-border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}

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

.btn-primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Оценка стоимости */
.claude-estimate {
  margin-top: 14px;
}

.estimate-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.estimate-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.estimate-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.estimate-value {
  font-size: 0.9rem;
  font-weight: 600;
}

.estimate-cost {
  color: var(--accent);
}

/* Сравнение подписок */
.subscriptions-comparison {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.comparison-title {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.comparison-row {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.78rem;
  padding: 3px 0;
}

.comparison-name {
  font-weight: 500;
  min-width: 120px;
}

.comparison-price {
  color: var(--text-secondary);
  min-width: 80px;
}

.comparison-verdict {
  color: var(--status-spec);
  font-style: italic;
}

/* Результат выполнения */
.claude-result {
  margin-top: 14px;
}

.execute-success {
  background: var(--bg);
  border: 1px solid var(--status-published);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}

.execute-header {
  font-weight: 600;
  color: var(--status-published);
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.execute-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.execute-item {
  display: flex;
  gap: 8px;
  font-size: 0.82rem;
}

.execute-label {
  color: var(--text-secondary);
  min-width: 130px;
  font-weight: 500;
}

.execute-error {
  background: var(--bg);
  border: 1px solid var(--status-test);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--status-test);
  font-size: 0.85rem;
}

.estimate-header-label {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

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

.btn-stop:hover {
  background: rgba(201, 66, 66, 0.1);
}

.loading {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-style: italic;
  padding: 8px 0;
}

.execute-progress {
  padding: 12px 0 8px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

.progress-timer {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.9s ease-out;
  animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.progress-model {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: monospace;
  opacity: 0.8;
}

.progress-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

@media (max-width: 768px) {
  .prompt-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .prompt-controls select {
    min-width: unset;
  }
}

/* === View Toggle: Промпт / Шаблон / Результат === */
.prompt-view-toggle {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0;
}

.view-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s;
}

.view-tab:hover {
  color: var(--text-primary);
}

.view-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.prompt-view {
  display: none;
}

.prompt-view.active {
  display: block;
}

/* === Template Editor === */
.template-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.template-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.template-header span {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.template-actions {
  display: flex;
  gap: 8px;
}

.template-blocks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-block {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s;
}

.template-block:hover {
  border-color: var(--accent-border);
}

.template-block.disabled {
  opacity: 0.5;
}

.template-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.template-block-header .block-toggle {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: none;
  padding: 0;
}

.template-block-header .block-toggle.on {
  background: var(--accent);
}

.template-block-header .block-toggle::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
}

.template-block-header .block-toggle.on::after {
  left: 16px;
}

.template-block-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.template-block-badges {
  display: flex;
  gap: 4px;
}

.template-block-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

.template-block-badge.computed {
  background: #f0e6d6;
  color: #8b6914;
}

.template-block-badge.marketplace {
  background: #e6f0e6;
  color: #2d6a2d;
}

.template-block-chevron {
  color: var(--text-secondary);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.template-block.expanded .template-block-chevron {
  transform: rotate(90deg);
}

.template-block-body {
  display: none;
  padding: 0 14px 14px;
}

.template-block.expanded .template-block-body {
  display: block;
}

.template-block-body textarea {
  width: 100%;
  min-height: 120px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-border);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  resize: vertical;
  box-sizing: border-box;
}

.template-block-body .computed-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-light);
}

/* === Result View === */
#result-text {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--status-published);
  padding: 18px;
  border-radius: var(--radius-md);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  resize: vertical;
  min-height: 200px;
  width: 100%;
  box-sizing: border-box;
}

/* === Claude Code Launch Panel === */
.claude-code-launch-panel {
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-top: 12px;
}

.cc-panel-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border-light);
}

.cc-panel-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cc-dir-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.cc-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.cc-badge-new {
  background: color-mix(in srgb, var(--status-published) 15%, transparent);
  color: var(--status-published);
}

.cc-badge-exists {
  background: var(--bg);
  color: var(--text-tertiary);
}

.cc-path-row,
.cc-cmd-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cc-path,
.cc-cmd {
  flex: 1;
  font-size: 0.79rem;
  background: var(--bg);
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-cmd {
  color: var(--accent);
  font-weight: 500;
}

.cc-copy-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  cursor: pointer;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.cc-copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.cc-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.cc-step {
  font-size: 0.76rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
}

.cc-sep {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* === Блок инструкции для Доработки (Refine) === */

.refine-instruction-block {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.refine-instruction-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.refine-instruction-header svg {
  color: var(--accent);
  flex-shrink: 0;
}

.refine-hint {
  font-size: 0.76rem;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: 4px;
}

.refine-textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  background: var(--bg);
  border: none;
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: inherit;
  box-sizing: border-box;
}

.refine-textarea:focus {
  outline: none;
  border-left-color: var(--accent);
  background: var(--accent-light);
}

.refine-textarea::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}

.refine-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
