/* AI 选股页面样式 —— 全部 token 来自 style.css :root */

/* 主布局 */
.main-content {
    display: flex;
    gap: 16px;
    padding: 24px 32px;
    max-width: 1280px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
}

.left-panel,
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 卡片容器（输入/代码/进度/结果/历史 统一外观） */
.input-section,
.code-section,
.progress-section,
.results-section,
.history-section {
    background: var(--pp-surface);
    border-radius: var(--pp-radius-card);
    padding: 20px 24px;
    box-shadow: var(--pp-shadow-sm);
    border: 1px solid var(--pp-border);
}

/* 使用说明 UI */
.usage-tip {
    margin-bottom: 16px;
}

.usage-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: var(--pp-surface-soft);
    color: var(--pp-text);
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-input);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    font-weight: 600;
    font-size: 13px;
}

.usage-toggle:hover {
    background: var(--pp-primary-soft);
    border-color: var(--pp-primary);
    color: var(--pp-primary);
}

.usage-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--pp-primary-ring);
    border-color: var(--pp-primary);
}

.usage-toggle .chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.usage-toggle[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.usage-content {
    margin-top: 10px;
    padding: 14px;
    background: var(--pp-surface);
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-input);
}

.usage-steps {
    counter-reset: step;
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
    color: var(--pp-text);
    font-size: 14px;
}

.usage-steps li {
    position: relative;
    padding: 10px 12px 10px 44px;
    background: var(--pp-surface-soft);
    border: 1px solid var(--pp-border-light);
    border-radius: var(--pp-radius-input);
}

.usage-steps li::before {
    content: counter(step);
    counter-increment: step;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--pp-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.usage-shortcuts {
    margin-top: 10px;
    font-size: 12px;
    color: var(--pp-text-tertiary);
}

.usage-shortcuts kbd {
    background: var(--pp-surface-soft);
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-chip);
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    color: var(--pp-text);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 650;
    color: var(--pp-text);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pp-border-light);
}

.section-title i {
    color: var(--pp-primary);
}

/* 查询输入框 */
.query-input-container {
    position: relative;
    margin-bottom: 16px;
}

.query-input {
    width: 100%;
    min-height: 180px;
    padding: 12px 14px;
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-input);
    font-size: 14px;
    line-height: 1.6;
    color: var(--pp-text);
    background: var(--pp-surface);
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.query-input:focus {
    outline: none;
    border-color: var(--pp-primary);
    box-shadow: 0 0 0 3px var(--pp-primary-ring);
}

.query-input::placeholder {
    color: var(--pp-text-tertiary);
    line-height: 1.6;
}

/* 输入控制 */
.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.char-count {
    font-size: 12px;
    color: var(--pp-text-tertiary);
}

.char-count span {
    font-weight: 600;
    color: var(--pp-primary);
}

/* 模板区域 */
.template-section {
    margin-bottom: 16px;
}

.template-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--pp-text-secondary);
    margin-bottom: 10px;
}

.template-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.template-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-input);
    background: var(--pp-surface);
    color: var(--pp-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.template-btn:hover {
    border-color: var(--pp-primary);
    background: var(--pp-primary-soft);
    color: var(--pp-primary);
}

.template-btn i {
    font-size: 13px;
}

/* 生成按钮 */
.generate-section {
    text-align: center;
}

.btn-large {
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
}

/* 代码预览区域 */
.code-container {
    background: #0F172A;
    border-radius: var(--pp-radius-input);
    padding: 16px;
    margin-bottom: 16px;
    overflow-x: auto;
    border: 1px solid var(--pp-border);
}

.code-container:focus-within {
    box-shadow: 0 0 0 3px var(--pp-primary-ring);
    border-color: var(--pp-primary);
}

.code-editor {
    display: block;
    width: 100%;
    height: 50vh;
    min-height: 320px;
    background: transparent;
    color: #E2E8F0;
    border: none;
    outline: none;
    padding: 0;
    caret-color: var(--pp-primary-soft);
    resize: vertical;
    tab-size: 2;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.code-preview {
    color: #E2E8F0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* 进度区域 */
.progress-container {
    margin-bottom: 14px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--pp-surface-soft);
    border: 1px solid var(--pp-border-light);
    border-radius: var(--pp-radius-chip);
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pp-primary), var(--pp-down));
    border-radius: var(--pp-radius-chip);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--pp-text-secondary);
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--pp-surface-soft);
    border: 1px solid var(--pp-border-light);
    border-radius: var(--pp-radius-input);
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--pp-text-tertiary);
    margin-bottom: 4px;
}

.stat-item span:last-child {
    font-size: 16px;
    font-weight: 700;
    color: var(--pp-text);
    font-variant-numeric: tabular-nums;
}

