/**
 * CSS-ShareHub — Analytics Dashboard styles
 */

/* ═══ Period selector ═══════════════════════════════════════ */
.cssh-period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cssh-period-select {
    padding: 6px 12px;
    border: 1.5px solid #E5E7EB;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    background: white;
    cursor: pointer;
    color: #1B4332;
}

.cssh-period-select:focus {
    border-color: #40916C;
    outline: none;
}

/* ═══ KPI cards ═════════════════════════════════════════════ */
.cssh-analytics-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.cssh-kpi-card {
    background: white;
    border-radius: 14px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #F3F4F6;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.cssh-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #1B4332, #40916C);
}

.cssh-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

.cssh-kpi-1::before { background: linear-gradient(90deg, #1B4332, #40916C); }
.cssh-kpi-2::before { background: linear-gradient(90deg, #1E40AF, #3B82F6); }
.cssh-kpi-3::before { background: linear-gradient(90deg, #065F46, #10B981); }
.cssh-kpi-4::before { background: linear-gradient(90deg, #92400E, #F59E0B); }

.cssh-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #F0FDF4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.cssh-kpi-2 .cssh-kpi-icon { background: #DBEAFE; }
.cssh-kpi-3 .cssh-kpi-icon { background: #D1FAE5; }
.cssh-kpi-4 .cssh-kpi-icon { background: #FEF3C7; }

.cssh-kpi-content {
    flex: 1;
    min-width: 0;
}

.cssh-kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: #1B4332;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.cssh-kpi-label {
    font-size: 12px;
    color: #6B7280;
    margin-top: 4px;
    font-weight: 600;
}

.cssh-kpi-rate {
    color: #10B981;
    font-weight: 700;
    margin-left: 4px;
}

@media (max-width: 900px) {
    .cssh-analytics-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ═══ Analytics grid ════════════════════════════════════════ */
.cssh-analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.cssh-analytics-grid .cssh-chart-evolution { grid-column: 1 / -1; }
.cssh-analytics-grid .cssh-chart-funnel    { grid-column: 1; }
.cssh-analytics-grid .cssh-chart-bundles   { grid-column: 2; grid-row: 2 / span 2; }
.cssh-analytics-grid .cssh-chart-heatmap   { grid-column: 1; }

@media (max-width: 900px) {
    .cssh-analytics-grid {
        grid-template-columns: 1fr;
    }
    .cssh-analytics-grid > * {
        grid-column: 1 !important;
        grid-row: auto !important;
    }
}

/* ═══ Chart container ═══════════════════════════════════════ */
.cssh-chart-container {
    background: #FAFBFC;
    border: 1px solid #F3F4F6;
    border-radius: 14px;
    padding: 20px;
    position: relative;
    transition: opacity 0.2s;
}

.cssh-chart-container.cssh-loading-overlay {
    opacity: 0.4;
    pointer-events: none;
}

.cssh-chart-title {
    font-size: 13px;
    font-weight: 700;
    color: #1B4332;
    margin: 0 0 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cssh-chart-evolution canvas { height: 240px !important; }
.cssh-chart-heatmap canvas   { height: 200px !important; }

/* ═══ Funnel ════════════════════════════════════════════════ */
.cssh-funnel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
}

.cssh-funnel-step {
    animation: csshFadeInUp 0.5s ease-out backwards;
}

.cssh-funnel-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.cssh-funnel-name {
    font-size: 13px;
    font-weight: 700;
    color: #1F2937;
}

.cssh-funnel-value {
    font-size: 18px;
    font-weight: 800;
    color: #1B4332;
    font-variant-numeric: tabular-nums;
}

.cssh-funnel-bar-wrap {
    background: #F3F4F6;
    border-radius: 8px;
    height: 36px;
    overflow: hidden;
    position: relative;
}

.cssh-funnel-bar {
    height: 100%;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 14px;
    transition: width 0.8s cubic-bezier(0.65, 0, 0.35, 1);
    animation: csshFunnelGrow 1s cubic-bezier(0.65, 0, 0.35, 1);
}

@keyframes csshFunnelGrow {
    from { width: 0% !important; }
}

.cssh-funnel-pct {
    color: white;
    font-weight: 800;
    font-size: 13px;
}

.cssh-funnel-drop {
    text-align: center;
    color: #EF4444;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ═══ Top Bundles ═══════════════════════════════════════════ */
#cssh-top-bundles {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cssh-bundle-rank {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    background: white;
    border: 1px solid #F3F4F6;
    border-radius: 12px;
    transition: all 0.2s;
}

.cssh-bundle-rank:hover {
    border-color: #40916C;
    transform: translateX(4px);
}

.cssh-bundle-medal {
    font-size: 24px;
    line-height: 1;
}

.cssh-bundle-rank-info { min-width: 0; }

.cssh-bundle-rank-name {
    font-size: 13px;
    font-weight: 700;
    color: #1F2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.cssh-bundle-rank-stats {
    font-size: 11px;
    color: #6B7280;
    margin-bottom: 6px;
}

.cssh-bundle-rank .cssh-progress-bar {
    height: 4px;
    margin-top: 0;
}

.cssh-bundle-rank-rate {
    font-size: 18px;
    font-weight: 800;
    color: #10B981;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ═══ Best time banner ══════════════════════════════════════ */
.cssh-best-time-banner {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 1px solid #F59E0B;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #78350F;
    line-height: 1.5;
    animation: csshFadeInUp 0.5s ease-out;
}

.cssh-best-time-banner strong {
    color: #92400E;
}

/* ═══ Loading overlay ═══════════════════════════════════════ */
.cssh-loading-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 14px;
    z-index: 10;
}

.cssh-loading-overlay::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #E5E7EB;
    border-top-color: #1B4332;
    border-radius: 50%;
    animation: csshSpin 0.7s linear infinite;
    z-index: 11;
}
