/* ========================================
   A股智选 - 股票筛选器样式
   ======================================== */

/* CSS 变量 */
:root {
    /* 主色调 */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    
    /* 涨跌色 */
    --rise: #ef4444;
    --fall: #22c55e;
    
    /* 背景色 */
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #252542;
    --bg-input: #16162a;
    
    /* 文字色 */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* 边框 */
    --border-color: #2d2d4a;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    
    /* 渐变 */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-card: linear-gradient(145deg, #1a1a2e 0%, #16162a 100%);
    --gradient-funnel: linear-gradient(90deg, #6366f1 0%, #ec4899 100%);
    
    /* 阴影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    /* 过渡 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* 重置样式 */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 背景装饰 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(139, 92, 246, 0.1), transparent);
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   布局
   ======================================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 头部 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    transition: var(--transition-fast);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.nav-link.active {
    color: var(--text-primary);
    background: var(--gradient-primary);
}

.market-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fall);
    animation: pulse 2s infinite;
}

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

/* 主内容区 */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    flex: 1;
}

/* ========================================
   控制面板
   ======================================== */
.control-panel {
    background: var(--gradient-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 80px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-reset {
    padding: 0.375rem 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition-fast);
}

.btn-reset:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.rules-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

/* 规则卡片 */
.rule-card {
    background: var(--bg-input);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    border: 1px solid transparent;
    transition: var(--transition-normal);
}

.rule-card:hover {
    border-color: var(--border-color);
}

.rule-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rule-title {
    font-weight: 500;
    font-size: 0.9rem;
}

.rule-body {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.rule-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Toggle 开关 */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-card);
    border-radius: 22px;
    transition: var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: white;
}

/* 输入框 */
.range-inputs, .single-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.range-separator {
    color: var(--text-muted);
}

.range-inputs input, .single-input input {
    width: 60px;
    padding: 0.4rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: center;
}

.range-inputs input:focus, .single-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* 按钮 */
.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

/* ========================================
   结果区域
   ======================================== */
.results-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* 筛选漏斗 */
.funnel-section {
    background: var(--gradient-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
}

.funnel-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.funnel-chart {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.funnel-item {
    display: flex;
    justify-content: center;
}

.funnel-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1rem;
    background: var(--gradient-funnel);
    border-radius: var(--border-radius-sm);
    min-width: 150px;
    transition: var(--transition-normal);
    opacity: 0.4;
}

.funnel-item.active .funnel-bar {
    opacity: 1;
    box-shadow: var(--shadow-glow);
}

.funnel-item.final .funnel-bar {
    background: linear-gradient(90deg, #f59e0b 0%, #ef4444 100%);
}

.funnel-label {
    font-size: 0.8rem;
    font-weight: 500;
}

.funnel-count {
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
}

/* 股票列表 */
.stock-list-section {
    background: var(--gradient-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    flex: 1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.list-actions {
    display: flex;
    gap: 0.75rem;
}

.search-input {
    padding: 0.5rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 200px;
}

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

/* 表格 */
.stock-table-container {
    overflow-x: auto;
}

.stock-table {
    width: 100%;
    border-collapse: collapse;
}

.stock-table th,
.stock-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.stock-table th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-table th.sortable {
    cursor: pointer;
    transition: var(--transition-fast);
}

.stock-table th.sortable:hover {
    color: var(--primary-light);
}

.stock-table tbody tr {
    transition: var(--transition-fast);
}

.stock-table tbody tr:hover:not(.empty-state) {
    background: var(--bg-card-hover);
}

.stock-table .stock-code {
    font-family: monospace;
    color: var(--text-secondary);
}

.stock-table .stock-name {
    font-weight: 500;
}

.stock-table .rise {
    color: var(--rise);
}

.stock-table .fall {
    color: var(--fall);
}

.stock-table .action-btns {
    display: flex;
    gap: 0.5rem;
}

.stock-table .btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.stock-table .btn-icon:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* 空状态 */
.empty-state td {
    padding: 3rem;
    text-align: center;
}

.empty-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.empty-message p {
    color: var(--text-secondary);
}

/* ========================================
   加载遮罩
   ======================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

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

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

.loading-text {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ========================================
   模态框
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 70px);
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
    }
    
    .rules-container {
        max-height: none;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .rules-container {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .list-actions {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .stock-table th,
    .stock-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
