/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 主题色彩定义 */
:root {
    --primary-color: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --success-color: #10b981;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: rgba(30, 41, 59, 0.8);
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
    --gradient-secondary: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
}

/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 容器样式 */
.dashboard-container {
    height: 100vh;
    max-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1e1b4b 100%);
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 主要内容区域 */
.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow: auto;
}

/* 头部样式 */
.dashboard-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    padding: 12px 18px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    position: relative;
}

/* 移动设备优化：移除高性能开销属性 */
.mobile-device .dashboard-header {
    backdrop-filter: none;
    box-shadow: var(--shadow-md);
}

.title-container {
    text-align: center;
    width: 100%;
    flex-shrink: 0;
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    margin: 0;
    display: block;
    text-align: center;
    width: 100%;
}

.title-hint {
    font-size: 0.8rem;
    color: #94a3b8;
    margin: 4px 0 0 0;
    font-weight: 400;
    letter-spacing: 0;
    display: block;
    text-align: center;
    width: 100%;
    position: relative;
    z-index: 1;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 30px;
    position: absolute;
    right: 20px;
}

.current-time {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--danger-color);
    animation: pulse 2s infinite;
}

.status-indicator.online {
    background-color: var(--success-color);
}

/* 主要内容区域 */
.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 指标网格样式 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    min-height: 100px;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

/* 为每个指标卡片设置不同的颜色 */
#metric1.metric-card::before {
    background: var(--gradient-primary); /* 蓝色 - 销售收入 */
}

#metric1.metric-card:hover {
    border-color: var(--primary-light);
}

#metric2.metric-card::before {
    background: var(--gradient-secondary); /* 绿色 - 订单数量 */
}

#metric2.metric-card:hover {
    border-color: #34d399; /* 绿色渐变的亮色 */
}

#metric3.metric-card::before {
    background: var(--gradient-warning); /* 黄色 - 转化率 */
}

#metric3.metric-card:hover {
    border-color: #fbbf24; /* 黄色渐变的亮色 */
}

#metric4.metric-card::before {
    background: var(--gradient-danger); /* 红色 - 平均客单价 */
}

#metric4.metric-card:hover {
    border-color: #f87171; /* 红色渐变的亮色 */
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.metric-card:hover::before {
    transform: scaleX(1);
}

.metric-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 6px;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

/* 为每个指标卡片的数值添加不同颜色 */
#metric1 .metric-value {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#metric2 .metric-value {
    background: var(--gradient-secondary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#metric3 .metric-value {
    background: var(--gradient-warning);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#metric4 .metric-value {
    background: var(--gradient-danger);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.metric-unit {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-change {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 16px;
    display: inline-block;
}

/* 确保数值和单位在同一行 */
.metric-value-container {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 6px;
}

.metric-value {
    margin-bottom: 0 !important;
}

.metric-unit {
    margin-left: 4px;
}

.metric-change.positive {
    color: var(--success-color);
    background-color: rgba(16, 185, 129, 0.1);
}

.metric-change.negative {
    color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
}

/* 图表行样式 */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 8px;
    min-height: 0;
    margin-bottom: 8px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    z-index: 1;
    width: 100%;
}

.chart-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

.chart-card.large {
    grid-column: span 1;
    min-height: 0;
    max-height: none;
}

.chart-card.medium {
    grid-column: span 1;
    min-height: 0;
    max-height: none;
}

/* 图表容器自适应高度 - 根据卡片类型调整不同比例 */
.chart-card .chart-container {
    flex: 1;
    min-height: 0;
}

/* 第二排大图表 - 调整高度比例 */
.chart-card.large .chart-container {
    aspect-ratio: 16 / 5;
}

/* 第三排中等图表 - 调整高度比例 */
.chart-card.medium .chart-container {
    aspect-ratio: 16 / 8;
}

/* 小屏幕下调整图表比例 */
@media (max-width: 1200px) {
    .chart-card.large .chart-container {
        aspect-ratio: 4 / 3;
    }
    
    .chart-card.medium .chart-container {
        aspect-ratio: 3 / 2;
    }
}

@media (max-width: 768px) {
    .chart-card.large .chart-container,
    .chart-card.medium .chart-container {
        aspect-ratio: 2 / 1;
    }
}

@media (max-width: 480px) {
    .chart-card.large .chart-container,
    .chart-card.medium .chart-container {
        aspect-ratio: 3 / 2;
    }
}

/* 指标网格样式 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.chart-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.chart-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.control-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.control-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}
/* 图表容器样式 */
.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    max-width: 100%;
}

