/* ========================================
   BEAMX1 Demo v2 — Dashboard Feedback
   Training feedback section (admin only)
   Aggregated stats, charts, voice comments
   ======================================== */

/* ===== Tab strip on training card ===== */
.tc-tabs {
    display: flex;
    gap: 0;
    margin-top: var(--space-sm);
    border-top: 1px solid var(--border);
    padding-top: var(--space-sm);
}

.tc-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 16px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all var(--duration) var(--ease);
    position: relative;
}

.tc-tab-btn:hover {
    color: var(--text-secondary);
}

.tc-tab-btn.active {
    color: var(--beam);
    border-bottom-color: var(--beam);
}

.tc-tab-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.tc-tab-btn .tc-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--beam-soft);
    color: var(--beam);
    font-size: 0.625rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Tab content panels */
.tc-tab-content {
    display: none;
    border-top: 1px solid var(--border);
    margin-top: var(--space-sm);
    padding-top: var(--space-md);
    animation: fbSlideDown 0.3s var(--ease);
}

.tc-tab-content.visible {
    display: block;
}

@keyframes fbSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Feedback Section ===== */
.fb-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Time filter strip */
.fb-time-filter {
    display: flex;
    gap: 4px;
    align-items: center;
}

.fb-time-btn {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: default;
    transition: all var(--duration) var(--ease);
    opacity: 0.4;
}

.fb-time-btn.active {
    background: var(--beam);
    border-color: var(--beam);
    color: white;
    opacity: 1;
    cursor: default;
}

.fb-time-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===== Stats Grid (top numbers) ===== */
.fb-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

.fb-stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: hidden;
    transition: all var(--duration) var(--ease);
}

.fb-stat-card:hover {
    border-color: var(--beam);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.08);
}

.fb-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--text-primary);
    line-height: 1;
}

.fb-stat-value .fb-stat-unit {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 2px;
}

.fb-stat-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 500;
}

.fb-stat-bar {
    margin-top: 6px;
}

.fb-stat-bar-track {
    height: 4px;
    border-radius: 2px;
    background: var(--bg-secondary);
    overflow: hidden;
}

.fb-stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--beam);
    transition: width 0.8s var(--ease);
}

.fb-stat-bar-fill.warning {
    background: var(--warning);
}

.fb-stat-bar-fill.danger {
    background: var(--danger);
}

.fb-stat-bar-text {
    font-size: 0.625rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-top: 2px;
    text-align: right;
}

.fb-stat-hint {
    font-size: 0.625rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 4px;
    opacity: 0.7;
}

/* ===== Sub-sections ===== */
.fb-subsection {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.fb-subsection-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.fb-subsection-title svg {
    width: 16px;
    height: 16px;
    color: var(--beam);
}

.fb-subsection-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: -4px;
}

/* ===== Question analysis bars ===== */
.fb-question-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fb-question-row {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    gap: var(--space-md);
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: all var(--duration) var(--ease);
}

.fb-question-row:hover {
    border-color: var(--beam);
}

.fb-question-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-question-bar-wrap {
    position: relative;
    height: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.fb-question-bar {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.8s var(--ease);
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.fb-question-bar.fast {
    background: linear-gradient(90deg, var(--beam), #34d399);
}

.fb-question-bar.medium {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.fb-question-bar.slow {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.fb-question-bar-label {
    font-size: 0.625rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: white;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.fb-question-metric {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 50px;
    text-align: right;
}

/* ===== Emotion distribution ===== */
.fb-emotion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.fb-emotion-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--duration) var(--ease);
}

.fb-emotion-item:hover {
    border-color: var(--beam);
}

.fb-emotion-emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.fb-emotion-name {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.fb-emotion-pct {
    font-size: 1rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--text-primary);
}

/* ===== Voice comments list ===== */
.fb-comments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fb-comment-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--space-md);
    align-items: start;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--duration) var(--ease);
}

.fb-comment-item:hover {
    border-color: var(--beam);
}

.fb-comment-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.fb-comment-icon.positive { background: rgba(16, 185, 129, 0.15); }
.fb-comment-icon.negative { background: rgba(239, 68, 68, 0.15); }
.fb-comment-icon.neutral { background: rgba(156, 163, 175, 0.15); }

.fb-comment-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fb-comment-text {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-style: italic;
    line-height: 1.5;
}

.fb-comment-meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.fb-comment-sentiment {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    align-self: start;
}

.fb-comment-sentiment.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--beam);
}

.fb-comment-sentiment.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.fb-comment-sentiment.neutral {
    background: rgba(156, 163, 175, 0.15);
    color: var(--text-muted);
}

/* ===== Sentiment summary bar ===== */
.fb-sentiment-bar {
    display: flex;
    height: 28px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}

