/* CSS for Hit-the-Board Strategy Tool */
/* Will be populated later */

:root {
    --primary-color: #FF6F00; /* 充满活力的橘色 */
    --primary-color-dark: #E66000;
    --background-color: #f4f6f9;
    --card-background-color: #ffffff;
    --text-color: #333333;
    --subtle-text-color: #666666;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1, h2 {
    color: var(--text-color);
    text-align: center;
}

/* --- 头部 --- */
.main-header {
    text-align: center;
    margin-bottom: 40px;
}

.main-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.main-header p {
    font-size: 1.1rem;
    color: var(--subtle-text-color);
}

/* --- 模块分区 --- */
.module-section {
    background-color: var(--card-background-color);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    margin-bottom: 30px;
}

.module-section h2 {
    text-align: left;
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
}

/* --- 模块一：市场情绪温度计 --- */
.sentiment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.sentiment-item {
    background-color: var(--background-color);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.sentiment-title {
    font-size: 0.9rem;
    color: var(--subtle-text-color);
    margin-bottom: 10px;
    display: block;
}

.sentiment-value {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* --- 模块二：候选池 --- */
.pool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 20px;
}

.pool-header h2 {
    margin: 0;
    flex-shrink: 0; /* Prevent title from shrinking */
}

.controls-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    flex-grow: 1;
    justify-content: flex-end;
}

.search-container, .add-stock-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1 1 280px; /* Grow, Shrink, Basis for responsive behavior */
    min-width: 250px; /* Prevent from becoming too small */
}

#stock-search-input, #add-stock-input {
    padding: 9px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    width: 100%; /* Changed from fixed width to be responsive */
    box-sizing: border-box;
}

.autocomplete-container {
    position: relative;
    flex-grow: 1; /* Let the container for input grow */
}

.autocomplete-results {
    position: absolute;
    top: calc(100% + 4px); /* A small gap from the input */
    left: 0;
    right: 0;
    background: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 1001; /* Make sure it's above other elements */
    box-shadow: 0 5px 15px var(--shadow-color);
    display: none; /* Controlled by JS */
}

.autocomplete-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.autocomplete-item:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

#stock-search-button, #add-stock-button {
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.stock-card {
    background-color: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stock-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px var(--shadow-color);
}

.stock-card-main {
    flex-grow: 1;
}

.stock-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.stock-name {
    font-size: 1.4rem;
    font-weight: bold;
}

.stock-code {
    font-size: 0.9rem;
    color: var(--subtle-text-color);
}

.stock-info {
    font-size: 0.9rem;
    color: var(--subtle-text-color);
}

.stock-score {
    display: none; /* Hide the old corner score */
}

/* New Probability Meter */
.stock-probability {
    flex-shrink: 0;
    width: 85px;
    height: 85px;
    border-radius: 50%;
    background-color: var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    margin-left: 15px;
    text-align: center;
    border: 3px solid;
}

.stock-probability .probability-label {
    font-size: 0.75rem;
    font-weight: bold;
    opacity: 0.9;
}

.stock-probability .probability-value {
    font-size: 1.8rem;
    font-weight: bold;
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
}

/* Dynamic colors for probability */
.prob-high {
    background-color: #ff5722; /* Deep Orange */
    border-color: #bf360c;
}

.prob-medium {
    background-color: #ff9800; /* Orange */
    border-color: #e68900;
}

.prob-low {
    background-color: #78909c; /* Blue Grey */
    border-color: #546e7a;
}

/* --- Fire Icon Styles (Restored) --- */
.fire-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    margin-left: 0.2em;
    color: #ff8c00;
    animation: hot-fire-flicker 2s ease-in-out infinite;
    filter: drop-shadow(0 0 2px #ff8c00);
}
@keyframes hot-fire-flicker {
    0% { transform: scale(1, 1) skew(0deg, 0deg); opacity: 0.9; }
    25% { transform: scale(1.05, 0.95) skew(-3deg, 2deg); opacity: 1; }
    50% { transform: scale(0.95, 1.05) skew(3deg, -2deg); opacity: 0.85; filter: drop-shadow(0 0 5px #ff4500); }
    75% { transform: scale(1.02, 0.98) skew(-2deg, 3deg); opacity: 1; }
    100% { transform: scale(1, 1) skew(0deg, 0deg); opacity: 0.9; }
}
.prob-high .fire-icon {
    color: #ff4500;
    filter: drop-shadow(0 0 5px #ff4500);
}
.prob-medium .fire-icon {
    color: #ff8c00;
    filter: drop-shadow(0 0 3px #ff8c00);
}
.prob-low .fire-icon { 
    color: #f9a602; 
    animation: none; 
    opacity: 0.7; 
    filter: none;
}

/* --- 弹窗 Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
}

#modal-header h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-top: 0;
    margin-bottom: 20px;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

#modal-body h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-top: 0;
}

#modal-body h3 {
    font-size: 1.4rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
    margin-top: 25px;
}

#modal-body ul {
    list-style-type: none;
    padding-left: 10px;
}

#modal-body li {
    margin-bottom: 8px;
}

#backtest-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#backtest-table th, #backtest-table td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: center;
}

#backtest-table th {
    background-color: var(--background-color);
}

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-header h1 {
        font-size: 2rem;
    }

    .pool-header {
        flex-direction: column;
        align-items: stretch; /* Make children full-width */
        gap: 1rem;
    }

    .controls-container {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
        gap: 1rem; /* Add gap for vertical stacking */
    }

    .search-container,
    .add-stock-container {
        flex-basis: auto; /* Reset flex-basis for stacking */
        width: 100%;
    }

    #job-control {
        width: 100%;
        margin-left: 0;
        justify-content: space-between; /* Space out items like time and button */
    }

    .autocomplete-container {
        width: 100%;
    }

    .v2-grid {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .v2-chart-container, .v2-metrics-container {
        width: 100%;
        max-width: 360px;
        margin: 0 auto;
    }

    .v2-chart-container svg {
        width: 100%;
        height: auto;
    }

    .plan-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 15px 10px;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    .sentiment-grid {
        grid-template-columns: 1fr;
    }
    
    .stock-grid {
        grid-template-columns: 1fr;
    }

    #job-control {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    #job-control > p {
        text-align: center;
    }

    #start-job-btn {
        width: 100%;
    }

    .modal-content {
        padding: 15px 10px;
    }
}