/* 确保canvas元素不会突破容器边界 */
.chart-container canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    height: 100% !important;
}

/* 地图容器样式 */
.map-container {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
}

/* 移除固定高度设置，使用aspect-ratio控制宽高比 */

/* 事件列表样式 */
.event-list {
    flex: 1;
    min-height: 0;
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 5px;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease-out;
}

.event-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(5px);
}

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

.event-type {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
}

.event-type.info {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary-light);
}

.event-type.success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.event-type.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.event-type.error {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.event-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.event-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

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

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

/* 动画效果 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 延迟动画 */
.metric-card:nth-child(1) {
    animation: fadeIn 0.5s ease-out 0.1s both;
}

.metric-card:nth-child(2) {
    animation: fadeIn 0.5s ease-out 0.2s both;
}

.metric-card:nth-child(3) {
    animation: fadeIn 0.5s ease-out 0.3s both;
}

.metric-card:nth-child(4) {
    animation: fadeIn 0.5s ease-out 0.4s both;
}

.chart-card {
    animation: fadeIn 0.5s ease-out 0.5s both;
}

/* 响应式设计 - 低于1920px (1080p) 开始调整字体大小 */
@media (max-width: 1600px) {
    .dashboard-title {
        font-size: 1.75rem;
    }
    
    .current-time {
        font-size: 1.1rem;
    }
    
    .metric-title {
        font-size: 0.78rem;
    }
    
    .metric-value {
        font-size: 1.6rem;
    }
    
    .chart-header h3 {
        font-size: 1.1rem;
    }
}

@media (max-width: 1440px) {
    .dashboard-title {
        font-size: 1.6rem;
    }
    
    .current-time {
        font-size: 1.05rem;
    }
    
    .metric-title {
        font-size: 0.76rem;
    }
    
    .metric-value {
        font-size: 1.5rem;
    }
    
    .metric-unit {
        font-size: 0.9rem;
    }
    
    .chart-header h3 {
        font-size: 1.05rem;
    }
    
    .control-btn {
        font-size: 0.8rem;
        padding: 5px 14px;
    }
}

@media (max-width: 1200px) {
    .charts-row {
        grid-template-columns: 1fr;
        margin-bottom: 8px;
    }
    
    .chart-card.large,
    .chart-card.medium {
        grid-column: span 1;
        width: 100%;
        box-sizing: border-box;
    }
    
    .dashboard-title {
        font-size: 1.5rem;
    }
    
    .current-time {
        font-size: 1rem;
    }
    
    .metric-title {
        font-size: 0.75rem;
    }
    
    .metric-value {
        font-size: 1.4rem;
    }
    
    .metric-change {
        font-size: 0.7rem;
        padding: 2px 8px;
    }
    
    .chart-header h3 {
        font-size: 1rem;
    }
    
    .chart-info {
        font-size: 0.75rem;
    }
    
    .event-type,
    .event-time,
    .event-description {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
        height: auto;
        max-height: none;
    }
    
    .dashboard-main {
        overflow: visible;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-info {
        flex-direction: column;
        gap: 10px;
    }
    
    /* 隐藏桌面导航，显示移动端菜单按钮 */
    .desktop-nav {
        display: none !important;
    }
    
    .mobile-menu-btn {
        display: block !important;
    }
    
    .dashboard-header {
        padding-bottom: 15px;
    }
    
    .dashboard-title {
        font-size: 1.5rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-title {
        font-size: 0.72rem;
    }
    
    .metric-value {
        font-size: 2rem;
    }
    
    .charts-row {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 8px;
    }
    
    .chart-card {
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .metric-card {
        padding: 20px;
    }
    
    .metric-title {
        font-size: 0.7rem;
    }
    
    .metric-value {
        font-size: 1.75rem;
    }
    
    .chart-card {
        padding: 15px;
        margin-bottom: 8px;
    }
}

/* 加载状态 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* 图表样式定制 */
.chartjs-tooltip {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-lg) !important;
    color: var(--text-primary) !important;
}

.chartjs-legend {
    color: var(--text-secondary) !important;
}

/* 数据更新动画 */
.data-update {
    animation: dataPulse 0.5s ease-out;
}

@keyframes dataPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}