/**
 * 汇率换算工具 - 样式表
 * 设计风格：极简东方美学 (Zen Minimalism)
 * 朱红强调色 + 大量留白 + 精确数据展示
 */

/* ========== 基础重置 ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #B91C1C;
    --primary-hover: #991B1B;
    --primary-light: #FEF2F2;
    --text: #1a1a1a;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg: #f8f8f6;
    --card-bg: #ffffff;
    --border: #e5e5e0;
    --border-light: #f0f0ec;
    --link: #2563EB;
    --link-hover: #1D4ED8;
    --success: #059669;
    --font-serif: 'Noto Serif SC', 'Songti SC', serif;
    --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --radius: 8px;
    --container: 1200px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ========== 容器 ========== */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 640px) {
    .container { padding: 0 24px; }
}

@media (min-width: 1024px) {
    .container { padding: 0 32px; }
}

/* ========== 顶部导航 ========== */
.top-nav {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(185,28,28,0.3);
}

.top-nav .container {
    display: flex;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 0;
}

.top-nav .container::-webkit-scrollbar {
    display: none;
}

.nav-brand {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 15px;
    padding: 12px 16px 12px 0;
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.2);
    margin-right: 4px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
}

.nav-link {
    display: inline-block;
    padding: 12px 14px;
    font-size: 13px;
    white-space: nowrap;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.15);
}

/* ========== 页面标题区 ========== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 20px 0 16px;
}

.page-title {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

@media (min-width: 768px) {
    .page-title { font-size: 22px; }
}

.rate-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary);
    color: #fff;
    padding: 5px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.swap-link {
    font-size: 13px;
    color: var(--link);
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    background: var(--card-bg);
}

.swap-link:hover {
    background: var(--link);
    color: #fff;
    border-color: var(--link);
}

/* ========== 卡片通用 ========== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-serif);
    font-size: 15px;
    font-weight: 600;
}

/* ========== 转换器 ========== */
.converter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

@media (min-width: 768px) {
    .converter-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.converter-input, .converter-result {
    padding: 24px;
}

@media (min-width: 768px) {
    .converter-input {
        border-right: 1px solid var(--border);
    }
}

@media (max-width: 767px) {
    .converter-input {
        border-bottom: 1px solid var(--border);
    }
}

.section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.section-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.section-dot.green { background: var(--success); }
.section-dot.blue { background: var(--link); }

/* 金额输入 */
.amount-wrap {
    position: relative;
    margin-bottom: 16px;
}

.amount-input {
    width: 100%;
    padding: 12px 60px 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 18px;
    font-family: var(--font-mono);
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
    background: var(--card-bg);
    color: var(--text);
}

.amount-input:focus {
    border-color: var(--primary);
}

.amount-unit {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-secondary);
}

/* 货币选择行 */
.currency-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.currency-row label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 24px;
    text-align: right;
}

.currency-select {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    appearance: auto;
}

.currency-select:focus {
    border-color: var(--primary);
}

/* 交换按钮 */
.swap-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.3s;
    color: var(--primary);
    font-size: 16px;
    margin: 0 auto;
}

.swap-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: rotate(180deg);
}

/* 结果区 */
.result-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    word-break: break-all;
}

@media (min-width: 768px) {
    .result-amount { font-size: 26px; }
}

.result-rate-box {
    display: inline-flex;
    align-items: center;
    background: var(--text);
    color: #fff;
    padding: 10px 28px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
}

.result-time {
    font-size: 12px;
    color: var(--text-light);
}

/* ========== 两列布局 ========== */
.two-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 1024px) {
    .two-col {
        grid-template-columns: 1.2fr 1fr;
    }
}

/* ========== 走势图 ========== */
.chart-container {
    padding: 16px 20px;
    min-height: 280px;
}

.chart-canvas {
    width: 100%;
    height: 250px;
}

/* ========== 快速换算表 ========== */
.quick-table {
    width: 100%;
    border-collapse: collapse;
}

.quick-table thead th {
    background: var(--bg);
    padding: 10px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}

.quick-table tbody tr {
    transition: background 0.15s;
    cursor: pointer;
}

.quick-table tbody tr:hover {
    background: rgba(37,99,235,0.04);
}

.quick-table tbody td {
    padding: 8px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}

.quick-table .from-val {
    font-weight: 600;
    color: var(--link);
}

.quick-table .to-val {
    font-family: var(--font-mono);
    font-weight: 500;
}

/* ========== 多货币汇率表 ========== */
.rate-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-icon {
    color: var(--text-light);
    font-size: 14px;
}

.search-input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    width: 200px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg);
}

.search-input:focus {
    border-color: var(--primary);
}

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

.page-size-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: var(--card-bg);
    outline: none;
}

/* 数据表格 */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.data-table thead th:hover {
    background: var(--primary-hover);
}

.data-table thead th .sort-icon {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.5;
}

.data-table thead th.sorted .sort-icon {
    opacity: 1;
}

.data-table thead th:last-child {
    cursor: default;
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.015);
}

.data-table tbody tr:hover {
    background: rgba(37,99,235,0.04);
}

.data-table tbody td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.data-table .mono {
    font-family: var(--font-mono);
}

.data-table .pair-btn {
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid #93C5FD;
    border-radius: 4px;
    background: transparent;
    color: var(--link);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.data-table .pair-btn:hover {
    background: var(--link);
    color: #fff;
    border-color: var(--link);
}

/* 分页信息 */
.table-info {
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-light);
    border-top: 1px solid var(--border);
}

/* 分页按钮 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 12px 0;
}

.page-btn {
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.page-btn:hover:not(:disabled):not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

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

.page-dots {
    padding: 0 8px;
    color: var(--text-light);
}

/* ========== 底部链接区 ========== */
.footer-links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
}

@media (min-width: 640px) {
    .footer-links-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
    .footer-links-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .footer-links-grid { grid-template-columns: repeat(5, 1fr); }
}

.footer-link {
    font-size: 13px;
    color: var(--link);
    padding: 6px 10px;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: none;
    background: none;
    text-align: left;
    font-family: inherit;
}

.footer-link:hover {
    background: rgba(37,99,235,0.06);
}

/* ========== 页脚 ========== */
.site-footer {
    text-align: center;
    padding: 24px 0;
    font-size: 12px;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    margin-top: 24px;
}

.site-footer a {
    color: var(--link);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* ========== 加载状态 ========== */
.loading-screen {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

/* ========== 错误提示 ========== */
.error-bar {
    background: #FEF3C7;
    border: 1px solid #FDE68A;
    color: #92400E;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ========== 间距工具 ========== */
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.p-20 { padding: 20px; }

/* ========== 响应式微调 ========== */
@media (max-width: 480px) {
    .page-title { font-size: 17px; }
    .result-amount { font-size: 20px; }
    .converter-input, .converter-result { padding: 16px; }
    .search-input { width: 140px; }
    .rate-controls { padding: 10px 12px; }
    .data-table tbody td, .data-table thead th { padding: 8px 10px; }
}
