/**
 * workflow-tool.css - shared chrome for the Workflows family
 * (Competitor Analysis, Website Health Checker, Pre-Publish Checker).
 *
 * Composes the shared tools.css primitives; per-tool tool.css files
 * only add accents and column widths. The accent comes from the
 * --wf-accent custom properties set inline by wf-page.php.
 */

/* ------------------------------------------------------------------ */
/* Form                                                                */
/* ------------------------------------------------------------------ */

.wf-intro {
    margin: 0 0 14px;
    color: #5b5b5b;
    font-size: 14.5px;
    line-height: 1.55;
}

.wf-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wf-field-label {
    font-weight: 600;
    font-size: 13.5px;
    color: #333;
}

/* Guard against the shared .text-input flex-basis-becomes-height trap
   inside a column-flex field. */
.wf-input {
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.wf-input-textarea {
    resize: vertical;
    min-height: 120px;
}

.wf-field-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12.5px;
    min-height: 16px;
}

.wf-field-hint { color: #8a8a8a; }

.wf-field-feedback { color: #8a8a8a; }
.wf-field-feedback.is-ok { color: #15803d; }
.wf-field-feedback.is-error { color: #b91c1c; }

.wf-submit-row {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wf-cancel-btn { margin-top: 10px; }

/* ------------------------------------------------------------------ */
/* Report sections                                                     */
/* ------------------------------------------------------------------ */

.wf-report {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-top: 22px;
    scroll-margin-top: 16px;
}

.wf-report[hidden] { display: none; }

/* ------------------------------------------------------------------ */
/* Sticky section navigator                                            */
/*                                                                     */
/* Injected by workflow-tool.js as the report's first child: one chip  */
/* per visible section (status dot + title). Pins to the viewport top  */
/* while the reader is inside the report and scrolls away with it.     */
/* Its measured height is published as --wf-sticky-offset on           */
/* #wf-report, which the sticky theads and scroll targets below use.   */
/* ------------------------------------------------------------------ */

.wf-section-nav {
    position: sticky;
    top: 0;
    z-index: 20;                      /* above the sticky theads (z 5) */
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;                 /* one row always; chips scroll  */
    padding: 8px 10px;
    background: #fffdfa;              /* opaque: rows scroll beneath   */
    border: 1px solid #e8e2da;
    border-radius: 10px;
    box-shadow: 0 6px 14px -12px rgba(31, 27, 22, 0.5);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.wf-section-nav[hidden] { display: none; }

.wf-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: #5b5b5b;
    cursor: pointer;
    white-space: nowrap;
}

.wf-nav-item[hidden] { display: none; }

.wf-nav-item:hover {
    background: #f5f1ec;
    color: #2f2f2f;
}

.wf-nav-item.is-active {
    background: var(--wf-accent-tint, #f3e8ff);
    border-color: var(--wf-accent-tint, #f3e8ff);
    color: var(--wf-accent-dark, #6d28d9);
}

.wf-nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d5cfc6;              /* pending / skipped */
    flex: 0 0 auto;
}

.wf-nav-item.is-running .wf-nav-dot {
    background: var(--wf-accent, #7c3aed);
    animation: wf-nav-pulse 1.1s ease infinite;
}

.wf-nav-item.is-done   .wf-nav-dot { background: #16a34a; }
.wf-nav-item.is-failed .wf-nav-dot { background: #dc2626; }

@keyframes wf-nav-pulse { 50% { opacity: 0.35; } }

.wf-section {
    background: #fff;
    border: 1px solid #e8e2da;
    border-radius: 10px;
    overflow: visible;
    /* Nav-click scroll target: land just below the pinned nav bar. */
    scroll-margin-top: calc(var(--wf-sticky-offset, 0px) + 10px);
}

.wf-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid #efe9e1;
    background: linear-gradient(180deg, #fdfcfa, #f9f6f2);
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

.wf-section-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.wf-section-title {
    margin: 0;
    font-size: 16.5px;
    font-weight: 700;
    color: #2f2f2f;
}

.wf-section-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wf-section-desc {
    margin: 10px 18px 0;
    color: #6b6b6b;
    font-size: 13px;
    line-height: 1.5;
}

.wf-section-body {
    padding: 16px 18px 18px;
}

.wf-section-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--wf-accent, #7c3aed);
    text-decoration: none;
    white-space: nowrap;
}

.wf-section-link:hover {
    color: var(--wf-accent-dark, #6d28d9);
    text-decoration: underline;
}

.wf-section-link[hidden] { display: none; }

/* The per-section Copy / CSV / Excel buttons are toggled via the
   `hidden` property, but they compose the shared .export-btn whose
   author-level `display: inline-flex` beats the UA [hidden] rule
   (the project-wide [hidden]-with-flex trap). Without this override
   they would stay visible mid-run and on zero-row sections. */
.wf-export-btn[hidden],
.wf-copy-btn[hidden] { display: none; }

/* Status chips */
.wf-section-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.wf-section-chip.is-pending { background: #f1efec; color: #8a8a8a; }
.wf-section-chip.is-running { background: var(--wf-accent-tint, #f3e8ff); color: var(--wf-accent-dark, #6d28d9); }
.wf-section-chip.is-done    { background: #e8f7ee; color: #15803d; }
.wf-section-chip.is-failed  { background: #fdeaea; color: #b91c1c; }
.wf-section-chip.is-skipped { background: #f1efec; color: #9a9a9a; }

.wf-section-chip.is-running::before {
    content: '';
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: wf-spin 0.9s linear infinite;
}

@keyframes wf-spin { to { transform: rotate(360deg); } }

/* Skeleton shimmer while a section waits */
.wf-section-skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wf-section-skeleton span {
    display: block;
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f2eee9 25%, #faf7f3 50%, #f2eee9 75%);
    background-size: 200% 100%;
    animation: wf-shimmer 1.4s ease infinite;
}

.wf-section-skeleton span:nth-child(2) { width: 82%; }
.wf-section-skeleton span:nth-child(3) { width: 64%; }

@keyframes wf-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

.wf-section-error {
    margin: 0;
    color: #9a4b4b;
    font-size: 13.5px;
}

.wf-section-empty {
    margin: 0;
    color: #8a8a8a;
    font-size: 13.5px;
}

/* ------------------------------------------------------------------ */
/* Summary metric strip (tiles)                                        */
/* ------------------------------------------------------------------ */

.wf-summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 10px;
}

.wf-tile {
    border: 1px solid #efe9e1;
    border-radius: 8px;
    background: #fdfcfa;
    padding: 12px 12px 10px;
    min-width: 0;
}

.wf-tile-value {
    font-size: 20px;
    font-weight: 700;
    color: #2f2f2f;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.wf-tile-value .wf-muted { color: #b5b0a8; font-weight: 500; }

.wf-tile-label {
    margin-top: 3px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #9a958d;
}

.wf-tile-sub {
    margin-top: 2px;
    font-size: 11.5px;
    color: #8a8a8a;
}

.wf-tile.is-accent { border-color: var(--wf-accent-tint, #f3e8ff); }
.wf-tile.is-accent .wf-tile-value { color: var(--wf-accent-dark, #6d28d9); }

/* Generic small badge for tile qualifiers (risk labels etc.) */
.wf-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.wf-badge.is-good   { background: #e8f7ee; color: #15803d; }
.wf-badge.is-medium { background: #fdf3e0; color: #b45309; }
.wf-badge.is-bad    { background: #fdeaea; color: #b91c1c; }
.wf-badge.is-muted  { background: #f1efec; color: #8a8a8a; }

/* ------------------------------------------------------------------ */
/* In-section tables (compose shared .results-table)                   */
/* ------------------------------------------------------------------ */

.wf-table-wrap {
    overflow-x: clip;
    /* Pager-click scroll target: table top lands below the sticky nav,
       with the sticky thead snapping in right under it. */
    scroll-margin-top: calc(var(--wf-sticky-offset, 0px) + 8px);
}

.wf-section .results-table { margin: 0; }

.wf-truncation-note {
    margin: 10px 0 0;
    font-size: 12px;
    color: #9a958d;
}

/* Simple pagination row reused across sections */
.wf-pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
    font-size: 12.5px;
    color: #6b6b6b;
}

.wf-pager button {
    border: 1px solid #ddd6cc;
    background: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12.5px;
    cursor: pointer;
    color: #444;
}

.wf-pager button:disabled { opacity: 0.4; cursor: default; }

/* ------------------------------------------------------------------ */
/* Mobile                                                              */
/* ------------------------------------------------------------------ */

@media (max-width: 640px) {
    .wf-section-head { padding: 12px 12px; }
    .wf-section-body { padding: 12px; }
    .wf-section-desc { margin: 8px 12px 0; }
    .wf-summary-strip { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); }
    .wf-tile-value { font-size: 17px; }
    .wf-section-nav { padding: 6px 8px; }
    .wf-nav-item { padding: 4px 10px; font-size: 12px; }
}

/* ------------------------------------------------------------------ */
/* Full-report toolbar                                                 */
/* ------------------------------------------------------------------ */

/* Buttons sit right next to the label (left-grouped): the toast stack
   overlays the toolbar's right edge, so right-aligned buttons were
   covered by e.g. the "Report ready" toast at the exact moment the
   toolbar appears. */
.wf-report-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border: 1px solid var(--wf-accent-tint, #f3e8ff);
    border-radius: 10px;
    background: linear-gradient(180deg, #fff, var(--wf-accent-tint, #f3e8ff));
}

.wf-report-toolbar[hidden] { display: none; }

.wf-report-toolbar-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-right: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--wf-accent-dark, #6d28d9);
}

/* Workflow sections carry their own card heads instead of the shared
   .results-header strip, so the shared thead sticky offset (tuned to
   sit under that strip) would leave a gap that scrolled rows peek
   through. Stick workflow theads right below the section nav bar
   (whose measured height the driver publishes as --wf-sticky-offset
   on #wf-report; 0 when the nav is hidden). */
.wf-section .results-table thead th {
    top: var(--wf-sticky-offset, 0px);
}