.fb-sentiment-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    transition: width 0.8s var(--ease);
    min-width: 0;
}

.fb-sentiment-seg.positive { background: var(--beam); }
.fb-sentiment-seg.neutral { background: #6b7280; }
.fb-sentiment-seg.negative { background: var(--danger); }

.fb-sentiment-legend {
    display: flex;
    gap: var(--space-md);
    margin-top: 6px;
}

.fb-sentiment-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.fb-sentiment-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.fb-sentiment-legend-dot.positive { background: var(--beam); }
.fb-sentiment-legend-dot.neutral { background: #6b7280; }
.fb-sentiment-legend-dot.negative { background: var(--danger); }

/* ===== Engagement chart (simple bar chart) ===== */
.fb-chart-wrap {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.fb-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
    padding-top: var(--space-sm);
}

.fb-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
    justify-content: flex-end;
}

.fb-bar {
    width: 100%;
    max-width: 40px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--beam);
    transition: height 0.8s var(--ease);
    position: relative;
    min-height: 2px;
}

.fb-bar.low { background: var(--danger); }
.fb-bar.medium { background: var(--warning); }
.fb-bar.high { background: var(--beam); }

.fb-bar-value {
    font-size: 0.5625rem;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-muted);
}

.fb-bar-label {
    font-size: 0.5625rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Loading state ===== */
.fb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    gap: var(--space-md);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.fb-loading .spinner {
    width: 24px;
    height: 24px;
}

/* ===== Empty state ===== */
.fb-empty {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.fb-empty svg {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-md);
    opacity: 0.3;
}

/* ===== Trend mini-chart (sparkline-like) ===== */
.fb-trend-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
}

.fb-trend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.fb-trend-count {
    font-size: 1.125rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--text-primary);
}

.fb-trend-label {
    font-size: 0.5625rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .fb-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .fb-question-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .fb-question-bar-wrap {
        height: 20px;
    }

    .fb-comment-item {
        grid-template-columns: 1fr;
    }

    .tc-tabs {
        flex-wrap: wrap;
    }

    .fb-env-split {
        grid-template-columns: 1fr;
    }

    .fb-branch-map-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .fb-perf-table {
        font-size: 0.6875rem;
    }
}

/* ===== Branching: Environment Distribution ===== */
.fb-env-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.fb-env-block {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.fb-env-block-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 500;
}

/* Segment bar fills (reused in environment + branch map) */
.fb-seg-bar-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    transition: width 0.8s var(--ease);
}

.fb-seg-bar-text {
    font-size: 0.625rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* ===== Branching: Question Map ===== */
.fb-branch-map-desc,
.fb-seq-desc,
.fb-perf-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: var(--space-sm);
}

.fb-branch-map-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fb-branch-map-row {
    display: grid;
    grid-template-columns: 140px 1fr auto;
    gap: var(--space-md);
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--duration) var(--ease);
}

.fb-branch-map-row:hover {
    border-color: var(--beam);
}

.fb-branch-map-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-branch-map-bar-wrap {
    height: 22px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.fb-branch-shown {
    height: 100%;
    background: linear-gradient(90deg, var(--beam), #34d399);
    border-radius: var(--radius-sm);
}

.fb-branch-map-stats {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 100px;
    text-align: right;
}

.fb-branch-shown-num {
    font-size: 0.6875rem;
    font-family: var(--font-mono);
    color: var(--beam);
    font-weight: 600;
}

.fb-branch-skipped-num {
    font-size: 0.6875rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* Zero-shown questions (never displayed to anyone) */
.fb-branch-map-row.fb-branch-zero {
    opacity: 0.6;
    border-style: dashed;
}

.fb-branch-map-row.fb-branch-zero .fb-branch-map-bar-wrap {
    background: repeating-linear-gradient(
        -45deg,
        var(--bg-secondary),
        var(--bg-secondary) 4px,
        var(--bg-tertiary) 4px,
        var(--bg-tertiary) 8px
    );
}

/* Skip reason text below the row */
.fb-branch-map-reason {
    grid-column: 1 / -1;
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
    padding-top: 2px;
}

/* ===== Branching: Sequences ===== */
.fb-seq-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fb-seq-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: var(--space-md);
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--duration) var(--ease);
}

.fb-seq-row:hover {
    border-color: var(--beam);
}

.fb-seq-rank {
    font-size: 0.875rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--beam);
}

.fb-seq-path {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.fb-seq-count {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.fb-seq-pct {
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== Branching: Performance Table ===== */
.fb-perf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-bottom: var(--space-md);
}

.fb-perf-table thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

.fb-perf-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.fb-perf-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.fb-perf-table tbody tr:last-child td {
    border-bottom: none;
}

.fb-perf-name {
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-body);
}
