/* ========================================
   优化的CSS样式 - 增强用户体验
   ======================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 导航栏 - 增强响应式 */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand h1 {
    font-size: 24px;
    font-weight: 600;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s;
    font-weight: 500;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.nav-links a.active {
    background: rgba(255,255,255,0.3);
}

/* 主内容 */
.main-content {
    padding: 30px 0;
}

.section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s;
}

.section:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.section h2 {
    font-size: 22px;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* 更新时间 - 增强样式 */
.update-time {
    text-align: right;
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.update-time .time {
    font-weight: 500;
}

.btn-refresh {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-refresh:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.btn-refresh.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn-refresh .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 状态提示 - 新增 */
.status-banner {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    animation: slideIn 0.3s ease-out;
}

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

.status-banner.info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.status-banner.success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.status-banner.warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.status-banner.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.status-banner .close-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.status-banner .close-btn:hover {
    opacity: 1;
}

/* ETF卡片 - 增强效果 */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.etf-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.etf-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.etf-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.etf-card h3 {
    font-size: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.etf-price {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.etf-change {
    font-size: 18px;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.etf-change.up {
    color: #4ade80;
}

.etf-change.down {
    color: #f87171;
}

.etf-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 14px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* IV网格 - 增强样式 */
.iv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.iv-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid #667eea;
    transition: all 0.3s;
}

.iv-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.iv-card h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

.iv-value {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.iv-current {
    font-size: 32px;
    font-weight: 700;
    color: #667eea;
}

.iv-percentile {
    font-size: 28px;
    font-weight: 600;
}

.iv-status {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.iv-status.good {
    background: #d1fae5;
    color: #065f46;
}

.iv-status.bad {
    background: #fee2e2;
    color: #991b1b;
}

/* 策略状态 */
.strategy-status {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.status-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s;
}

.status-item:hover {
    background: #e5e7eb;
}

.status-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.status-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

/* 加载状态 - 增强 */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    position: relative;
}

.loading-spinner {
    display: inline-block;
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 16px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    height: 180px;
    margin-bottom: 20px;
}

/* 空状态 - 增强 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    animation: fadeIn 0.5s ease-out;
}

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

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.6;
}

.empty-state-text {
    font-size: 18px;
    margin-bottom: 12px;
}

.empty-state-hint {
    font-size: 14px;
    color: #bbb;
}

/* 错误提示 - 增强 */
.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border-left: 4px solid #ef4444;
    animation: shake 0.5s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-message h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

.error-message p {
    font-size: 14px;
    margin-bottom: 15px;
}

.error-message .retry-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.error-message .retry-btn:hover {
    background: #dc2626;
}

/* 机会列表 */
.opportunities-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    color: #666;
}

.opportunity-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid #10b981;
    transition: all 0.3s;
}

.opportunity-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.opportunity-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.opportunity-contract {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.opportunity-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    background: #d1fae5;
    color: #065f46;
}

.opportunity-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.opportunity-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.opportunity-label {
    font-size: 12px;
    color: #666;
}

.opportunity-value {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* 持仓表格 */
.positions-container {
    overflow-x: auto;
}

.positions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.positions-table th,
.positions-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.positions-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
}

.positions-table tr:hover {
    background: #f9fafb;
}

/* 图表容器 */
.chart-container {
    margin-top: 30px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chart-container h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
}

.filter-bar label {
    font-weight: 500;
    color: #333;
}

.filter-bar select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-bar select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 汇总卡片 */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s;
}

.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.summary-card .label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.summary-card .value {
    font-size: 28px;
    font-weight: 700;
}

/* 工具提示 - 新增 */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: all 0.3s;
    font-size: 12px;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Toast通知 - 新增 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
}

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

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.toast.info {
    border-left: 4px solid #3b82f6;
}

/* 响应式设计 - 增强 */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .cards, .iv-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .nav-links a {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .main-content {
        padding: 20px 0;
    }
    
    .section {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .section h2 {
        font-size: 20px;
    }
    
    .update-time {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .cards, .iv-grid, .strategy-status {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .etf-price {
        font-size: 28px;
    }
    
    .iv-current {
        font-size: 28px;
    }
    
    .status-value {
        font-size: 20px;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .nav-brand h1 {
        font-size: 20px;
    }
    
    .nav-links a {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .section {
        padding: 15px;
    }
    
    .etf-card, .iv-card {
        padding: 15px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .toast {
        min-width: 250px;
        font-size: 14px;
    }
}

/* 打印样式 */
@media print {
    .navbar, .btn-refresh, .status-banner {
        display: none;
    }
    
    .section {
        break-inside: avoid;
        box-shadow: none;
    }
    
    .etf-card, .iv-card {
        color: black;
        background: white;
        border: 1px solid #ddd;
    }
}

/* 深色模式支持 (预留) */
@media (prefers-color-scheme: dark) {
    /* 可以在这里添加深色模式样式 */
}
