/**
 * Sector Rotation Panel Styles
 * v20.0: 類股輪動分析面板樣式
 * 使用 brand-system tokens，支援亮/暗色主題
 */

/* ==================== 容器 ==================== */

.sr-container {
    margin: 8px 0;
    border-radius: 12px;
    overflow: hidden;
}

/* ==================== 進度區塊 ==================== */

.sr-progress-section {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
}

.sr-progress-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.sr-icon {
    font-size: 20px;
}

.sr-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
    flex: 1;
}

.sr-progress-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
}

.sr-progress-bar-track {
    height: 6px;
    background: var(--color-bg-hover);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.sr-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.sr-stage-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sr-stage-badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--color-bg-hover);
    color: var(--color-text-secondary);
    transition: all 0.3s ease;
}

.sr-stage-badge.done {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.sr-stage-badge.active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    animation: sr-pulse 1.5s infinite;
}

@keyframes sr-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ==================== 卡片通用 ==================== */

.sr-ranking-card,
.sr-prediction-card,
.sr-analysis-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    animation: sr-fadeIn 0.5s ease;
}

@keyframes sr-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.sr-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border-subtle);
}

.sr-card-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.sr-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.sr-card-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-left: auto;
}

/* ==================== 卡片 1: 排行榜表格 ==================== */

.sr-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sr-ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sr-ranking-table th {
    position: sticky;
    top: 0;
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-align: right;
    padding: 8px 10px;
    border-bottom: 2px solid var(--color-border-subtle);
    white-space: nowrap;
    z-index: 2;
}

.sr-ranking-table th:first-child,
.sr-ranking-table th:nth-child(2) {
    text-align: left;
}

.sr-ranking-table td {
    padding: 7px 10px;
    text-align: right;
    border-bottom: 1px solid var(--color-border-subtle);
    white-space: nowrap;
}

.sr-ranking-table td:first-child {
    text-align: center;
    color: var(--color-text-secondary);
    font-weight: 500;
    width: 32px;
}

.sr-ranking-table td:nth-child(2) {
    text-align: left;
    font-weight: 500;
}

.sr-ranking-table tbody tr:hover {
    background: var(--color-bg-hover);
}

.sr-value-up { color: #ef4444; }
.sr-value-down { color: #22c55e; }

.sr-industry-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sr-expand-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    background: transparent;
    border: 1px dashed var(--color-border-subtle);
    border-radius: 8px;
    color: var(--color-text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.sr-expand-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

/* LIVE badge */
.sr-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #ef4444;
    animation: sr-pulse 1.5s infinite;
}

.sr-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
}

.sr-last-update {
    font-size: 11px;
    color: var(--color-text-secondary);
}

/* Flash animation for value changes */
.sr-flash {
    animation: sr-flash-bg 1s ease;
}

@keyframes sr-flash-bg {
    0% { background-color: rgba(250, 204, 21, 0.3); }
    100% { background-color: transparent; }
}

/* ==================== 卡片 2: 預測儀表板 ==================== */

.sr-leaders {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--color-bg-hover);
    border-radius: 8px;
}

.sr-prediction-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sr-prediction-item {
    border: 1px solid var(--color-border-subtle);
    border-radius: 10px;
    padding: 16px;
    background: var(--color-bg-primary);
    transition: border-color 0.2s;
}

.sr-prediction-item:hover {
    border-color: var(--color-accent);
}

.sr-prediction-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sr-pred-rank {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-accent);
}

.sr-pred-industry {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.sr-badge-strong {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    font-weight: 600;
    margin-left: auto;
}

.sr-badge-watch {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    font-weight: 600;
    margin-left: auto;
}

.sr-badge-potential {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    font-weight: 600;
    margin-left: auto;
}

.sr-signal-summary {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    padding-left: 4px;
}

.sr-signals {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sr-signal-row {
    display: grid;
    grid-template-columns: 72px 120px 1fr;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.sr-signal-name {
    color: var(--color-text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.sr-signal-bar-track {
    height: 6px;
    background: var(--color-bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

.sr-signal-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.sr-signal-desc {
    color: var(--color-text-secondary);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-pred-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border-subtle);
    font-size: 12px;
    color: var(--color-text-secondary);
}

.sr-entry-timing {
    color: var(--color-info);
}

.sr-risk-note {
    color: var(--color-text-secondary);
}

/* 退潮警示 */
.sr-retreat-section {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 8px;
}

.sr-retreat-title {
    font-size: 13px;
    font-weight: 600;
    color: #ef4444;
    margin-bottom: 8px;
}

.sr-retreat-item {
    font-size: 12px;
    color: var(--color-text-secondary);
    padding: 4px 0;
}

/* ==================== 卡片 3: AI 分析 ==================== */

.sr-analysis-card {
    line-height: 1.7;
}

.sr-analysis-content {
    font-size: 14px;
    color: var(--color-text-primary);
}

.sr-analysis-content h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 10px;
    color: var(--color-text-primary);
}

.sr-analysis-content h2:first-child {
    margin-top: 0;
}

.sr-analysis-content p {
    margin: 8px 0;
}

.sr-analysis-content strong {
    color: var(--color-accent);
}

.sr-analysis-content ul,
.sr-analysis-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.sr-analysis-content li {
    margin: 4px 0;
}

/* 打字游標 */
.sr-typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--color-accent);
    animation: sr-blink 0.8s infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

@keyframes sr-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ==================== 響應式 ==================== */

@media (max-width: 768px) {
    .sr-ranking-card,
    .sr-prediction-card,
    .sr-analysis-card {
        padding: 14px;
    }

    .sr-signal-row {
        grid-template-columns: 60px 80px 1fr;
        gap: 6px;
    }

    .sr-pred-footer {
        flex-direction: column;
        gap: 4px;
    }

    .sr-card-meta {
        display: none;
    }
}
