/* ─── ПЕРЕМЕННЫЕ ─────────────────────────────────────────────────── */
:root {
  --teal: #3EC9C7;
  --teal-dark: #2ba8a6;
  --teal-light: #e8fafa;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
}

/* ─── СБРОС ──────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; }

/* ─── ШАПКА ──────────────────────────────────────────────────────── */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--teal);
  padding: 16px 0;
  white-space: nowrap;
}
.logo span { color: var(--text-muted); font-weight: 400; font-size: 14px; margin-left: 6px; }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--teal); }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ─── ВКЛАДКИ ────────────────────────────────────────────────────── */
.tab-content { display: none; padding: 24px 32px; max-width: 1100px; margin: 0 auto; }
.tab-content.active { display: block; }

/* ─── ПАНЕЛЬ ─────────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 16px; font-weight: 600; margin-bottom: 20px; }

/* ─── ФОРМА ──────────────────────────────────────────────────────── */
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 13px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 6px; }

select, input[type="text"], textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  background: #fff;
}
textarea { resize: vertical; }

.chapter-controls, .prompt-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.chapter-controls select, .prompt-controls select { flex: 1; }

.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── ПРЕВЬЮ ГЛАВЫ ───────────────────────────────────────────────── */
.chapter-preview { margin-top: 12px; }
#chapter-text-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  color: var(--text-muted);
}

/* ─── КНОПКИ ─────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }

.btn-large { padding: 13px 32px; font-size: 15px; }

.btn-approve { background: var(--success); color: #fff; border: none;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-redo { background: var(--warning); color: #fff; border: none;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-reject { background: var(--danger); color: #fff; border: none;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-approve:hover { filter: brightness(0.9); }
.btn-redo:hover { filter: brightness(0.9); }
.btn-reject:hover { filter: brightness(0.9); }

/* ─── ЗАПУСК ─────────────────────────────────────────────────────── */
.run-row { display: flex; align-items: center; gap: 20px; margin-top: 24px; }
.status-msg { font-size: 14px; color: var(--text-muted); }

/* ─── ИСТОРИЯ СЕССИЙ ─────────────────────────────────────────────── */
.sessions-list { display: flex; flex-direction: column; gap: 8px; }
.session-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.session-item:hover { border-color: var(--teal); background: var(--teal-light); }
.session-status { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.status-done { background: #d1fae5; color: #065f46; }
.status-running, .status-analyzing, .status-generating { background: #fef3c7; color: #92400e; }
.status-error { background: #fee2e2; color: #991b1b; }
.status-pending { background: var(--border); color: var(--text-muted); }
.session-info { flex: 1; font-size: 13px; }
.session-info strong { display: block; margin-bottom: 2px; }
.session-time { font-size: 12px; color: var(--text-muted); }

/* ─── РЕЗУЛЬТАТЫ ─────────────────────────────────────────────────── */
.results-header { display: flex; align-items: center; justify-content: space-between; }
.results-controls { display: flex; gap: 10px; align-items: center; }
.results-controls select { min-width: 250px; }

.status-bar {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 7px;
  font-size: 13px;
  color: #92400e;
}
.status-bar.done { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.status-bar.error { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

/* ─── ИДЕЯ / КАРТОЧКА ────────────────────────────────────────────── */
.idea-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.idea-header {
  padding: 16px 24px;
  background: var(--teal-light);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.idea-num {
  background: var(--teal);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.idea-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.idea-description { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.idea-details { padding: 16px 24px; border-bottom: 1px solid var(--border); }
.idea-details details summary { font-size: 13px; color: var(--teal); cursor: pointer;
  font-weight: 500; margin-bottom: 8px; }
.idea-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.idea-detail-item { font-size: 12px; }
.idea-detail-item strong { display: block; color: var(--text-muted); margin-bottom: 3px; }

.images-grid { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }

/* ─── КАРТОЧКА ИЗОБРАЖЕНИЯ ───────────────────────────────────────── */
.image-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.image-card:hover { box-shadow: 0 4px 16px rgba(62,201,199,0.15); }
.image-card.approved { border-color: var(--success); }
.image-card.rejected { opacity: 0.5; }

.image-card img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.image-placeholder {
  width: 100%;
  height: 200px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

.image-controls { padding: 14px 16px; }
.image-rating { display: flex; gap: 4px; margin-bottom: 10px; }
.star { font-size: 20px; cursor: pointer; color: #d1d5db; transition: color 0.1s; }
.star.active { color: #f59e0b; }
.star:hover, .star:hover ~ .star { color: #fde68a; }

.image-comment { margin-bottom: 10px; }
.image-comment textarea {
  font-size: 12px;
  padding: 7px 10px;
  min-height: 50px;
}

.image-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.image-status-badge { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; margin-left: auto; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-generating { background: #fef3c7; color: #92400e; }

/* ─── ВЕРСТКА ────────────────────────────────────────────────────── */
.layout-header { display: flex; align-items: center; justify-content: space-between; }
.layout-chapter {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.layout-chapter-header {
  padding: 16px 24px;
  background: var(--teal-light);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  color: var(--teal-dark);
}
.layout-chapter-body { padding: 20px 24px; }
.layout-text { font-size: 14px; line-height: 1.7; white-space: pre-wrap; color: var(--text); margin-bottom: 20px; }
.layout-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.layout-image-item { border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.layout-image-item img { width: 100%; display: block; }
.layout-image-caption { padding: 8px 12px; font-size: 12px; color: var(--text-muted); background: var(--bg); }
.layout-no-images { color: var(--text-muted); font-size: 13px; font-style: italic; }

/* ─── МОДАЛЬНЫЕ ОКНА ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  width: 560px;
  max-width: 95vw;
}
.modal-content {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999; }

/* ─── ВСПОМОГАТЕЛЬНОЕ ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 32px; color: var(--text-muted); font-size: 14px; }
details summary { cursor: pointer; list-style: none; }
details summary::before { content: '▶ '; font-size: 10px; }
details[open] summary::before { content: '▼ '; }
pre { white-space: pre-wrap; font-size: 12px; line-height: 1.5; }
