/* 基础变量 */
:root {
    --primary-color: #232f3e;
    --secondary-color: #febd69;
    --accent-color: #146eb4;
    --success-color: #067d62;
    --warning-color: #b12704;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    --bg-color: #f5f5f5;
    --card-bg: #fff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, var(--primary-color), #37475a);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.header-info {
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 主内容区 */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* 控制面板 */
.control-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.control-row, .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.filter-row {
    margin-bottom: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.control-group, .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.control-group label, .filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
}

.control-group input, .control-group select, .filter-group input, .filter-group select {
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    min-width: 180px;
}

.control-group input:focus, .control-group select:focus, .filter-group input:focus, .filter-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(20, 110, 180, 0.1);
}

.filter-group input[type="number"] {
    min-width: 80px;
}

/* 按钮样式 */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: #0d5a96;
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #ccc;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 统计卡片 */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
}

.price-icon { background: linear-gradient(135deg, #667eea, #764ba2); }
.rating-icon { background: linear-gradient(135deg, #f093fb, #f5576c); }
.review-icon { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.sales-icon { background: linear-gradient(135deg, #43e97b, #38f9d7); }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* 图表区域 */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.chart-container canvas {
    max-height: 250px;
}

/* 表格区域 */
.table-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.table-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--bg-color);
}

th {
    padding: 1rem 0.8rem;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

th:hover {
    background: #e8e8e8;
}

th[data-sort]::after {
    content: ' ⇅';
    opacity: 0.3;
}

td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:hover {
    background: #f8f9fa;
}

/* 表格特殊列 */
.product-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.product-image:hover {
    transform: scale(1.5);
}

.product-title {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.product-title:hover {
    color: var(--accent-color);
}

.price {
    font-weight: 600;
    color: var(--warning-color);
}

.rating {
    color: var(--secondary-color);
    font-weight: 600;
}

.tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 0.1rem;
}

.tag-amazon-choice {
    background: #232f3e;
    color: white;
}

.tag-best-seller {
    background: #ff9900;
    color: white;
}

.tag-promotion {
    background: #cc0c39;
    color: white;
}

.tag-prime {
    background: #146eb4;
    color: white;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

#page-info {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    z-index: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

#modal-body {
    padding: 2rem;
}

.product-detail {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
}

.product-detail-image {
    width: 100%;
    border-radius: 8px;
}

.product-detail-info h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.detail-row {
    display: flex;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-label {
    width: 100px;
    font-weight: 500;
    color: var(--text-light);
}

.detail-value {
    flex: 1;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .control-row, .filter-row {
        flex-direction: column;
    }

    .control-group, .filter-group {
        width: 100%;
    }

    .control-group input, .control-group select, .filter-group input, .filter-group select {
        width: 100%;
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .product-detail {
        grid-template-columns: 1fr;
    }

    .product-detail-image {
        max-width: 200px;
        margin: 0 auto;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card, .chart-container, .table-section {
    animation: fadeIn 0.3s ease-out;
}
