/**
 * 数据分析页面样式
 * 包含：KPI卡片、趋势图、饼图、漏斗、柱状图、排名列表、留存矩阵、A/B测试
 */

/* ========== 容器 ========== */

.analytics-container {
    padding: var(--spacing-lg, 24px);
    max-width: 100%;
}

/* ========== 工具栏 ========== */

.analytics-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.analytics-toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.analytics-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analytics-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
    margin: 0;
}

.analytics-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary, #1a1a2e);
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.analytics-select:focus {
    border-color: var(--primary-color);
}

/* ========== KPI 卡片网格 ========== */

.analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.analytics-kpi-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

.analytics-kpi-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.analytics-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.analytics-kpi-card--pv { border-left-color: var(--kpi-pv); }
.analytics-kpi-card--uv { border-left-color: var(--kpi-uv); }
.analytics-kpi-card--new { border-left-color: var(--kpi-new); }
.analytics-kpi-card--reads { border-left-color: var(--kpi-reads); }
.analytics-kpi-card--click { border-left-color: var(--kpi-click); }
.analytics-kpi-card--impression { border-left-color: var(--kpi-impression); }
.analytics-kpi-card--ctr { border-left-color: var(--kpi-ctr); }

.analytics-kpi-icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

.analytics-kpi-body {
    flex: 1;
    min-width: 0;
}

.analytics-kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
    line-height: 1.2;
}

.analytics-kpi-label {
    font-size: 12px;
    color: var(--text-secondary, #666);
    margin-top: 4px;
}

/* ========== 卡片通用 ========== */

.analytics-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
    overflow: hidden;
}

.analytics-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 0;
}

.analytics-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
    margin: 0;
}

.analytics-card-body {
    padding: 16px 20px 20px;
}

/* ========== 网格行 ========== */

.analytics-row {
    display: grid;
    gap: 20px;
    margin-bottom: 0;
}

.analytics-row--2-1 {
    grid-template-columns: 2fr 1fr;
}

.analytics-row--1-1 {
    grid-template-columns: 1fr 1fr;
}

/* ========== 区段标题 ========== */

.analytics-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 32px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.analytics-section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
    margin: 0;
}

.analytics-section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== SVG 图表 ========== */

.analytics-svg {
    width: 100%;
    height: auto;
    display: block;
}

.analytics-axis-label {
    font-size: 10px;
    fill: #999;
}

.analytics-grid-line {
    stroke: #f0f0f0;
    stroke-width: 1;
    stroke-dasharray: 4 2;
}

.analytics-trend-chart {
    min-height: 200px;
}

.analytics-chart-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary, #666);
}

.analytics-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.analytics-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* ========== 饼图 ========== */

.analytics-pie-wrapper {
    display: flex;
    align-items: center;
    gap: 24px;
}

