/* 全局样式 */
:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --info-color: #2196f3;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #95a5a6;
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --border-color: #e0e6ed;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --sidebar-width: 260px;
    --topbar-height: 80px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.logo i {
    font-size: 24px;
    color: var(--primary-color);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-primary);
    color: var(--primary-color);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, transparent 100%);
    color: var(--primary-color);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 主内容区 */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 24px;
}

/* 顶部栏 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.date-range:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.btn-icon:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-icon .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* 指标卡片 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.metric-icon.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.metric-icon.success {
    background: linear-gradient(135deg, #4caf50, #45a049);
}

.metric-icon.warning {
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

.metric-icon.danger {
    background: linear-gradient(135deg, #f44336, #e53935);
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

.metric-trend.up {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.metric-trend.down {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
}

.metric-body {
    margin-bottom: 16px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.metric-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.metric-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.metric-detail i {
    color: var(--primary-color);
}

/* 图表区域 */
.charts-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.chart-row:last-child {
    grid-template-columns: 1fr 1fr;
}

.chart-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.chart-card.large {
    grid-column: span 1;
}

.chart-card.medium {
    grid-column: span 1;
}

.chart-card.small {
    grid-column: span 1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.chart-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-header i {
    color: var(--primary-color);
}

.chart-actions {
    display: flex;
    gap: 8px;
}

.btn-text {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    font-size: 13px;
}

.btn-text:hover {
    background: var(--bg-primary);
    color: var(--primary-color);
}

.btn-text.active {
    background: var(--primary-color);
    color: white;
}

.select-small {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
}

.chart-body {
    position: relative;
    height: 300px;
}

.chart-legend {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* 漏斗图 */
.funnel-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 0;
}

.funnel-item {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    padding: 16px 24px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    transition: var(--transition);
    margin: 0 auto;
}

.funnel-item:hover {
    transform: translateX(8px);
    box-shadow: var(--shadow-md);
}

.funnel-label {
    font-size: 14px;
    font-weight: 500;
}

.funnel-value {
    font-size: 18px;
    font-weight: 700;
}

.funnel-rate {
    font-size: 14px;
    opacity: 0.9;
}

/* 活动区域 */
.activity-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.activity-card,
.quick-stats-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.activity-header,
.quick-stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.activity-header h3,
.quick-stats-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: 8px;
    transition: var(--transition);
}

.activity-item:hover {
    background: var(--bg-primary);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.activity-icon.success {
    background: var(--success-color);
}

.activity-icon.primary {
    background: var(--primary-color);
}

.activity-icon.warning {
    background: var(--warning-color);
}

.activity-icon.info {
    background: var(--info-color);
}

.activity-icon.danger {
    background: var(--danger-color);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.activity-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.activity-time {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
}

/* 快速统计 */
.quick-stats-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.quick-stat-item {
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.quick-stat-item:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05), transparent);
    transform: translateX(4px);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-change {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

.stat-change.positive {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.stat-change.negative {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
}

/* 响应式设计 */
@media (max-width: 1600px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .activity-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* 按钮 */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* 概览卡片（共享） */
.overview-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: var(--transition);
}

.overview-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.overview-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.overview-icon.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.overview-icon.success {
    background: linear-gradient(135deg, #4caf50, #45a049);
}

.overview-icon.warning {
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

.overview-icon.danger {
    background: linear-gradient(135deg, #f44336, #e53935);
}

.overview-content {
    flex: 1;
}

.overview-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.overview-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.overview-trend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
}

.overview-trend.up {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.overview-trend.down {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
}

/* 通知 */
.notification {
    position: fixed;
    top: 24px;
    right: 24px;
    background: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideInRight 0.3s ease-out;
}

.notification-success {
    border-left: 4px solid #4caf50;
}

.notification-error {
    border-left: 4px solid #f44336;
}

.notification-warning {
    border-left: 4px solid #ff9800;
}

.notification-info {
    border-left: 4px solid #2196f3;
}

/* AI 组件样式 */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    color: #667eea;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.ai-badge i {
    font-size: 10px;
}

.ai-insight-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.ai-insight-panel .panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.ai-insight-panel .panel-title .ai-badge {
    font-size: 12px;
    padding: 4px 10px;
}

.ai-insights-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.ai-insight-card {
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 10px;
    border-left: 3px solid var(--primary-color);
    transition: var(--transition);
}

.ai-insight-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.ai-insight-card.anomaly {
    border-left-color: var(--danger-color);
}

.ai-insight-card.trend {
    border-left-color: var(--info-color);
}

.ai-insight-card.recommend {
    border-left-color: var(--warning-color);
}

.ai-insight-card.revenue {
    border-left-color: var(--success-color);
}

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

.ai-insight-card .insight-type {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-insight-card .insight-type i {
    color: var(--primary-color);
}

.confidence {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.ai-insight-card .insight-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.ai-insight-card .insight-action {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 500;
}

.ai-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    border: 3px solid;
}

.ai-score.high {
    color: var(--success-color);
    border-color: var(--success-color);
    background: rgba(76, 175, 80, 0.08);
}

.ai-score.medium {
    color: var(--warning-color);
    border-color: var(--warning-color);
    background: rgba(255, 152, 0, 0.08);
}

.ai-score.low {
    color: var(--danger-color);
    border-color: var(--danger-color);
    background: rgba(244, 67, 54, 0.08);
}

.ai-progress-bar {
    height: 6px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.ai-progress-bar .bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.ai-progress-bar .bar-fill.success {
    background: var(--success-color);
}

.ai-progress-bar .bar-fill.warning {
    background: var(--warning-color);
}

.ai-progress-bar .bar-fill.danger {
    background: var(--danger-color);
}

.ai-progress-bar .bar-fill.primary {
    background: var(--primary-color);
}

.btn-insight {
    padding: 6px 12px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    background: rgba(102, 126, 234, 0.05);
    color: var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-insight:hover {
    background: var(--primary-color);
    color: white;
}

.ai-tip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06), rgba(118, 75, 162, 0.06));
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    border: 1px solid rgba(102, 126, 234, 0.12);
}

.ai-tip .ai-badge {
    flex-shrink: 0;
    margin-top: 1px;
}

.ai-summary {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06), rgba(118, 75, 162, 0.04));
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.12);
    margin-bottom: 20px;
}

.ai-summary .summary-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-summary .summary-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.metric-card,
.chart-card,
.activity-card,
.quick-stats-card {
    animation: fadeIn 0.5s ease-out;
}

@media (max-width: 1400px) {
    .ai-insights-grid {
        grid-template-columns: 1fr;
    }
}
