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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* 头部样式 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1 {
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header h1 i {
    color: #3498db;
}

.last-update {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.refresh-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.refresh-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.refresh-btn:active {
    transform: translateY(0);
}

.refresh-btn i {
    transition: transform 0.3s ease;
}

.refresh-btn.loading i {
    animation: spin 1s linear infinite;
}

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

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

/* 价格卡片样式 */
.price-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.price-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.price-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
}

.price-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

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

.commodity-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
}

.commodity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.copper { background: linear-gradient(135deg, #f39c12, #e67e22); }
.aluminum { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }
.iron { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.gold { background: linear-gradient(135deg, #f1c40f, #f39c12); }

.price-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #ecf0f1;
}

.price-row:last-child {
    border-bottom: none;
}

.price-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 500;
}

.price-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
}

.price-change {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.price-change.positive {
    background: #d5f4e6;
    color: #27ae60;
}

.price-change.negative {
    background: #fadbd8;
    color: #e74c3c;
}

.price-change.neutral {
    background: #ebf3fd;
    color: #3498db;
}

/* 对比区域样式 */
.comparison-section,
.chart-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.comparison-section h2,
.chart-section h2 {
    color: #2c3e50;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.comparison-section h2 i,
.chart-section h2 i {
    color: #3498db;
}

.comparison-chart {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 15px;
    color: #7f8c8d;
    overflow-x: auto;
}

/* 对比表格样式 */
.comparison-table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed;
}

.comparison-table th,
.comparison-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #dee2e6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comparison-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    position: sticky;
    top: 0;
    z-index: 10;
    text-align: center;
}

.comparison-table th:nth-child(1) {
    text-align: left;
    width: 20%;
}

.comparison-table th:nth-child(2),
.comparison-table th:nth-child(3) {
    text-align: right;
    width: 25%;
}

.comparison-table th:nth-child(4) {
    text-align: center;
    width: 30%;
}

.comparison-table td {
    color: #495057;
}

.comparison-table .commodity-name {
    font-weight: 600;
    color: #2c3e50;
    text-align: left;
}

.comparison-table .price-cell {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.comparison-table .difference-cell {
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.comparison-table .positive {
    color: #e74c3c;
}

.comparison-table .negative {
    color: #27ae60;
}

/* 图表控制区域 */
.chart-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.chart-controls select {
    padding: 10px 15px;
    border: 2px solid #ecf0f1;
    border-radius: 10px;
    background: white;
    color: #2c3e50;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chart-controls select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.chart-container {
    position: relative;
    height: 400px;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
}

/* 加载状态 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading p {
    font-size: 1.1rem;
    font-weight: 500;
}

/* 错误提示 */
.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

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

/* 语言切换按钮 */
.language-toggle {
    display: flex;
    gap: 5px;
    margin-left: 20px;
}

.lang-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.lang-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* 换算说明 */
.conversion-note {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.conversion-note .price-value.small {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .price-cards {
        grid-template-columns: 1fr;
    }
    
    .chart-controls {
        flex-direction: column;
    }
    
    .chart-controls select {
        width: 100%;
    }
    
    .chart-container {
        height: 300px;
    }
    
    /* 移动端对比表格优化 */
    .comparison-section {
        padding: 15px;
    }
    
    .comparison-table {
        font-size: 0.8rem;
        min-width: 500px;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 8px 6px;
    }
    
    .comparison-table th:nth-child(1) {
        width: 25%;
    }
    
    .comparison-table th:nth-child(2),
    .comparison-table th:nth-child(3) {
        width: 30%;
    }
    
    .comparison-table th:nth-child(4) {
        width: 15%;
    }
    
    .comparison-table .price-cell {
        font-size: 0.75rem;
    }
    
    .comparison-table .difference-cell {
        font-size: 0.7rem;
    }

    .language-toggle {
        margin-left: 10px;
    }
    
    .lang-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .price-card {
        padding: 20px;
    }
    
    .commodity-name {
        font-size: 1.1rem;
    }
    
    .price-value {
        font-size: 1rem;
    }
    
    .chart-container {
        height: 250px;
        padding: 15px;
    }
    
    /* 小屏幕对比表格进一步优化 */
    .comparison-section {
        padding: 10px;
    }
    
    .comparison-table {
        font-size: 0.75rem;
        min-width: 450px;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 6px 4px;
    }
    
    .comparison-table th:nth-child(1) {
        width: 30%;
    }
    
    .comparison-table th:nth-child(2),
    .comparison-table th:nth-child(3) {
        width: 25%;
    }
    
    .comparison-table th:nth-child(4) {
        width: 20%;
    }
    
    .comparison-table .commodity-name {
        min-width: 60px;
    }
    
    .comparison-table .price-cell {
        font-size: 0.7rem;
    }
    
    .comparison-table .difference-cell {
        font-size: 0.65rem;
    }
}

/* 动画效果 */
.price-card {
    animation: fadeInUp 0.6s ease forwards;
}

.price-card:nth-child(1) { animation-delay: 0.1s; }
.price-card:nth-child(2) { animation-delay: 0.2s; }
.price-card:nth-child(3) { animation-delay: 0.3s; }
.price-card:nth-child(4) { animation-delay: 0.4s; }

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