// ────────────────────────────────────────
// Stats Admin — BlogWeb
// ────────────────────────────────────────

// ── Tendance KPI (fleche + delta) ──
.bw-kpi__trend {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 2px;
    display: inline-flex;
    align-items: center;
    gap: 3px;

    &--up {
        color: #16a34a;
    }

    &--down {
        color: #dc2626;
    }

    &--stable {
        color: #94a3b8;
    }
}

// ── Navigation onglets stats ──
.bw-stats-nav {
    display: flex;
    gap: 0.25rem;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 0.25rem;

    &__item {
        padding: 0.5rem 1rem;
        border-radius: 8px;
        font-size: 0.85rem;
        font-weight: 500;
        color: #64748b;
        text-decoration: none;
        transition: all 0.15s;

        &:hover {
            background: #e2e8f0;
            color: #1e293b;
            text-decoration: none;
        }

        &.is-active {
            background: #fff;
            color: #2563eb;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        }
    }
}

// ── Entonnoir de conversion ──
.bw-funnel {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;

    &__step {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    &__bar {
        height: 36px;
        background: linear-gradient(90deg, #3b82f6, #93c5fd);
        border-radius: 6px;
        display: flex;
        align-items: center;
        padding: 0 0.75rem;
        min-width: 60px;
        transition: width 0.4s ease;

        span {
            color: #fff;
            font-size: 0.78rem;
            font-weight: 500;
            white-space: nowrap;
        }

        &--success {
            background: linear-gradient(90deg, #16a34a, #4ade80);
        }
    }

    &__value {
        font-size: 0.85rem;
        font-weight: 600;
        color: #1e293b;
        white-space: nowrap;

        small {
            font-weight: 400;
            color: #64748b;
        }
    }
}

// ── Mini-flux de parcours ──
.bw-flow {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: start;

    &__col {
        min-width: 0;
    }

    &__heading {
        font-size: 0.8rem;
        font-weight: 600;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        margin-bottom: 0.75rem;
    }

    &__item {
        position: relative;
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.75rem;
        background: #f8fafc;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        overflow: hidden;
    }

    &__bar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        background: rgba(59, 130, 246, 0.1);
        border-radius: 6px;
        transition: width 0.3s ease;
    }

    &__label {
        position: relative;
        font-size: 0.82rem;
        color: #334155;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        a {
            color: #2563eb;
            text-decoration: none;

            &:hover {
                text-decoration: underline;
            }
        }
    }

    &__pct {
        position: relative;
        font-size: 0.78rem;
        font-weight: 600;
        color: #64748b;
        flex-shrink: 0;
    }

    &__center {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding-top: 1.5rem;
    }

    &__page {
        background: #2563eb;
        color: #fff;
        padding: 0.75rem 1.25rem;
        border-radius: 10px;
        font-size: 0.85rem;
        font-weight: 600;
        text-align: center;
        max-width: 180px;
        word-break: break-all;
    }

    &__exit-rate {
        margin-top: 0.5rem;
        font-size: 0.78rem;
        color: #64748b;
    }
}

// ── Source badges ──
.bw-source-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;

    &--seo_google { background: #dcfce7; color: #166534; }
    &--seo_bing { background: #dbeafe; color: #1e40af; }
    &--seo_other { background: #e0f2fe; color: #075985; }
    &--direct { background: #f1f5f9; color: #475569; }
    &--social_linkedin { background: #dbeafe; color: #1e40af; }
    &--social_facebook { background: #ede9fe; color: #5b21b6; }
    &--social_other { background: #fce7f3; color: #9d174d; }
    &--email { background: #fef3c7; color: #92400e; }
    &--referral { background: #f3e8ff; color: #6b21a8; }
    &--other { background: #f1f5f9; color: #64748b; }
    &--paid_google { background: #fef3c7; color: #b45309; }
}

// ── Dashboard resume bloc ──
.bw-stats-summary {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;

    &__item {
        text-align: center;
        min-width: 80px;
    }

    &__value {
        font-size: 1.25rem;
        font-weight: 700;
        color: #0f172a;
    }

    &__label {
        font-size: 0.75rem;
        color: #64748b;
        margin-top: 2px;
    }
}

// ── Parcours de conversion ──
.bw-path {
    margin-bottom: 0.75rem;

    &__bar-bg {
        height: 8px;
        background: #e2e8f0;
        border-radius: 4px;
        margin-bottom: 0.35rem;
        overflow: hidden;
    }

    &__bar-fill {
        height: 100%;
        background: linear-gradient(90deg, #3b82f6, #60a5fa);
        border-radius: 4px;
        min-width: 4px;
        transition: width 0.3s ease;
    }

    &__label {
        font-size: 0.82rem;
        color: #334155;
        line-height: 1.3;
        word-break: break-word;
    }

    &__stats {
        font-size: 0.78rem;
        color: #64748b;
        margin-top: 2px;
    }

    &:last-child {
        margin-bottom: 0;
    }
}

// ── Heatmap temporel ──
.bw-heatmap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-x: auto;

    &__row {
        display: flex;
        gap: 2px;
        align-items: center;

        &--header {
            .bw-heatmap__cell {
                background: transparent !important;
                color: #94a3b8;
                font-size: 0.65rem;
                font-weight: 600;
            }
        }
    }

    &__label {
        min-width: 36px;
        font-size: 0.72rem;
        font-weight: 600;
        color: #64748b;
        text-align: right;
        padding-right: 4px;
        flex-shrink: 0;
    }

    &__cell {
        flex: 1;
        min-width: 24px;
        height: 28px;
        border-radius: 3px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.1s;

        &--header {
            height: 18px;
        }

        span {
            font-size: 0.6rem;
            font-weight: 600;
            color: #fff;
            text-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
        }

        &:hover {
            transform: scale(1.15);
            z-index: 1;
        }
    }
}

// ── Responsive ──
@media (max-width: 768px) {
    .bw-stats-nav {
        flex-wrap: wrap;

        &__item {
            font-size: 0.78rem;
            padding: 0.4rem 0.75rem;
        }
    }

    .bw-flow {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .bw-flow__center {
        order: -1;
        padding-top: 0;
    }
}