/* --- Tab 样式 --- */
.tab-container {
    overflow: hidden;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-link {
    background-color: inherit;
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: 0.3s;
    font-size: 1rem;
    font-weight: bold;
    color: var(--subtle-text-color);
}

.tab-link:hover {
    background-color: #ddd;
}

.tab-link.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

.tab-content {
    display: none;
    padding: 6px 12px;
}

.tab-content h3 {
    font-size: 1.4rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
    margin-top: 10px;
}

.tab-content ul {
    list-style-type: none;
    padding-left: 10px;
}

.tab-content li {
    margin-bottom: 8px;
}

/* --- Report Specific Styles --- */
.report-section {
    background-color: #f7f9fc;
    border: 1px solid #e1e8f2;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.report-section h3 {
    color: var(--primary-color);
    margin-top: 0;
    font-size: 1.5rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.report-section h4 {
    color: #333;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.metric-card {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e1e8f2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.metric-label {
    display: block;
    font-size: 0.9rem;
    color: #667;
    margin-bottom: 8px;
}

.metric-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
}

.metric-value.highlight {
    color: var(--primary-color);
    font-weight: 700;
}

.factor-list {
    list-style: none;
    padding-left: 0;
}

.factor-list li {
    background: #fff;
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    border-left: 4px solid var(--primary-color-dark);
}

.factor-name {
    font-weight: bold;
    color: #333;
    margin-right: 8px;
}

.factor-score {
    display: inline-block;
    background-color: var(--primary-color);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
}

.plan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.plan-card {
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}
.plan-card.plan-positive {
    background-color: #ffe8d9;
    border: 1px solid var(--primary-color);
    color: var(--primary-color-dark);
}
.plan-card.plan-neutral {
    background-color: #eef2f5;
    border: 1px solid #d1d9e0;
    color: #556;
}
.plan-label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 5px;
}
.plan-value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
}

.plan-note {
    background: #e9f5ff;
    border: 1px solid #bce0ff;
    color: #004085;
    padding: 15px;
    border-radius: 6px;
    font-size: 0.95rem;
}

.genesis-report .metric-card {
    background: linear-gradient(135deg, #424242, #212121);
    color: #fff;
    border: none;
}
.genesis-report .metric-label {
    color: #ccc;
}
.genesis-report .metric-value {
    color: #fff;
}
.genesis-report .metric-value.highlight{
    color: #ffd180;
}

.decision-suggestion {
    margin-top: 20px;
    padding: 15px;
    background-color: #263238;
    color: #eceff1;
    border-radius: 8px;
    border-left: 5px solid var(--primary-color);
}
.decision-suggestion h4 {
    color: #fff;
    margin-top: 0;
}

/* Info State for 'No Data' messages */
.info-state {
    background-color: #f0f4f8;
    color: #5a687f;
    border: 1px solid #d6dde7;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.info-state h3 {
    margin-top: 0;
    color: var(--text-color);
}

.info-state p {
    color: var(--subtle-text-color);
    font-size: 1rem;
}

/* --- On-demand Backtest Styles --- */

.backtest-placeholder {
    padding: 40px 20px;
    text-align: center;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin: 20px 0;
}

.backtest-placeholder p {
    font-size: 1.1rem;
    color: var(--subtle-text-color);
    max-width: 600px;
    margin: 0 auto 20px auto;
}

.cta-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.cta-button:hover {
    background-color: var(--primary-color-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.cta-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.state-placeholder {
    padding: 40px 20px;
    text-align: center;
    font-size: 1.1rem;
}

.loading-state {
    color: var(--primary-color);
}

.error-state {
    color: #c0392b; /* Red */
    font-weight: bold;
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
    margin-top: 20px;
    margin-bottom: 20px;
}

#backtest-chart {
    /* The height is now controlled by the container */
}

.table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 15px;
}

#backtest-table .win {
    color: #c0392b; /* Red for win/up in China market */
    font-weight: bold;
}

