body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.container {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 500px;
}

h1 {
    text-align: center;
    color: #1877f2;
    margin-bottom: 1.5rem;
}

.input-group {
    margin-bottom: 1rem;
}

.input-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-row > .input-group {
    flex: 1;
    margin-bottom: 0;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1rem;
    background-color: white;
}

button {
    width: 100%;
    padding: 0.75rem;
    background-color: #1877f2;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #166fe5;
}

/* AI分析區域樣式 */
.ai-analysis-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    color: white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.ai-analysis-section h3 {
    color: white;
    margin-bottom: 15px;
    text-align: center;
}

.ai-analysis-section .input-group {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.ai-analyze-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(238, 90, 36, 0.3);
}

.ai-analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 36, 0.4);
}

.ai-results {
    margin-top: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-analysis-content {
    display: grid;
    gap: 20px;
}

.ai-section {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 15px;
}

.ai-section h4 {
    color: white;
    margin-bottom: 10px;
    font-size: 16px;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.analysis-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
}

.analysis-item .label {
    font-weight: bold;
    color: rgba(255,255,255,0.8);
}

.analysis-item .value {
    font-weight: bold;
}

.trend-uptrend { color: #4CAF50; }
.trend-downtrend { color: #f44336; }
.trend-sideways { color: #FF9800; }

.momentum-overbought { color: #f44336; }
.momentum-oversold { color: #4CAF50; }
.momentum-neutral { color: #FF9800; }

.volatility-high { color: #f44336; }
.volatility-medium { color: #FF9800; }
.volatility-low { color: #4CAF50; }

.recommendation-box {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
}

.recommendation-box.favorable_for_short {
    background: linear-gradient(45deg, #4CAF50, #45a049);
}

.recommendation-box.caution_advised {
    background: linear-gradient(45deg, #FF9800, #F57C00);
}

.recommendation-box.neutral_conditions {
    background: linear-gradient(45deg, #9E9E9E, #757575);
}

.parameters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
}

.param-label {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
}

.param-value {
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.apply-params-btn {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    width: 100%;
}

.apply-params-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.risk-assessment {
    display: grid;
    gap: 10px;
}

.risk-score, .risk-level, .risk-factors {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
}

.risk-label {
    color: rgba(255,255,255,0.8);
    font-weight: bold;
}

.risk-value {
    font-weight: bold;
}

.risk-極高風險 { color: #d32f2f; }
.risk-高風險 { color: #f44336; }
.risk-中等風險 { color: #FF9800; }
.risk-低風險 { color: #4CAF50; }
.risk-極低風險 { color: #2e7d32; }

.confidence-meter {
    display: flex;
    align-items: center;
    gap: 15px;
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #f44336, #FF9800, #4CAF50);
    transition: width 0.5s ease;
}

.confidence-text {
    color: white;
    font-weight: bold;
    min-width: 40px;
}

/* 通知樣式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: linear-gradient(45deg, #4CAF50, #45a049);
}

.notification-error {
    background: linear-gradient(45deg, #f44336, #d32f2f);
}

.notification-info {
    background: linear-gradient(45deg, #2196F3, #1976D2);
}

/* AI錯誤提示 */
.ai-error {
    text-align: center;
    padding: 20px;
    background: rgba(244, 67, 54, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.ai-error h4 {
    color: #f44336;
    margin-bottom: 10px;
}

.ai-error p {
    color: rgba(255,255,255,0.8);
    margin: 5px 0;
}

/* 結果區域樣式 */
#results {
    margin-top: 2rem;
    display: none;
}

#results h2 {
    text-align: center;
    margin-bottom: 1rem;
    color: #333;
}

#results h3 {
    color: #1877f2;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
    margin-top: 1.5rem;
}

#short-position h3 { color: #dc3545; } /* 空單用紅色 */
#long-position h3 { color: #28a745; }  /* 多單用綠色 */


#results ul {
    list-style-type: none;
    padding: 0;
}

#results li {
    background-color: #f9f9f9;
    padding: 0.75rem;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

#results li span:first-child {
    font-weight: 600;
}

.take-profit span:last-child {
    color: #28a745;
    font-weight: bold;
}

.stop-loss span:last-child {
    color: #dc3545;
    font-weight: bold;
}

.grid-list-container {
    margin-top: 1.5rem;
}

.grid-list-container h4 {
    color: #333;
    margin-bottom: 0.5rem;
}

.grid-list-container ul {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 0.5rem;
}

.grid-list-container li {
    background-color: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    justify-content: center;
}

.limit-row {
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    display: flex;
    justify-content: space-between;
}

.limit-row > div {
    width: 48.5%;
    background-color: #f9f9f9;
    padding: 0.75rem;
    border: 1px solid #eee;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
}

.limit-row > div span:first-child {
    font-weight: 600;
}

.warning {
    background-color: #fffbe6 !important;
    color: #9f6000;
    font-weight: bold;
    justify-content: center !important;
}

.risk-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.risk-warning h3 {
    color: #856404;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.risk-warning p {
    margin-bottom: 0.5rem;
    color: #856404;
}

.risk-warning ul {
    margin: 0;
    padding-left: 1.5rem;
    color: #856404;
}

.calculation-mode {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.calculation-mode h3 {
    color: #1565c0;
    margin-top: 0;
    margin-bottom: 1rem;
}

.calculation-notes {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.calculation-notes h3 {
    color: #495057;
    margin-top: 0;
    margin-bottom: 1rem;
}

.mode-explanation h4 {
    color: #6c757d;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.mode-explanation ul {
    margin: 0 0 1rem 0;
    padding-left: 1.5rem;
}

.mode-explanation li {
    background: none;
    border: none;
    padding: 0.25rem 0;
    display: list-item;
    justify-content: flex-start;
}

.note-item {
    background-color: transparent;
    border: none;
    padding: 0.5rem 0;
    display: block;
}

.info span:last-child {
    color: #17a2b8;
    font-weight: bold;
}

.parameters-section {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.parameters-section h3 {
    color: #495057;
    margin-top: 0;
    margin-bottom: 1rem;
}