/* ═══════════════════════════════════════════════════════════
   Help Knowledge Base — ReadTheDocs-style layout + FIE pipeline
   ═══════════════════════════════════════════════════════════ */

/* ── Layout ─────────────────────────────────────────────── */
.help-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 0;
    min-height: calc(100vh - 80px);
}

@media (max-width: 768px) {
    .help-layout {
        grid-template-columns: 1fr;
    }
}

/* ── Sidebar ────────────────────────────────────────────── */
.help-sidebar {
    border-right: 1px solid var(--border);
    background: var(--bg-surface, var(--bg-secondary));
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.help-sidebar-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
}

.help-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.help-sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.help-sidebar-link.active {
    background: var(--accent-alpha-10, rgba(99, 102, 241, 0.08));
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

.help-sidebar-link .help-nav-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
}

.help-sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 1.25rem;
}

/* Mobile sidebar toggle */
.help-mobile-toggle {
    display: none;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .help-sidebar { display: none; }
    .help-sidebar.mobile-open { display: block; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 50; height: 100vh; }
    .help-mobile-toggle { display: flex; align-items: center; gap: 0.5rem; }
}

/* ── Content Area ───────────────────────────────────────── */
.help-content {
    padding: 2rem 2.5rem;
    max-width: 800px;
}

@media (max-width: 768px) {
    .help-content { padding: 1rem; }
}

.help-content h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 1.5rem 0 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--accent-alpha-20, rgba(99, 102, 241, 0.15));
}

.help-content h3:first-child {
    margin-top: 0;
}

.help-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.25rem 0 0.4rem 0;
}

.help-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.help-content code {
    background: var(--bg-hover);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent);
}

/* ── Steps list ─────────────────────────────────────────── */
.help-steps {
    padding-left: 0;
    list-style: none;
    counter-reset: help-step;
}

.help-steps li {
    counter-increment: help-step;
    padding: 0.5rem 0 0.5rem 2.5rem;
    position: relative;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-steps li::before {
    content: counter(help-step);
    position: absolute;
    left: 0;
    top: 0.45rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--premium-purple, #7c3aed));
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Callout boxes ──────────────────────────────────────── */
.help-callout {
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    background: var(--bg-hover);
    border-left: 4px solid var(--accent);
}

.help-callout.help-callout-why {
    border-left-color: var(--warning);
    background: linear-gradient(135deg, var(--bg-hover), rgba(245, 158, 11, 0.04));
}

.help-callout-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.help-callout p {
    margin-bottom: 0;
    font-size: 0.9rem;
}

/* ── Example cards ──────────────────────────────────────── */
.help-example-card {
    border-radius: 12px;
    overflow: hidden;
    margin: 1.25rem 0;
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    animation: helpCardPop 0.4s ease-out;
}

@keyframes helpCardPop {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

.help-example-title {
    padding: 0.65rem 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--premium-purple, #7c3aed));
    letter-spacing: 0.02em;
}

.help-example-body {
    padding: 1rem 1.25rem;
}

.help-example-caption {
    font-size: 0.8rem;
    color: var(--text-muted) !important;
    font-style: italic;
    margin-top: 0.75rem;
    margin-bottom: 0 !important;
}

/* ── Mock UI elements inside examples ───────────────────── */
.help-mock-account, .help-mock-budget {
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.help-mock-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
}

.help-mock-icon {
    font-size: 1.5rem;
}

.help-mock-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ── Mock table ─────────────────────────────────────────── */
.help-mock-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}

.help-mock-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.help-mock-table td {
    padding: 0.5rem 0.5rem 0.5rem 0;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.help-neg { color: var(--error) !important; font-weight: 600; }
.help-pos { color: var(--success) !important; font-weight: 600; }

.help-tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent-alpha-10, rgba(99, 102, 241, 0.1));
    color: var(--accent);
}

/* ── Progress bar mock ──────────────────────────────────── */
.help-progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: var(--bg-hover);
    overflow: hidden;
    margin: 0.5rem 0;
}

.help-progress-fill {
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--success), #10b981);
    animation: helpBarFill 1.2s ease-out;
}

