/**
 * JY 股價指數圖表 - 樣式表
 * Version: 1.0.0
 */

/* ========================================
   共通スタイル
   ======================================== */

.jy-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: jy-spin 1s linear infinite;
    margin: 0 auto;
}

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

/* ========================================
   即時價格容器
   ======================================== */

.jy-index-price-container {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.jy-index-price-loading,
.jy-index-price-error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.jy-index-price-content {
    display: block;
}

/* 主要價格顯示 */
.jy-price-main {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.jy-current-price {
    font-size: 36px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.jy-price-change {
    font-size: 18px;
    font-weight: 500;
}

.jy-price-change.positive {
    color: #e74c3c;
}

.jy-price-change.negative {
    color: #27ae60;
}

.jy-change-icon {
    margin-right: 5px;
}

/* HLOC詳細 */
.jy-price-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.jy-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
}

.jy-price-label {
    font-weight: 500;
    color: #666;
    font-size: 14px;
}

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

/* 市場狀態 */
.jy-market-status {
    margin-top: 15px;
    text-align: center;
}

.jy-status-badge {
    display: inline-block;
    padding: 6px 16px;
    color: white;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* 市場狀態顏色 */
.jy-status-badge.status-open {
    background: #27ae60; /* 綠色 - 開盤中 */
}

.jy-status-badge.status-closed {
    background: #3498db; /* 藍色 - 收盤 */
}

.jy-status-badge.status-holiday {
    background: #95a5a6; /* 灰色 - 休市 */
}

.jy-status-badge.status-lunch {
    background: #f39c12; /* 橙色 - 午休 */
}

/* ========================================
   圖表容器
   ======================================== */

.jy-index-chart-container {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 時間軸按鈕 */
.jy-chart-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.jy-timeframe-btn {
    flex: 1;
    min-width: 80px;
    padding: 10px 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    transition: all 0.3s ease;
}

.jy-timeframe-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.jy-timeframe-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

.jy-timeframe-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
}

/* 圖表包裝器 */
.jy-chart-wrapper {
    position: relative;
    min-height: 400px;
}

.jy-chart-loading,
.jy-chart-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
}

.jy-chart-market-closed {
    position: absolute;
    top: 20px;
    right: 20px;
    text-align: center;
    background: rgba(149, 165, 166, 0.9);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 10;
}

.jy-market-closed-badge {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
}

.jy-chart-market-closed p {
    margin: 0;
    font-size: 14px;
}

/* Canvas */
#jy-chart-canvas {
    max-width: 100%;
    height: auto !important;
}

/* ========================================
   レスポンシブデザイン
   ======================================== */

@media (max-width: 768px) {
    .jy-current-price {
        font-size: 28px;
    }
    
    .jy-price-change {
        font-size: 16px;
    }
    
    .jy-price-details {
        grid-template-columns: 1fr;
    }
    
    .jy-timeframe-btn {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }
    
    .jy-chart-wrapper {
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .jy-index-price-container,
    .jy-index-chart-container {
        padding: 15px;
    }
    
    .jy-current-price {
        font-size: 24px;
    }
    
    .jy-price-change {
        font-size: 14px;
    }
    
    .jy-price-row {
        padding: 6px 10px;
    }
    
    .jy-price-label {
        font-size: 12px;
    }
    
    .jy-price-value {
        font-size: 14px;
    }
    
    .jy-timeframe-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ========================================
   印刷スタイル
   ======================================== */

@media print {
    .jy-chart-controls {
        display: none;
    }
    
    .jy-index-price-container,
    .jy-index-chart-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
