/* The analytics pages (projects, work orders, conversations) share their stat cards, sections, chart frame,
   legend, charts and completed-item cards. Global rather than scoped because several pages draw them; the classes
   carry the analytics- prefix where a bare name (legend-item, legend-dot) is taken elsewhere. */

.analytics-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.analytics-stat-card {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid transparent;
    box-shadow: var(--shadow-md);
    padding: 1rem 1.1rem;
    transition: box-shadow 0.15s;
}

.analytics-stat-card:hover {
    box-shadow: var(--shadow-lg);
}

/* Accent as a straight bar just inside the card's left edge, matching the sidebar
   marker. A coloured border-left would bend around the rounded corner into a hook
   — so the inset top and bottom must clear the corner radius to stay straight. */
.analytics-stat-card::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 1.25rem;
    bottom: 1.25rem;
    width: 3px;
    border-radius: 3px;
    background: var(--clr-slate-300);
}

.stat-accent-blue::before { background: var(--clr-blue-500); }

.stat-accent-cyan::before { background: var(--clr-cyan-500); }

.stat-accent-green::before { background: var(--clr-green-500); }

.stat-accent-slate::before { background: var(--clr-slate-500); }

.analytics-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--clr-slate-900);
}

.analytics-stat-label {
    font-size: 0.82rem;
    color: var(--clr-slate-500);
    font-weight: 500;
}

.analytics-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.analytics-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--clr-slate-900);
    margin: 0 0 1rem 0;
}

.chart-container {
    margin-bottom: 1rem;
}

.analytics-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--clr-slate-500);
}

.analytics-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.analytics-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.completed-card {
    background: var(--clr-slate-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
}

.completed-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.completed-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--clr-slate-900);
    word-break: break-word;
}

.completed-card-duration {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--clr-blue-500);
    background: var(--clr-blue-50);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
    white-space: nowrap;
    flex-shrink: 0;
}

.completed-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.78rem;
    color: var(--clr-slate-500);
}

.completed-card-meta .meta-label {
    color: var(--clr-slate-400);
}

/* ── Shared by Vorgänge and Kommunikation ── */
.stat-accent-amber::before { background: var(--clr-amber-500); }
.stat-accent-red::before { background: var(--clr-red-500); }

/* Vertical bar chart: the monthly trend, two bars a month. The bare part names (bar, bar-label) are scoped
   under the chart, since they are global here. */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 180px;
    padding: 0 0.25rem;
}

.bar-chart .bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.bar-chart .bar-pair {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    flex: 1;
    width: 100%;
    justify-content: center;
}

.bar-chart .bar {
    width: 18px;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    transition: height 0.4s ease;
    position: relative;
}

.bar-chart .bar-created {
    background: var(--clr-blue-300);
}

.bar-chart .bar-completed {
    background: var(--clr-green-500);
}

.bar-chart .bar-value {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--clr-slate-600);
    white-space: nowrap;
}

.bar-chart .bar-label {
    font-size: 0.72rem;
    color: var(--clr-slate-500);
    margin-top: 0.4rem;
    white-space: nowrap;
}

.legend-created {
    background: var(--clr-blue-300);
}

.legend-completed {
    background: var(--clr-green-500);
}

/* Horizontal bar chart: one row per template or person. */
.horizontal-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.h-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.h-bar-label {
    width: 130px;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--clr-slate-700);
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.h-bar-track {
    flex: 1;
    background: var(--clr-slate-100);
    border-radius: var(--radius-sm);
    height: 22px;
    overflow: hidden;
}

.h-bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--clr-blue-500), var(--clr-blue-400));
    transition: width 0.4s ease;
    min-width: 2px;
}

.h-bar-fill.h-bar-user {
    background: linear-gradient(90deg, var(--clr-violet-500), var(--clr-violet-400));
}

.h-bar-value {
    width: 60px;
    flex-shrink: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--clr-slate-900);
    text-align: right;
}

@media (min-width: 640px) {
    .h-bar-label {
        width: 180px;
    }
}

@media (min-width: 900px) {
    .bar-chart .bar {
        width: 28px;
    }
}
