/**
 * 网络测速网站样式表
 * 半圆形表盘设计
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: #2d2d2d; /* 暗灰色背景 */
    min-height: 100vh;
    padding: 40px 20px;
    color: #e0e0e0; /* 浅色文字 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #3a3a3a; /* 稍亮的暗灰色容器 */
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* 顶部控制按钮 */
.header-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

.btn {
    padding: 12px 32px;
    border: 2px solid #1890ff;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #ffffff;
    color: #1890ff;
}

.btn:hover:not(:disabled) {
    background: #1890ff;
    color: #ffffff;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    border-color: #1890ff;
    color: #1890ff;
}

.btn-secondary {
    border-color: #52c41a;
    color: #52c41a;
}

.btn-secondary:hover:not(:disabled) {
    background: #52c41a;
    color: #ffffff;
}

/* IP地址显示 */
.ip-display {
    text-align: center;
    margin-bottom: 40px;
    font-size: 16px;
    color: #e0e0e0;
}

.ip-label {
    margin-right: 8px;
    color: #b0b0b0;
}

.ip-value {
    font-weight: 600;
    color: #4a9eff;
}

/* 指标网格 */
.metrics-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

/* 表盘行（两个表盘在同一行） */
.gauges-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 指标卡片 */
.metric-card {
    background: #2d2d2d; /* 暗灰色卡片 */
    border: 1px solid #4a4a4a; /* 暗色边框 */
    border-radius: 12px;
    padding: 20px 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.metric-card:not(.speed-card) {
    min-height: 120px;
}

.metric-label {
    font-size: 14px; /* 减少30%: 16px * 0.7 = 11.2px ≈ 14px (保持可读性) */
    color: #b0b0b0; /* 浅灰色标签 */
    margin-bottom: 10px; /* 减少30%: 15px * 0.7 = 10.5px ≈ 10px */
    font-weight: 500;
}

/* 延迟显示（在表盘下方） */
.latency-display {
    margin-top: 10px;
    text-align: center;
}

.latency-label {
    font-size: 14px;
    color: #b0b0b0; /* 浅灰色标签 */
    margin-bottom: 5px;
    font-weight: 500;
}

.latency-value {
    font-size: 24px; /* 减少30%: 28px * 0.7 = 19.6px ≈ 24px (保持可读性) */
    font-weight: 700;
    color: #8b4513;
    margin-bottom: 3px;
    line-height: 1.2;
}

.latency-unit {
    font-size: 12px;
    color: #999;
    margin-top: 3px;
}

/* 速度卡片（带表盘） */
.speed-card {
    position: relative;
    padding: 15px; /* 减少30%: 20px * 0.7 = 14px ≈ 15px */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.speed-gauge {
    position: relative;
    width: 100%;
    height: 98px; /* 减少30%: 140px * 0.7 = 98px */
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    max-width: 154px; /* 减少30%: 220px * 0.7 = 154px */
    max-height: 98px; /* 减少30%: 140px * 0.7 = 98px */
}

/* 表盘弧线 */
.gauge-background {
    opacity: 0.3;
}

.gauge-arc {
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: 100px 100px;
    will-change: stroke-dashoffset;
}

.download-arc {
    stroke: #764ba2;
}

.upload-arc {
    stroke: #38ef7d;
}

/* 指针 */
.pointer-group {
    transform-origin: 100px 100px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.pointer {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    stroke: #333;
    stroke-width: 3;
}

.pointer-center {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    fill: #333;
}

/* 指针跳动动画 */
@keyframes pointerBounce {
    0%, 100% {
        transform: rotate(var(--pointer-angle, -90deg)) scale(1) translateY(0);
    }
    25% {
        transform: rotate(var(--pointer-angle, -90deg)) scale(1.05) translateY(-2px);
    }
    50% {
        transform: rotate(var(--pointer-angle, -90deg)) scale(1.1) translateY(-3px);
    }
    75% {
        transform: rotate(var(--pointer-angle, -90deg)) scale(1.05) translateY(-2px);
    }
}

.pointer-group.animating {
    animation: pointerBounce 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* 速度数值显示 */
.speed-value-container {
    position: absolute;
    bottom: 10px; /* 减少30%: 15px * 0.7 = 10.5px ≈ 10px */
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
}

.speed-value-large {
    font-size: 22px; /* 减少30%: 32px * 0.7 = 22.4px ≈ 22px */
    font-weight: 700;
    color: #e0e0e0; /* 浅色文字 */
    line-height: 1;
    margin-bottom: 2px; /* 减少30%: 3px * 0.7 = 2.1px ≈ 2px */
}

.speed-unit {
    font-size: 8px; /* 减少30%: 12px * 0.7 = 8.4px ≈ 8px */
    color: #999;
    font-weight: 500;
}

/* 状态消息 */
.status-message {
    text-align: center;
    margin-top: 30px;
    padding: 15px;
    font-size: 14px;
    color: #b0b0b0;
    min-height: 20px;
}

.status-message.testing {
    color: #4a9eff;
    font-weight: 500;
}

.status-message.error {
    color: #ff6b6b;
}

.status-message.success {
    color: #51cf66;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .gauges-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .header-controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 200px;
    }

    .speed-value-large {
        font-size: 20px;
    }

    .latency-value {
        font-size: 20px;
    }
    
    .speed-gauge {
        height: 85px;
    }
    
    .gauge-svg {
        max-width: 135px;
        max-height: 85px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 20px 10px;
    }

    .speed-value-large {
        font-size: 32px;
    }

    .metric-value {
        font-size: 24px;
    }

    .gauge-svg {
        max-width: 250px;
        max-height: 150px;
    }
}

/* 测试中的加载动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.metric-card.testing {
    animation: pulse 2s ease-in-out infinite;
}

/* 历史记录区域 */
.history-section {
    margin-top: 40px;
    padding: 25px;
    background: #2d2d2d;
    border-radius: 15px;
    border: 1px solid #4a4a4a;
}

.history-section h3 {
    color: #e0e0e0;
    margin-bottom: 20px;
    font-size: 1.3em;
    text-align: center;
}

.history-container {
    background: #3a3a3a;
    border-radius: 10px;
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table thead {
    background: #2d2d2d;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #e0e0e0;
    border-bottom: 2px solid #4a4a4a;
}

.history-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #4a4a4a;
    color: #e0e0e0;
}

.history-table tbody tr:hover {
    background: #2d2d2d;
}

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

.history-loading,
.history-empty,
.history-error {
    text-align: center;
    padding: 30px;
    color: #b0b0b0;
    font-size: 14px;
}

/* 表盘数值更新动画 */
@keyframes numberUpdate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.speed-value-large.updating,
.metric-value.updating {
    animation: numberUpdate 0.3s ease;
}
