/* ===== My Projects page ===== */
.projects-page {
  font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
  background: #f4f5f7;
  color: var(--clr-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.page-hero__count.badge {
  margin-right: 4px;
}

.page-hero--project .page-hero__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--clr-text-2);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.page-hero--project .page-hero__back:hover {
  color: var(--clr-primary);
}

.page-hero--project .page-hero__back i,
.page-hero--project .page-hero__back svg {
  width: 16px;
  height: 16px;
}

.page-hero--project .page-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 20px 28px;
}

.page-hero--project .page-hero__copy {
  min-width: 0;
  max-width: 100%;
}

.page-hero--project .page-hero__copy h1 {
  max-width: 70rem;
}

.page-hero__project-desc {
  max-width: 70rem;
  line-height: 1.55;
  color: var(--clr-text-2);
}

.page-hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  max-width: 70rem;
}

.page-hero__stats:empty {
  display: none;
}

.page-hero__export .export-menu__trigger {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.08);
}

.page-hero--project .page-hero__actions {
  align-items: flex-end;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 2px;
}

.page-hero--project #heroStatus .status-badge {
  flex-shrink: 0;
}

.page-hero--project.is-completed #refreshBtn {
  display: none !important;
}

.badge {
  background: linear-gradient(135deg, #fff0f3, #ffdde4);
  color: var(--clr-primary);
  border-radius: var(--radius-full);
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid rgba(219, 0, 50, 0.2);
}

.projects-page .btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1.5px solid var(--clr-border);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--clr-text-2);
  font-family: inherit;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.08);
}

.projects-page .btn-refresh i,
.projects-page .btn-refresh svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.25;
}

.projects-page .btn-refresh:hover {
  background: #fff0f3;
  border-color: var(--clr-primary-light);
  color: var(--clr-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(219, 0, 50, 0.12), 0 1px 3px rgba(15, 23, 42, 0.08);
}

@media (max-width: 720px) {
  .page-hero__actions {
    width: 100%;
    gap: 10px;
  }

  .page-hero__actions .btn-refresh {
    flex: 1;
    justify-content: center;
    min-height: 42px;
  }

  .project-card {
    padding: 16px 16px 12px;
    gap: 12px;
  }

  .project-card__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .project-card__summary {
    min-height: 0;
    -webkit-line-clamp: 4;
  }

  .project-card__foot {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 10px;
  }

  .project-card__actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .card-btn {
    justify-content: center;
    min-height: 40px;
    background: var(--clr-surface-2);
  }
}

.projects-shell {
  flex: 1;
  width: 100%;
  padding: 28px var(--page-gutter) 48px;
}

/* ===== Grid + cards ===== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 18px;
}

.project-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  padding: 20px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.project-card.is-processing { border-left: 3px solid var(--clr-warning); }
.project-card.is-completed { border-left: 3px solid var(--clr-success); }
.project-card.is-failed { border-left: 3px solid var(--clr-danger); }

.project-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-card__head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.project-card__summary {
  font-size: 0.88rem;
  color: var(--clr-text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3em;
}

.project-card__error {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--clr-danger);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--clr-surface-2);
}

.project-card__date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--clr-muted);
}
.project-card__date i,
.project-card__date svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
  flex-shrink: 0;
}

.project-card__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--clr-text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.card-btn i,
.card-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
  flex-shrink: 0;
}

.card-btn--danger {
  color: var(--clr-primary);
}

/* ===== Status badge ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
}
.status-badge i,
.status-badge svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
  flex-shrink: 0;
}
.status-badge.is-processing {
  background: #fff7ed;
  color: #b45309;
  box-shadow: 0 1px 2px rgba(180, 83, 9, 0.1), 0 2px 4px rgba(180, 83, 9, 0.08);
}
.status-badge.is-completed {
  background: #ecfdf5;
  color: #0d7a55;
  box-shadow: 0 1px 2px rgba(13, 122, 85, 0.1), 0 2px 4px rgba(13, 122, 85, 0.08);
}
.status-badge.is-failed {
  background: #fff0f3;
  color: var(--clr-danger);
  box-shadow: 0 1px 2px rgba(219, 0, 50, 0.1), 0 2px 4px rgba(219, 0, 50, 0.08);
}

.badge-spin { animation: mp-spin 1s linear infinite; }
@keyframes mp-spin { to { transform: rotate(360deg); } }

/* ===== Loading / empty ===== */
.projects-loading,
.detail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--clr-text-2);
  font-size: 0.9rem;
  grid-column: 1 / -1;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(219, 0, 50, 0.18);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: mp-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.projects-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.projects-empty__orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff0f3;
  color: var(--clr-primary);
  margin-bottom: 6px;
}
.projects-empty__orb i { width: 28px; height: 28px; }
.projects-empty h3 { font-size: 1.15rem; font-weight: 700; }
.projects-empty p { color: var(--clr-text-2); font-size: 0.9rem; max-width: 360px; }
.projects-empty .btn-refresh { margin-top: 10px; }

/* ===== Detail view ===== */
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-primary);
  margin-bottom: 4px;
}

.detail-head h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.detail-summary {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.detail-summary__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.detail-summary__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--clr-muted);
  margin: 0;
}