.analytics-pie {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.analytics-pie-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.analytics-pie-total {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
    line-height: 1.2;
}

.analytics-pie-label {
    font-size: 10px;
    color: var(--text-secondary, #999);
}

.analytics-pie-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.analytics-pie-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.analytics-pie-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.analytics-pie-legend-name {
    flex: 1;
    color: var(--text-primary, #1a1a2e);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analytics-pie-legend-value {
    color: var(--text-secondary, #666);
    flex-shrink: 0;
}

/* ========== 漏斗图 ========== */

.analytics-funnel-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.analytics-funnel-step {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.analytics-funnel-bar-wrapper {
    height: 28px;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 4px;
    overflow: hidden;
}

.analytics-funnel-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.analytics-funnel-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.analytics-funnel-name {
    color: var(--text-primary, #1a1a2e);
    font-weight: 500;
    min-width: 80px;
}

.analytics-funnel-count {
    color: var(--text-primary, #1a1a2e);
    font-weight: 600;
}

.analytics-funnel-rate {
    color: var(--danger-color);
    font-size: 12px;
}

/* ========== 柱状图 (横向) ========== */

.analytics-bar-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.analytics-bar-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.analytics-bar-label {
    width: 100px;
    font-size: 12px;
    color: var(--text-primary, #1a1a2e);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.analytics-bar-track {
    flex: 1;
    height: 18px;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 4px;
    overflow: hidden;
}

.analytics-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.analytics-bar-value {
    width: 60px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
    text-align: right;
    flex-shrink: 0;
}

/* ========== 排名列表 ========== */

.analytics-rank-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.analytics-rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-light, #f5f5f5);
    transition: background 0.15s;
}

.analytics-rank-item:last-child {
    border-bottom: none;
}

.analytics-rank-item:hover {
    background: var(--bg-secondary, #f9f9ff);
}

.analytics-rank-num {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.analytics-rank-num--top {
    background: var(--primary-color);
    color: #fff;
}

.analytics-rank-num--normal {
    background: var(--bg-secondary, #f0f0f0);
    color: var(--text-secondary, #666);
}

.analytics-rank-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary, #1a1a2e);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analytics-rank-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
    flex-shrink: 0;
}

/* ========== 数据表格 ========== */

.analytics-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.analytics-data-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    border-bottom: 2px solid var(--border-color, #e0e0e0);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.analytics-data-table tbody td {
    padding: 10px 12px;
    color: var(--text-primary, #1a1a2e);
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.analytics-data-table tbody tr:hover {
    background: var(--bg-secondary, #f9f9ff);
}

.analytics-data-table tbody tr:last-child td {
    border-bottom: none;
}

.analytics-td-title {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== 留存分析矩阵 ========== */

.analytics-retention-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.analytics-retention-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 500px;
}

.analytics-retention-table thead th {
    padding: 8px 10px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    border-bottom: 2px solid var(--border-color, #e0e0e0);
    text-align: center;
    white-space: nowrap;
}

.analytics-retention-table thead th:first-child,
.analytics-retention-table thead th:nth-child(2) {
    text-align: left;
}

.analytics-retention-table tbody td {
    padding: 6px 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
    white-space: nowrap;
}

.analytics-retention-date {
    text-align: left !important;
    font-weight: 500;
    color: var(--text-primary, #1a1a2e);
}

.analytics-retention-count {
    text-align: left !important;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}

.analytics-retention-cell {
    border-radius: 4px;
    font-weight: 500;
    color: var(--primary-color);
    min-width: 60px;
}

/* ========== A/B 测试概览 ========== */

.analytics-ab-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.analytics-ab-item {
    padding: 14px;
    border: 1px solid var(--border-light, #f0f0f0);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.analytics-ab-item:hover {
    border-color: var(--border-color, #e0e0e0);
}

.analytics-ab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.analytics-ab-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}

.analytics-ab-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.analytics-ab-status--active {
    background: rgba(82, 196, 26, 0.12);
    color: var(--success-color);
}

.analytics-ab-status--completed {
    background: rgba(16, 30, 139, 0.08);
    color: var(--primary-color);
}

.analytics-ab-status--paused {
    background: rgba(169, 116, 42, 0.12);
    color: var(--warning-color);
}

.analytics-ab-variants {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-ab-variant {
    display: flex;
    align-items: center;
    gap: 10px;
}

.analytics-ab-variant-name {
    width: 80px;
    font-size: 12px;
    color: var(--text-secondary, #666);
    flex-shrink: 0;
}

.analytics-ab-variant-bar {
    flex: 1;
    height: 14px;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 4px;
    overflow: hidden;
}

.analytics-ab-variant-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.analytics-ab-variant-rate {
    width: 50px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
    text-align: right;
    flex-shrink: 0;
}

/* ========== 空状态 & 加载 ========== */

.analytics-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: var(--text-secondary, #999);
    font-size: 13px;
}

.analytics-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: var(--text-secondary, #999);
    font-size: 13px;
}

/* ========== 响应式 ========== */

@media (max-width: 1200px) {
    .analytics-row--2-1 {
        grid-template-columns: 1fr;
    }

    .analytics-row--1-1 {
        grid-template-columns: 1fr;
    }

    .analytics-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-kpi-grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .analytics-pie-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .analytics-container {
        padding: var(--spacing-md, 16px);
    }

    .analytics-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .analytics-toolbar-right {
        width: 100%;
        justify-content: flex-end;
    }

    .analytics-kpi-grid {
        grid-template-columns: 1fr;
    }

    .analytics-kpi-grid--3 {
        grid-template-columns: 1fr;
    }

    .analytics-bar-label {
        width: 70px;
    }

    .analytics-bar-value {
        width: 48px;
    }

    .analytics-td-title {
        max-width: 180px;
    }
}