/* 结果区域 */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.results-actions {
    display: flex;
    gap: 8px;
}

.results-container {
    max-height: 600px;
    overflow-y: auto;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 16px;
    padding: 10px 12px;
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-input);
    background: var(--pp-surface);
    transition: all 0.15s ease;
}

.result-item:hover {
    border-color: var(--pp-primary);
    background: var(--pp-surface-soft);
}

.stock-info {
    flex: 1;
}

.result-item .stock-code {
    font-weight: 600;
    color: var(--pp-text);
    font-size: 14px;
    line-height: 1.2;
    font-family: 'Courier New', monospace;
}

.result-item .stock-name {
    color: var(--pp-text-secondary);
    font-size: 12px;
    margin-top: 2px;
    line-height: 1.2;
}

.stock-details {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 180px;
}

.stock-price {
    font-weight: 700;
    color: var(--pp-up);
    font-size: 14px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stock-reason {
    color: var(--pp-text-secondary);
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.2;
}

/* 历史记录 */
.history-container {
    max-height: 300px;
    overflow-y: auto;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 12px 14px;
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-input);
    background: var(--pp-surface);
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-item:hover {
    border-color: var(--pp-primary);
    background: var(--pp-surface-soft);
}

.history-query {
    font-size: 13px;
    color: var(--pp-text);
    margin-bottom: 6px;
    line-height: 1.4;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--pp-text-tertiary);
}

.history-status {
    padding: 2px 8px;
    border-radius: var(--pp-radius-chip);
    font-size: 11px;
    font-weight: 600;
}

.history-status.completed {
    background: var(--pp-tag-a-bg);
    color: var(--pp-tag-a);
}

.history-status.processing {
    background: var(--pp-tag-c-bg);
    color: var(--pp-tag-c);
}

.history-status.failed {
    background: var(--pp-up-bg);
    color: var(--pp-up);
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: var(--pp-surface);
    padding: 28px;
    border-radius: var(--pp-radius-card);
    text-align: center;
    box-shadow: var(--pp-shadow-lg);
}

.loading-content .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--pp-border);
    border-top: 3px solid var(--pp-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--pp-surface);
    border: 1px solid var(--pp-border);
    border-radius: var(--pp-radius-card);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--pp-shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--pp-border-light);
}

.modal-header h3 {
    margin: 0;
    color: var(--pp-text);
    font-size: 15px;
    font-weight: 650;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--pp-text-tertiary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--pp-text);
}

.modal-body {
    padding: 20px 24px;
    color: var(--pp-text);
    line-height: 1.6;
    font-size: 14px;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--pp-border-light);
    text-align: right;
}

/* 响应式 */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        padding: 16px;
    }

    .left-panel,
    .right-panel {
        flex: none;
    }

    .template-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .progress-stats {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .code-actions {
        flex-direction: column;
    }
}

/* 通用 btn 基类 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--pp-radius-input);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

/* 大字体覆盖 */
html.font-large .section-title { font-size: 18px; }
html.font-large .query-input { font-size: 16px; line-height: 1.7; }
html.font-large .char-count { font-size: 14px; }
html.font-large .template-title { font-size: 15px; }
html.font-large .template-btn { font-size: 14px; }
html.font-large .btn { font-size: 15px; }
html.font-large .btn-large { font-size: 17px; }
html.font-large .code-preview { font-size: 15px; }
html.font-large .progress-text { font-size: 15px; }
html.font-large .stat-label { font-size: 14px; }
html.font-large .stat-item span:last-child { font-size: 18px; }
html.font-large .result-item { padding: 10px 12px; }
html.font-large .result-item .stock-code { font-size: 16px; }
html.font-large .result-item .stock-name { font-size: 14px; }
html.font-large .stock-price { font-size: 16px; }
html.font-large .stock-reason { font-size: 14px; }
html.font-large .history-item { font-size: 15px; }
html.font-large .history-meta { font-size: 14px; }
html.font-large .history-status { font-size: 12px; }
html.font-large .modal-body { font-size: 15px; }

.btn-primary {
    background: var(--pp-primary);
    color: #fff;
    border-color: var(--pp-primary);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--pp-primary-hover);
    border-color: var(--pp-primary-hover);
}

.btn-secondary {
    background: var(--pp-surface);
    color: var(--pp-text-secondary);
    border-color: var(--pp-border);
}

.btn-secondary:hover {
    border-color: var(--pp-text-tertiary);
    color: var(--pp-text);
}

.btn-success {
    background: var(--pp-tag-a);
    color: #fff;
    border-color: var(--pp-tag-a);
    font-weight: 600;
}

.btn-success:hover {
    background: #166534;
    border-color: #166534;
}

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

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

::-webkit-scrollbar-track {
    background: var(--pp-surface-soft);
    border-radius: 4px;
}

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

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