/* Content Factory dashboard — базовые стили (Bootstrap 5 дополнения) */

:root {
  --cf-sidebar-width: 260px;
  --cf-accent: #0d6efd;
  --cf-sidebar-bg: #212529;
}

body.cf-app {
  min-height: 100vh;
  background: #f4f6f9;
}

/* Вертикальный sidebar слева */
.cf-shell {
  min-height: 100vh;
}

.cf-sidebar {
  width: var(--cf-sidebar-width);
  background: var(--cf-sidebar-bg);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.cf-sidebar .nav-link {
  border-radius: 0.5rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.95rem;
}

.cf-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cf-sidebar .nav-link.active {
  background: var(--cf-accent) !important;
  font-weight: 600;
  color: #fff !important;
}

.cf-content {
  min-width: 0;
  background: #f4f6f9;
}

.cf-main {
  flex: 1;
}

@media (max-width: 991.98px) {
  .cf-shell {
    flex-direction: column;
  }

  .cf-sidebar {
    width: 100%;
    min-height: auto !important;
    position: relative;
  }

  .cf-sidebar .nav {
    max-height: 70vh;
    overflow-y: auto;
  }
}

.cf-kpi-card {
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cf-status--ok { background: #198754; }
.cf-status--warn { background: #ffc107; color: #212529; }
.cf-status--err { background: #dc3545; }

.cf-plan-card {
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease;
}

.cf-plan-card:hover {
  transform: translateY(-2px);
}

.cf-agent-card {
  border-left: 4px solid var(--cf-accent);
}

.cf-agent-card[data-status="busy"] { border-left-color: #ffc107; }
.cf-agent-card[data-status="error"] { border-left-color: #dc3545; }
.cf-agent-card[data-status="idle"] { border-left-color: #6c757d; }

.cf-chat-messages {
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
  background: #fafafa;
}

.cf-chat-bubble {
  max-width: 85%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.cf-chat-bubble--user {
  margin-left: auto;
  background: #0d6efd;
  color: #fff;
}

.cf-chat-bubble--bot {
  background: #e9ecef;
  color: #212529;
}

.cf-timeline {
  position: relative;
  padding-left: 1.25rem;
}

.cf-timeline li {
  position: relative;
  padding-bottom: 1rem;
  border-left: 2px solid #dee2e6;
  padding-left: 1rem;
  margin-left: 0.25rem;
}

.cf-timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cf-accent);
}

.cf-prompt-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 400px;
}

.cf-footer {
  background: #fff;
}

@media (max-width: 576px) {
  .cf-kpi-card .display-6 {
    font-size: 1.75rem;
  }
}

/* Контент-планы: сайдбар проектов */
.cf-plans-sidebar {
  top: 1rem;
  z-index: 10;
}

.cf-plans-sidebar .list-group-item {
  cursor: pointer;
  border-left: 3px solid transparent;
}

.cf-plans-sidebar .list-group-item.active {
  border-left-color: var(--cf-accent);
  background: rgba(13, 110, 253, 0.08);
}

/* Сводка пайплайна */
.cf-pipeline-summary {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  color: #166534;
  margin-bottom: 0.75rem;
}

/* Горизонтальный пайплайн (строго слева направо) */
.cf-pipeline-horizontal,
.pipeline-container {
  margin: 0;
  padding: 0.5rem 0 0.25rem;
  overflow-x: auto;
  width: 100%;
}

.cf-pipeline-track,
.pipeline-container.cf-pipeline-track {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  min-width: min-content;
  width: max-content;
  max-width: 100%;
  gap: 0;
}

.pipeline-step,
.cf-pipeline-step {
  min-width: 80px;
  max-width: 110px;
  flex: 0 0 auto;
  display: flex !important;
  flex-direction: column !important;
  align-items: center;
  text-align: center;
  position: relative;
  padding: 0 0.15rem;
}

.pipeline-circle,
.cf-pipeline-step__circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: #e9ecef;
  color: #64748b;
  border: 2px solid #dee2e6;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.pipeline-label,
.cf-pipeline-step__title {
  font-weight: 600;
  font-size: 0.72rem;
  color: #1e293b;
  line-height: 1.2;
  margin-top: 0.35rem;
}

.cf-pipeline-step__meta {
  font-size: 0.65rem;
  color: #64748b;
  line-height: 1.2;
}

/* Линия между этапами (sibling в flex-row) */
.pipeline-line,
.cf-pipeline-step__connector {
  width: 40px;
  min-width: 28px;
  height: 3px;
  background: #dee2e6;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  align-self: center;
  margin-bottom: 1.6rem; /* выровнять с кружками, не с подписями */
}

.pipeline-line--done,
.cf-pipeline-step__connector--done {
  background: #28a745;
}

.pipeline-line--active,
.cf-pipeline-step__connector--active {
  background: linear-gradient(90deg, #28a745 0%, #ffc107 50%, #dee2e6 100%);
  background-size: 200% 100%;
  animation: cf-pipeline-glow-run 1.4s linear infinite;
}

/* Состояния кружков */
.pipeline-step-done .pipeline-circle,
.pipeline-step.done .pipeline-circle,
.cf-pipeline-step--done .pipeline-circle,
.cf-pipeline-step--done .cf-pipeline-step__circle {
  background: #28a745;
  border-color: #28a745;
  color: #fff;
}

.pipeline-step-active .pipeline-circle,
.pipeline-step.active .pipeline-circle,
.cf-pipeline-step--running .pipeline-circle,
.cf-pipeline-step--running .cf-pipeline-step__circle {
  background: #ffc107;
  border-color: #ffc107;
  color: #212529;
  animation: pulse 1.5s infinite;
}

.pipeline-step-pending .pipeline-circle,
.pipeline-step.pending .pipeline-circle,
.cf-pipeline-step--pending .pipeline-circle,
.cf-pipeline-step--upcoming .pipeline-circle,
.cf-pipeline-step--pending .cf-pipeline-step__circle,
.cf-pipeline-step--upcoming .cf-pipeline-step__circle {
  background: #e9ecef;
  border-color: #dee2e6;
  border-style: dashed;
  color: #94a3b8;
}

.pipeline-step-error .pipeline-circle,
.cf-pipeline-step--error .pipeline-circle,
.cf-pipeline-step--error .cf-pipeline-step__circle {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

.cf-pipeline-step--slow .cf-pipeline-step__meta {
  color: #b45309;
  font-weight: 600;
}

.cf-pipeline-step__pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 193, 7, 0.5);
  animation: cf-pipeline-ring 1.5s ease-out infinite;
  pointer-events: none;
}

/* Бегущий человечек по линии */
.pipeline-runner {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  color: #b45309;
  font-size: 0.95rem;
  line-height: 1;
  animation: runner 1.6s linear infinite;
  z-index: 2;
  pointer-events: none;
}

.pipeline-activity-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #ffc107;
  border-radius: 50%;
  animation: bounce 0.8s ease-in-out infinite;
}

.cf-pipeline-queue {
  padding: 0.25rem 0.15rem;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(255, 193, 7, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

@keyframes runner {
  0% { left: 0; opacity: 0.3; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { left: calc(100% - 14px); opacity: 0.3; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes cf-timeline-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.25), 0 0 8px rgba(255, 193, 7, 0.3); }
  50% { box-shadow: 0 0 0 7px rgba(255, 193, 7, 0.12), 0 0 18px rgba(255, 193, 7, 0.45); }
}

@keyframes cf-pipeline-ring {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.45); opacity: 0; }
}

@keyframes cf-pipeline-glow-run {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Legacy вертикальный timeline (не для пайплайна задачи) */
.cf-timeline:not(.cf-pipeline-horizontal) {
  margin: 0;
  padding: 0.25rem 0;
}

.cf-timeline__item {
  display: flex;
  gap: 0.85rem;
  position: relative;
}

.cf-timeline__track {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 2.25rem;
}

.cf-timeline__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.cf-timeline__line {
  flex: 1;
  width: 2px;
  min-height: 1rem;
  background: #e2e8f0;
  margin: 0.25rem 0;
}

.cf-timeline__item--done .cf-timeline__icon {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.cf-timeline__item--running .cf-timeline__icon {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
  animation: cf-timeline-pulse 1.5s ease-in-out infinite;
}

.cf-timeline__body {
  flex: 1;
  padding-bottom: 0.85rem;
  min-width: 0;
}

.cf-timeline__title {
  font-weight: 600;
  font-size: 0.875rem;
  color: #1e293b;
}

.cf-timeline__meta {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.cf-agent-details {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  overflow: hidden;
}

.cf-agent-detail-item {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
}

.cf-agent-detail-item:last-child {
  border-bottom: none;
}

.cf-agent-detail-item:nth-child(even) {
  background: #f8fafc;
}

/* Диалог агентов */
.cf-dialogue__item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.cf-dialogue__item:last-child {
  border-bottom: none;
}

.cf-dialogue__time {
  flex-shrink: 0;
  width: 4.5rem;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
  padding-top: 0.15rem;
}

.cf-dialogue__body {
  flex: 1;
  min-width: 0;
}

.cf-dialogue__agent {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1e293b;
}

.cf-dialogue__action {
  font-size: 0.75rem;
  color: #64748b;
}

.cf-dialogue__result {
  font-size: 0.8rem;
  color: #334155;
  margin-top: 0.25rem;
  line-height: 1.4;
}

.cf-dialogue__status {
  flex-shrink: 0;
}

.cf-dialogue__reasoning {
  font-size: 0.78rem;
  color: #475569;
  margin-top: 0.35rem;
  line-height: 1.45;
  background: #f8fafc;
  border-radius: 0.35rem;
  padding: 0.35rem 0.5rem;
}

.cf-dialogue__reasoning-label {
  opacity: 0.85;
}

.cf-dialogue__toggle {
  font-size: 0.75rem;
  vertical-align: baseline;
}

.cf-dialogue__meta {
  margin-top: 0.2rem;
}

.cf-dialogue__item--expanded .cf-dialogue__reasoning {
  background: #f1f5f9;
}

/* Стриминг токенов агента */
.cf-stream-panel {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #0f172a;
  color: #e2e8f0;
}

.cf-stream-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  border-bottom: 1px solid #334155;
}

.cf-stream-panel__body {
  margin: 0;
  padding: 0.75rem;
  max-height: 140px;
  overflow: auto;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.cf-stream-panel__status {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* Манифест агентов */
.cf-manifest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}

.cf-manifest-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  opacity: 0.72;
}

.cf-manifest-card--active {
  opacity: 1;
  background: #fff;
  border-color: #cbd5e1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.cf-manifest-card--idle .cf-manifest-card__id {
  color: #94a3b8;
}

.cf-manifest-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.cf-manifest-card__id {
  font-size: 0.72rem;
  word-break: break-all;
}

.cf-manifest-card__role {
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.35;
}

.cf-manifest-card__meta {
  margin-top: 0.35rem;
}

.cf-manifest-card__preview {
  margin-top: 0.35rem;
  color: #334155;
  line-height: 1.35;
  max-height: 3.2em;
  overflow: hidden;
}

/* Блок медиа-настроек в форме создания задачи */
.cf-task-media-settings {
  background: #f8fafc;
  border-color: #e2e8f0 !important;
}

.cf-task-media-settings .form-check-label {
  font-weight: 500;
}

/* Виджет календаря на дашборде */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  padding: 2px 0;
}

.calendar-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 3px;
  background: #f8fafc;
  font-size: 0.75rem;
  min-height: 52px;
  overflow: hidden;
  border: 1px solid transparent;
}

.calendar-day.today {
  background: #e3f2fd;
  border-color: #0d6efd;
}

.calendar-day.other-month {
  opacity: 0.35;
}

.calendar-day__num {
  font-weight: 600;
  font-size: 0.7rem;
  line-height: 1.2;
  color: #334155;
}

.calendar-event {
  font-size: 0.62rem;
  margin-top: 2px;
  padding: 1px 3px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  cursor: pointer;
  line-height: 1.25;
  /* Только контур статуса — без цветной заливки фона */
  background: transparent !important;
  border: 1px solid #94a3b8;
  color: #334155;
}

.calendar-event:hover {
  filter: brightness(0.95);
}

.calendar-event.pending {
  background: transparent !important;
  border-color: #ffc107;
  color: #b45309;
}

.calendar-event.published {
  background: transparent !important;
  border-color: #28a745;
  color: #28a745;
}

.calendar-event.failed {
  background: transparent !important;
  border-color: #dc3545;
  color: #dc3545;
}

.calendar-event .platform-icon {
  margin-right: 1px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: auto;
  height: auto;
}

.calendar-day__more {
  font-size: 0.6rem;
  color: #64748b;
  margin-top: 1px;
  cursor: default;
}

@media (max-width: 991.98px) {
  .calendar-day {
    min-height: 44px;
  }
}

/* Иконки платформ — без обводки/рамок и без заливки-фона */
.cf-platform-icon {
  display: inline-block;
  line-height: 1;
  vertical-align: -0.05em;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-text-stroke: 0 !important;
  text-shadow: none !important;
}
.cf-platform-icon--telegram { color: #229ED9; }
.cf-platform-icon--vk { color: #0077FF; }
.cf-platform-icon--zen { color: #FF8A00; }
.cf-platform-icon--youtube { color: #FF0000; }
.cf-platform-icon--site,
.cf-platform-icon--wordpress { color: #21759B; }
.cf-platform-icon--max { color: #4A90D9; }
.cf-platform-icon--instagram { color: #E4405F; }
.cf-platform-icon--threads { color: #101010; }
.cf-platform-icon--tiktok { color: #111111; }

.cf-platform-max-svg,
.cf-platform-zen-svg,
.cf-platform-tg-svg {
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
  background: transparent !important;
}

.calendar-event .platform-icon .cf-platform-icon,
.calendar-event .platform-icon svg {
  font-size: 0.75rem;
  width: 0.9em;
  height: 0.9em;
}

.cf-platform-check-label .cf-platform-icon,
.cf-platform-check-label svg.cf-platform-icon {
  margin-right: 0.35rem;
}

/* Компактная таблица задач (без горизонтальной прокрутки) */
.task-table,
#cf-active-processes.task-table {
  width: 100%;
  table-layout: fixed;
  margin-bottom: 0;
}
.task-table th,
.task-table td,
#cf-active-processes.task-table th,
#cf-active-processes.task-table td {
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-table .title-col { width: auto; }
.task-table .platform-col { width: 40px; text-align: center; }
.task-table .date-col { width: 90px; }
.task-table .stage-col { width: 72px; }
.task-table .status-col { width: 88px; }
.task-table .cost-col { width: 64px; }
.task-table .progress-col { width: 56px; }
.task-table .actions-col { width: 110px; }

@media (max-width: 1200px) {
  .task-table .cost-col,
  .task-table .progress-col {
    display: none;
  }
}

/* Убрать лишний горизонтальный скролл у таблицы задач на дашборде */
#cf-active-processes {
  min-width: 0;
}
.card-body .table-responsive.cf-tasks-scroll {
  overflow-x: visible;
}