#backtest-table .loss {
    color: #27ae60; /* Green for loss/down */
}

.factor-score.highlight {
    background-color: transparent;
    color: var(--primary-color-dark);
    padding: 0;
    font-size: 1.0rem;
    font-weight: 700;
    border: none;
    box-shadow: none;
    vertical-align: middle; /* Aligns better with text */
    border-left: 5px solid var(--primary-color);
}

/* --- DNA Attack Analysis Report Styles --- */
.dna-report h3 {
    color: #1e88e5; /* A techy blue */
    border-color: #1e88e5;
}

.dna-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.dna-card {
    background: linear-gradient(145deg, #eef2f5, #ffffff);
    border: 1px solid #d1d9e0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.06);
    text-align: center;
}

.dna-card h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #37474f; /* Dark blue grey */
}

.dna-value {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: #1e88e5;
}

.dna-value.highlight {
    color: #f57c00; /* A strong orange for the highest rank */
}

.dna-desc {
    font-size: 0.9rem;
    color: var(--subtle-text-color);
    line-height: 1.5;
}

.premium-note {
    font-size: 0.8rem;
    color: var(--subtle-text-color);
    background-color: var(--background-color);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

/* --- 更新时间文本样式 --- */
.update-time-text {
    font-size: 0.9rem;
    color: var(--subtle-text-color);
    margin: 0;
    white-space: nowrap;
}

.download-btn {
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    float: right;
}

.download-btn:hover {
    background-color: #0056b3;
}

/* --- 新增：任务控制样式 (V2) --- */
#job-control {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap; /* Allow job control items to wrap if needed */
}

#start-job-btn .icon-update {
    transition: transform 0.5s ease;
}

#start-job-btn.loading .icon-update {
    animation: spin 1.2s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#job-status-message {
    font-size: 0.9rem;
    color: var(--subtle-text-color);
    margin: 0;
}

#progress-bar {
    width: 0%;
    background-color: var(--primary-color); /* Use theme color */
    color: white;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
    transition: width 0.4s ease;
}

/* --- General Button Styles --- */
.btn {
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.2s ease;
    padding: 10px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
}
.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

/* Primary (Orange) Button */
#stock-search-button,
#add-stock-button {
    background-color: var(--primary-color);
    color: white;
}
#stock-search-button:hover:not(:disabled),
#add-stock-button:hover:not(:disabled) {
    background-color: var(--primary-color-dark);
}

/* Secondary (Gray) Update Button */
#start-job-btn {
    background-color: #6c757d;
    color: white;
    padding: 8px 12px;
    font-size: 0.9rem;
}
#start-job-btn:hover:not(:disabled) {
    background-color: #5a6268;
}

/* --- V2 Core Diagnosis Report Styles --- */
.v2-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 25px;
    align-items: center;
    margin-bottom: 20px;
}

.v2-chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 320px;
}

.v2-chart-container svg {
    width: 100%;
    height: auto;
    max-width: 300px;
}

.v2-metrics-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.v2-metrics-container .metric-card {
    width: 100%;
    margin: 0; /* Override default margins if any */
    box-sizing: border-box;
}

.factor-list.v2 li {
    font-size: 0.9rem;
    line-height: 1.5;
    background-color: #fff;
}

/* --- Snapshot Section Styles --- */
.snapshot-section {
    background-color: #fffaf0; /* A light orange/yellow background */
    border-color: #ffeac4;
    border-left: 5px solid var(--primary-color);
}
.snapshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.snapshot-card {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #f0e6d5;
}
.snapshot-card.wide {
    grid-column: span 2;
}
.snapshot-label {
    display: block;
    font-size: 0.9rem;
    color: var(--subtle-text-color);
    margin-bottom: 8px;
}
.snapshot-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}
.snapshot-value.small {
    font-size: 1rem;
    font-weight: normal;
    word-break: break-all;
    min-height: 44px; /* Align with other cards */
    display: flex;
    align-items: center;
    justify-content: center;
}
.snapshot-value.price-positive, .snapshot-value.percent-positive {
    color: #c0392b; /* Red for up */
}
.snapshot-value.price-negative, .snapshot-value.percent-negative {
    color: #27ae60; /* Green for down */
}
.snapshot-value.price-neutral, .snapshot-value.percent-neutral {
    color: #333;
}

/* --- Notification Styles (Restored) --- */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    background-color: #28a745;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateX(120%);
    transition: transform 0.4s ease-in-out;
    z-index: 2000;
}
.notification.error {
    background-color: #dc3545;
}
.notification.show {
    transform: translateX(0);
}
.stock-card.manual-add { 
    border-left: 4px solid #007bff; 
}