.detail-summary__text {
  font-size: 0.92rem;
  color: var(--clr-text-2);
  line-height: 1.6;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.stat-chip {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  background: var(--clr-surface-2);
  color: var(--clr-text-2);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
}
.stat-chip--rec {
  background: #fff0f3;
  color: var(--clr-primary);
  box-shadow: 0 1px 2px rgba(219, 0, 50, 0.1), 0 2px 4px rgba(219, 0, 50, 0.08);
}

.detail-error {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff0f3;
  border: 1px solid rgba(219, 0, 50, 0.2);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  color: var(--clr-danger);
}
.detail-error i { width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px; }
.detail-error p { color: var(--clr-text-2); font-size: 0.88rem; margin-top: 4px; }

/* ===== Segmented tabs (matches Analyze) ===== */
.detail-workspace {
  margin-top: 4px;
}

.detail-workspace__tabs {
  margin-bottom: 14px;
}

.results-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: var(--clr-surface-2);
  border-radius: var(--radius-full);
  border: 1px solid var(--clr-border);
}

.results-tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--clr-text-2);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.results-tab__count {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(29, 37, 44, 0.06);
  color: var(--clr-text);
}

.results-tab.is-active {
  background: #fff;
  color: var(--clr-primary);
  box-shadow: 0 1px 4px rgba(29, 37, 44, 0.08);
}

.results-tab.is-active .results-tab__count {
  background: #fff0f3;
  color: var(--clr-primary);
}

.detail-workspace__body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ===== Feature tiles ===== */
.features-pane { display: none; flex-direction: column; gap: 16px; }
.features-pane.is-visible { display: flex; }
.pane-empty { color: var(--clr-muted); font-size: 0.9rem; padding: 24px; text-align: center; }

.feature-tile {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.feature-tile.is-recommended { border-radius: 0; border-left: 3px solid var(--clr-primary); }
.feature-tile__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.feature-tile__head h4 { font-size: 1rem; font-weight: 700; }
.feature-tile__badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--clr-muted);
  background: var(--clr-surface-2);
  padding: 3px 9px;
  border-radius: var(--radius-full);
}
.feature-tile__desc { font-size: 0.85rem; color: var(--clr-text-2); line-height: 1.55; margin-bottom: 12px; }

.uc-grid { display: flex; flex-direction: column; gap: 8px; }
.uc-empty { font-size: 0.82rem; color: var(--clr-muted); }

.uc-item {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fcfcfd;
}
.uc-item.is-expanded {
  border-color: var(--pf-border-soft, rgba(219, 0, 50, 0.25));
}

.uc-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.uc-tile:hover { background: var(--clr-surface-2); }
.uc-tile.is-active {
  background: #fff0f3;
}
.uc-tile__icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--clr-surface-2);
  color: var(--clr-primary);
  flex-shrink: 0;
}
.uc-tile__icon [data-lucide] {
  width: 16px;
  height: 16px;
}
.uc-tile__icon i { width: 16px; height: 16px; }
.uc-tile__body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.uc-tile__body strong { font-size: 0.86rem; font-weight: 600; }
.uc-tile__body span {
  font-size: 0.78rem; color: var(--clr-text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.uc-tile__arrow { color: var(--clr-muted); flex-shrink: 0; }
.uc-tile__arrow i { width: 18px; height: 18px; }

.uc-chip {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--clr-surface-2);
  color: var(--clr-text-2);
  flex-shrink: 0;
}
.uc-chip--done { background: #ecfdf5; color: #0d7a55; }
.uc-chip--fail { background: #fff0f3; color: var(--clr-danger); }

.uc-detail {
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
}

.uc-detail__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--clr-border);
  background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
}

.uc-detail__toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--clr-primary);
}

.uc-detail__inner {
  padding: 16px 18px 12px;
}

.uc-detail__inner.markdown-body {
  padding: 16px 18px 20px;
}
.detail-loading { padding: 24px 16px; }

/* ===== Markdown body ===== */
.markdown-body { font-size: 0.88rem; color: var(--clr-text); line-height: 1.65; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 14px 0 8px; font-weight: 700; }
.markdown-body h1 { font-size: 1.2rem; }
.markdown-body h2 { font-size: 1.05rem; }
.markdown-body h3 { font-size: 0.95rem; }
.markdown-body p { margin: 8px 0; }
.markdown-body ul, .markdown-body ol { margin: 8px 0 8px 20px; }
.markdown-body li { margin: 4px 0; }
.markdown-body code {
  background: var(--clr-surface-2);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}
.markdown-body pre { background: #1d252c; color: #f6f6f6; padding: 12px; border-radius: 8px; overflow-x: auto; }
.markdown-body pre code { background: transparent; color: inherit; }

@media (max-width: 900px) {
  .page-hero--project .page-hero__inner {
    grid-template-columns: 1fr;
  }

  .page-hero--project .page-hero__actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .page-hero__project-desc,
  .page-hero__stats {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .projects-shell { padding-left: 20px; padding-right: 20px; }
  .projects-grid { grid-template-columns: 1fr; }

  .detail-summary__top {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .page-hero__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .page-hero__count.badge {
    grid-column: 1 / -1;
    justify-self: start;
    margin-right: 0;
  }

  .projects-page .btn-refresh {
    padding: 9px 10px;
    font-size: 0.78rem;
  }
}

@media (max-width: 390px) {
  .project-card__actions {
    grid-template-columns: 1fr;
  }
}
