/* ================================================================
   FRIDAY AI — PIPELINE PAGE STYLES
   Wave 18: Visual Task Pipeline + Gantt + AI Planning
   ================================================================ */

/* ==================== LAYOUT ==================== */
#page-pipeline {
  padding: 0 0 40px;
  position: relative;
}

/* ==================== KPI GRID ==================== */
.pipe-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 1200px) {
  .pipe-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .pipe-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.pipe-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.pipe-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.pipe-kpi-card.blue::before  { background: var(--primary); }
.pipe-kpi-card.green::before { background: var(--success); }
.pipe-kpi-card.yellow::before { background: var(--warning); }
.pipe-kpi-card.red::before   { background: var(--error); }
.pipe-kpi-card.purple::before { background: #a855f7; }
.pipe-kpi-card.critical::before { background: #ff4444; }
.pipe-kpi-card.progress-card::before { background: var(--primary); }

.pipe-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.pipe-kpi-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.pipe-kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 4px;
}

.pipe-kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Progress bar inside KPI card */
.pipe-progress-bar {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0;
}

.pipe-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #00a3ff);
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ==================== TOOLBAR ==================== */
.pipe-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.pipe-toolbar-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.pipe-project-sel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.pipe-project-sel:focus {
  border-color: var(--primary);
}

.pipe-last-update {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.pipe-refresh-btn {
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 6px;
  color: var(--primary);
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
}

.pipe-refresh-btn:hover {
  background: rgba(0,212,255,0.2);
}

/* ==================== GANTT SECTION ==================== */
.pipe-gantt-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.pipe-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

/* ==================== GANTT GRID ==================== */
.pipe-gantt {
  min-width: 600px;
}

.pipe-gantt-header {
  display: flex;
  margin-bottom: 6px;
}

.pipe-gantt-label-col {
  width: 220px;
  min-width: 220px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-right: 12px;
  padding-bottom: 4px;
}

.pipe-gantt-bar-col {
  flex: 1;
  position: relative;
}

.pipe-gantt-timeline {
  position: relative;
  height: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.pipe-timeline-mark {
  position: absolute;
  font-size: 0.68rem;
  color: var(--text-muted);
  transform: translateX(-50%);
  white-space: nowrap;
  bottom: 4px;
}

/* ==================== TASK ROWS ==================== */
.pipe-gantt-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.pipe-gantt-row:hover {
  background: rgba(255,255,255,0.03);
}

.pipe-row-critical {
  background: rgba(255,68,68,0.04);
  border-left: 2px solid rgba(255,68,68,0.4);
  padding-left: 10px;
}

.pipe-gantt-label {
  width: 220px;
  min-width: 220px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-right: 12px;
}

.pipe-task-icon {
  font-size: 1rem;
  margin-top: 1px;
  flex-shrink: 0;
}

.pipe-task-info {
  flex: 1;
  min-width: 0;
}

.pipe-task-name {
  font-size: 0.82rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-bottom: 3px;
}

.pipe-task-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pipe-task-agent {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.pipe-critical-badge {
  font-size: 0.6rem;
  font-weight: 700;
  background: rgba(255,68,68,0.2);
  color: #ff6666;
  border: 1px solid rgba(255,68,68,0.3);
  border-radius: 3px;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pipe-dep-badge {
  font-size: 0.62rem;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ==================== BARS ==================== */
.pipe-bar-track {
  position: relative;
  height: 28px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  overflow: visible;
}

.pipe-bar {
  position: absolute;
  top: 4px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  overflow: hidden;
  min-width: 16px;
  transition: box-shadow 0.2s;
}

.pipe-bar:hover {
  box-shadow: 0 0 8px rgba(0,212,255,0.4);
  z-index: 2;
}

/* Status colors */
.pipe-bar-pending {
  background: linear-gradient(90deg, rgba(156,163,175,0.4), rgba(156,163,175,0.25));
  border: 1px solid rgba(156,163,175,0.3);
}

.pipe-bar-running {
  background: linear-gradient(90deg, rgba(0,212,255,0.5), rgba(0,212,255,0.25));
  border: 1px solid rgba(0,212,255,0.4);
  animation: pipe-pulse 2s ease-in-out infinite;
}

.pipe-bar-completed {
  background: linear-gradient(90deg, rgba(0,200,83,0.5), rgba(0,200,83,0.25));
  border: 1px solid rgba(0,200,83,0.4);
}

.pipe-bar-blocked {
  background: linear-gradient(90deg, rgba(255,68,68,0.4), rgba(255,68,68,0.2));
  border: 1px solid rgba(255,68,68,0.3);
}

.pipe-bar-planned {
  background: linear-gradient(90deg, rgba(168,85,247,0.4), rgba(168,85,247,0.2));
  border: 1px solid rgba(168,85,247,0.3);
}

/* Critical path override */
.pipe-bar-critical {
  border-color: rgba(255,68,68,0.6) !important;
  box-shadow: 0 0 6px rgba(255,68,68,0.25);
}

/* Running progress fill */
.pipe-bar-progress {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  transition: width 1s linear;
}

.pipe-bar-label {
  position: relative;
  z-index: 1;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.8);
  padding: 0 6px;
  white-space: nowrap;
}

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

/* ==================== LEGEND ==================== */
.pipe-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.pipe-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pipe-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.pipe-dot-running   { background: rgba(0,212,255,0.6); border: 1px solid rgba(0,212,255,0.4); }
.pipe-dot-pending   { background: rgba(156,163,175,0.4); border: 1px solid rgba(156,163,175,0.3); }
.pipe-dot-completed { background: rgba(0,200,83,0.5); border: 1px solid rgba(0,200,83,0.4); }
.pipe-dot-blocked   { background: rgba(255,68,68,0.4); border: 1px solid rgba(255,68,68,0.3); }
.pipe-dot-critical  { border: 2px solid rgba(255,68,68,0.6); background: transparent; }

/* ==================== AI PLANNER ==================== */
.pipe-planner-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.pipe-planner-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255,255,255,0.02);
  transition: background 0.2s;
  user-select: none;
}

.pipe-planner-header:hover {
  background: rgba(255,255,255,0.04);
}

.pipe-planner-badge {
  font-size: 0.65rem;
  background: rgba(168,85,247,0.2);
  color: #a855f7;
  border: 1px solid rgba(168,85,247,0.3);
  border-radius: 4px;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pipe-planner-chevron {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.pipe-planner-body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.pipe-planner-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 12px 0;
  line-height: 1.5;
}

.pipe-planner-textarea {
  width: 100%;
  min-height: 80px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 10px 14px;
  resize: vertical;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.pipe-planner-textarea:focus {
  border-color: rgba(0,212,255,0.4);
}

.pipe-planner-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.pipe-gen-btn {
  background: linear-gradient(135deg, var(--primary), #0099cc);
  border: none;
  border-radius: 8px;
  color: #000;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 9px 20px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.pipe-gen-btn:hover { opacity: 0.85; }
.pipe-gen-btn:active { transform: scale(0.97); }
.pipe-gen-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pipe-gen-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pipe-planner-result {
  margin-top: 12px;
  font-size: 0.85rem;
}

.pipe-gen-ok   { color: var(--success); }
.pipe-gen-warn { color: var(--warning); }
.pipe-gen-err  { color: var(--error); }
.pipe-gen-loading { color: var(--text-muted); }

/* ==================== EMPTY STATE ==================== */
.pipe-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.pipe-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.pipe-empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.pipe-empty-sub {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ==================== ERROR STATE ==================== */
.pipe-error {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.pipe-error-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.pipe-error-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.pipe-retry-btn {
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 6px;
  color: var(--primary);
  padding: 8px 18px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.pipe-retry-btn:hover { background: rgba(0,212,255,0.2); }

/* ==================== SKELETON ==================== */
.pipe-skeleton {
  animation: pipe-shimmer 1.5s ease-in-out infinite;
}

@keyframes pipe-shimmer {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.4; }
}

.skeleton-card {
  pointer-events: none;
}

.skel {
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
}

.skel-icon { width: 32px; height: 32px; border-radius: 50%; margin: 0 auto 6px; }
.skel-val  { width: 50%; height: 28px; margin: 0 auto 6px; }
.skel-lbl  { width: 70%; height: 12px; margin: 0 auto; }
.skel-title { width: 40%; height: 18px; margin-bottom: 16px; }
.skel-row-label { width: 200px; min-width: 200px; height: 34px; margin-right: 12px; }
.skel-row-bar   { height: 20px; border-radius: 4px; margin-bottom: 10px; }

/* ==================== MOBILE ==================== */
@media (max-width: 768px) {
  .pipe-gantt-section {
    padding: 14px;
  }

  .pipe-gantt-label-col,
  .pipe-gantt-label {
    width: 140px;
    min-width: 140px;
  }

  .pipe-task-name {
    font-size: 0.78rem;
  }

  .pipe-planner-header {
    padding: 12px 14px;
  }

  .pipe-planner-body {
    padding: 0 14px 14px;
  }

  .pipe-legend {
    gap: 10px;
  }
}