.help-progress-fill.help-progress-accent {
    background: linear-gradient(90deg, var(--accent), var(--premium-purple, #7c3aed));
}

@keyframes helpBarFill {
    0% { width: 0 !important; }
}

/* ── Flow steps (numbered walkthrough) ──────────────────── */
.help-flow-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.help-flow-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.help-flow-num {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--premium-purple, #7c3aed));
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.help-flow-arrow {
    padding-left: 0.45rem;
    color: var(--accent);
    font-size: 0.9rem;
    line-height: 1;
    opacity: 0.5;
}

/* ── Insight list (for Insights section) ────────────────── */
.help-insight-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.help-insight-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.help-insight-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.help-insight-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── FAQ ─────────────────────────────────────────────────── */
.help-faq-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.help-faq-item:last-child {
    border-bottom: none;
}

.help-faq-item h4 {
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.help-faq-item p {
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* ── Prev / Next navigation ─────────────────────────────── */
.help-nav-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.help-nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.help-nav-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.help-nav-btn i {
    font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════
   FIE Pipeline Visual
   ═══════════════════════════════════════════════════════════ */

.fie-pipeline-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1.25rem 1rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

/* Individual node */
.fie-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    transition: all 0.3s;
    flex-shrink: 0;
    position: relative;
}

.fie-node-bubble {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    transition: all 0.3s;
    position: relative;
}

.fie-node-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    transition: color 0.3s;
    white-space: nowrap;
}

/* Node states */
.fie-node.upstream .fie-node-bubble {
    border-color: var(--success);
    background: var(--success-light, rgba(16, 185, 129, 0.1));
}

.fie-node.upstream .fie-node-bubble::after {
    content: '✓';
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    font-size: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.fie-node.upstream .fie-node-label {
    color: var(--success);
}

/* Active node — glowing pulse */
.fie-node.active .fie-node-bubble {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--accent-alpha-10, rgba(99,102,241,0.1)), rgba(124,58,237,0.1));
    box-shadow: 0 0 20px var(--accent-alpha-20, rgba(99,102,241,0.2)),
                0 0 40px rgba(124,58,237,0.08);
    animation: fiePulseGlow 2s ease-in-out infinite;
    transform: scale(1.1);
}

.fie-node.active .fie-node-label {
    color: var(--accent);
    font-weight: 700;
}

@keyframes fiePulseGlow {
    0%, 100% {
        box-shadow: 0 0 20px var(--accent-alpha-20, rgba(99,102,241,0.2)),
                    0 0 40px rgba(124,58,237,0.08);
    }
    50% {
        box-shadow: 0 0 30px var(--accent-alpha-20, rgba(99,102,241,0.3)),
                    0 0 60px rgba(124,58,237,0.15);
    }
}

/* Downstream (dimmed) */
.fie-node.downstream .fie-node-bubble {
    opacity: 0.4;
}

.fie-node.downstream .fie-node-label {
    opacity: 0.4;
}

/* Hover on any node */
.fie-node:hover .fie-node-bubble {
    transform: scale(1.15);
    border-color: var(--accent);
}

.fie-node:hover .fie-node-label {
    color: var(--accent);
}

/* Connector line between nodes */
.fie-connector {
    width: 32px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}

.fie-connector.upstream {
    background: var(--success);
}

.fie-connector.active {
    background: linear-gradient(90deg, var(--success), var(--accent));
}

/* Animated particle on active connector */
.fie-connector.active::after {
    content: '';
    position: absolute;
    top: -2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: fieParticleFlow 1.8s ease-in-out infinite;
}

@keyframes fieParticleFlow {
    0% { left: 0; opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { left: calc(100% - 6px); opacity: 0; }
}

/* Responsive pipeline */
@media (max-width: 640px) {
    .fie-pipeline-strip {
        padding: 1rem 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }

    .fie-node-bubble {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }

    .fie-connector {
        width: 20px;
    }

    .fie-node-label {
        font-size: 0.5rem;
    }
}

/* ── Section header with icon ──────────────────────────── */
.help-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.help-section-icon {
    font-size: 2rem;
    line-height: 1;
}

.help-section-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.help-section-short {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}
