/* 緊湊佈局樣式 */

/* 賽事選擇卡片 Sticky 固定在頁頂 */
#race-selector-row {
    position: -webkit-sticky; /* Safari 支援 */
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 1rem;
    background-color: transparent;
    padding-top: 0;
    padding-bottom: 0;
}

#race-selector-card {
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: box-shadow 0.3s ease;
    border: 1px solid #dee2e6;
    margin: 0;
}

/* 當卡片sticky時增強陰影效果 */
#race-selector-row.sticky-active #race-selector-card {
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* 確保在手機版也能正常工作 */
@media (max-width: 768px) {
    #race-selector-row {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    #race-selector-card {
        border-radius: 0.375rem;
    }
}

/* 確保 container 不會阻止 sticky */
.container {
    overflow: visible !important;
}

/* 投注活動監控滾動樣式 */
#betting-activity-content {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 自定義滾動條樣式（Webkit瀏覽器） */
#betting-activity-content::-webkit-scrollbar {
    width: 8px;
}

#betting-activity-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#betting-activity-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#betting-activity-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 機器學習推薦卡片平滑更新樣式 */
.ml-recommendations-row {
    transition: opacity 0.3s ease;
}

/* 文字更新時的平滑過渡 */
.horse-name,
.horse-no,
.composite-score,
.champion-prob,
.runner-up-prob,
.third-prob,
.fourth-prob,
.ml-reason,
.success-labels {
    transition: all 0.2s ease;
}

/* 機器學習概率表格樣式 */
.ml-predictions-table {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.ml-predictions-table th {
    background-color: #343a40;
    color: white;
    font-weight: 600;
    padding: 0.75rem 0.5rem;
    border: 1px solid #495057;
}

.ml-predictions-table td {
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    vertical-align: middle;
}

.ml-predictions-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* 概率方格顏色標示 */
.probability-cell {
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* 最高概率 - 紅色背景 */
.probability-cell.highest-prob {
    background-color: #dc3545 !important;
    color: white !important;
    font-weight: 700;
}

/* 高變動概率 - 綠色背景 */
.probability-cell.high-change {
    background-color: #28a745 !important;
    color: white !important;
    font-weight: 600;
}

/* 極高變動概率 - 啡色背景 */
.probability-cell.extreme-change {
    background-color: #8b4513 !important;
    color: white !important;
    font-weight: 700;
}

/* 馬號和馬名樣式 */
.ml-predictions-table .fw-bold {
    font-weight: 600 !important;
}

/* 重心馬標籤樣式（只保留標籤，不需要邊框和背景） */
.badge.bg-danger {
    font-size: 0.7rem;
    padding: 0.2em 0.4em;
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 表格響應式設計 */
@media (max-width: 768px) {
    .ml-predictions-table {
        font-size: 0.8rem;
    }
    
    .ml-predictions-table th,
    .ml-predictions-table td {
        padding: 0.4rem 0.3rem;
    }
}


/* 圓形賽事按鈕樣式 */
.race-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #dee2e6;
    background-color: #fff;
    color: #6c757d;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1px;
}

.race-btn:hover {
    border-color: #0d6efd;
    color: #0d6efd;
    transform: scale(1.05);
}

.race-btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.race-btn.active:hover {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
}

/* 日期選擇器樣式 */
.date-selector {
    display: flex;
    align-items: center;
}

.date-selector .form-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
}

.date-selector .form-select {
    font-size: 0.9rem;
    min-width: 150px;
}

/* 賽事資訊樣式 */
.race-info-content {
    text-align: center;
}

.race-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}

.race-time {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 3px;
}

.update-time {
    font-size: 0.9rem;
    color: #6c757d;
}

/* 表格樣式優化 */
.table-sm th,
.table-sm td {
    padding: 0.4rem;
    font-size: 0.8rem;
}

.table-sm th {
    font-weight: 600;
    background-color: #f8f9fa;
}

/* 賠率表格樣式 */
.odds-table-container {
    position: relative;
    font-size: 0.7rem;
}

.odds-label {
    font-size: 0.7rem;
    font-weight: bold;
    color:#333;
    padding: 2px 4px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 5px;
}

.quin-label {
    background-color: #7ee7fc;
    margin-left: auto;
}


/* 圓形場次按鈕樣式 - 使用 hkjc_races 資料 */
.race-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 1px solid #dee2e6;
    background-color: #fff;
    color: #333;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px;
    margin: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    flex-shrink: 0; /* 防止按鈕被壓縮 */
}

/* 場次選擇器容器樣式 */
.race-selector-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    overflow-x: auto;
    padding: 5px 0;
    justify-content: flex-start;
    align-items: center;
}

/* 響應式設計 - 確保所有場次都能顯示 */
@media (max-width: 768px) {
    .race-btn {
        width: 30px;
        height: 30px;
        font-size: 0.6rem;
        margin: 0.5px;
    }
    
    .race-no {
        font-size: 0.7rem;
    }
    
    .race-name {
        font-size: 0.35rem;
    }
}

.race-btn-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0px;
    width: 100%;
    height: 100%;
}

.race-no {
    font-weight: 700;
    font-size: 0.8rem;
    color: #0d6efd;
    line-height: 1;
}

.race-name {
    font-size: 0.4rem;
    font-weight: 500;
    color: #333;
    line-height: 1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.race-info {
    font-size: 0.4rem;
    color: #666;
    font-weight: 400;
    line-height: 1;
    display: none; /* 隱藏詳細資訊，保持簡潔 */
}

/* 懸停時顯示詳細資訊 */
.race-btn:hover .race-name,
.race-btn:hover .race-info {
    display: block;
}

.race-btn:hover {
    width: 80px;
    height: auto;
    border-radius: 8px;
    padding: 8px 4px;
}

.race-btn:hover {
    border-color: #0d6efd;
    color: #0d6efd;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

.race-btn.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.race-btn.active .race-no {
    color: #fff;
    font-weight: 800;
}

.race-btn.active .race-name {
    color: #fff;
}

.race-btn.active .race-info {
    color: rgba(255,255,255,0.9);
}

.race-btn.active:hover {
    background-color: #0b5ed7;
    border-color: #0b5ed7;
    transform: scale(1.15);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .race-btn {
        width: 40px;
        height: 40px;
        font-size: 0.7rem;
    }
    
    .race-no {
        font-size: 0.8rem;
    }
    
    .race-name {
        font-size: 0.4rem;
    }
    
    .race-info {
        font-size: 0.3rem;
    }
    
    .race-btn:hover {
        width: 60px;
        height: auto;
        border-radius: 6px;
        padding: 6px 3px;
    }
    
    /* 手機版優化間距 */
    .card-body {
        padding: 0.5rem !important;
    }
    
    .row {
        margin-left: -0.25rem !important;
        margin-right: -0.25rem !important;
    }
    
    .row > * {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }
    
    /* 卡片間距優化 */
    .card {
        margin-bottom: 0.5rem !important;
    }
    
    .card-header {
        padding: 0.5rem 0.75rem !important;
    }
    
    .card-body {
        padding: 0.5rem !important;
    }
    
    /* 表格間距優化 */
    .table-responsive {
        margin: 0 !important;
    }
    
    .table {
        margin-bottom: 0 !important;
    }
    
    /* 移除不必要的邊距 */
    .mb-3 {
        margin-bottom: 0.5rem !important;
    }
    
    .mt-3 {
        margin-top: 0.5rem !important;
    }
}

/* 超小螢幕優化 (手機) */
@media (max-width: 576px) {
    /* 進一步減少間距 */
    .card-body {
        padding: 0.25rem !important;
    }
    
    .row {
        margin-left: -0.125rem !important;
        margin-right: -0.125rem !important;
    }
    
    .row > * {
        padding-left: 0.125rem !important;
        padding-right: 0.125rem !important;
    }
    
    /* 卡片標題優化 */
    .card-header {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.9rem;
    }
    
    .card-header h6 {
        margin-bottom: 0 !important;
        font-size: 0.9rem;
    }
    
    /* 表格優化 */
    .table-compact {
        font-size: 0.75rem;
    }
    
    .table-compact th,
    .table-compact td {
        padding: 0.25rem !important;
    }
    
    /* 手機版獨贏位置表格優化 */
    #race-entries {
        font-size: 0.85rem !important;
    }
    
    #race-entries th,
    #race-entries td {
        font-size: 0.85rem !important;
        padding: 0.2rem 0.2rem !important;
    }
    
    #race-entries .win-odds,
    #race-entries .place-odds {
        font-size: 0.8rem !important;
        font-weight: 600 !important;
    }
    
    /* 手機版連贏位置Q表格優化 */
    #quin-odds {
        font-size: 0.6rem !important;
    }
    
    #quin-odds th,
    #quin-odds td {
        font-size: 0.6rem !important;
        padding: 0.1rem !important;
        line-height: 1.1 !important;
    }
    
    #quin-odds .quin-odds,
    #quin-odds .place-quin-odds {
        font-size: 0.55rem !important;
        padding: 0.03rem 0.02rem !important;
        min-width: 25px !important;
    }
    
    /* 移除所有不必要的邊距 */
    .mb-3 {
        margin-bottom: 0.25rem !important;
    }
    
    .mt-3 {
        margin-top: 0.25rem !important;
    }
    
    .mb-2 {
        margin-bottom: 0.25rem !important;
    }
    
    .mt-2 {
        margin-top: 0.25rem !important;
    }
    
    /* 騎師Q組合超小螢幕優化 */
    #jockey-quinella-cards .col-lg-3.col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    #jockey-quinella-cards .card {
        font-size: 0.75rem !important;
    }
    
    #jockey-quinella-cards .card-body {
        padding: 0.25rem !important;
    }
    
    #jockey-quinella-cards .card-header {
        padding: 0.25rem 0.375rem !important;
    }
    
    #jockey-quinella-cards .card-header h6 {
        font-size: 0.8rem !important;
        margin-bottom: 0 !important;
    }
    
    #jockey-quinella-cards .table {
        font-size: 0.65rem !important;
    }
    
    #jockey-quinella-cards .table th,
    #jockey-quinella-cards .table td {
        padding: 0.2rem 0.1rem !important;
    }
    
    #jockey-quinella-cards .small {
        font-size: 0.6rem !important;
    }
}

.table-compact {
    font-size: 0.8rem;
}

.table-compact td, 
.table-compact th {
    padding: 0.3rem !important;
}

/* 獨贏位置表格文字大小優化 */
#race-entries {
    font-size: 0.8rem !important;
}

#race-entries th,
#race-entries td {
    font-size: 0.8rem !important;
    padding: 0.25rem 0.3rem !important;
}

/* 確保表格中馬名與其他文字大小一致 */
#race-entries .horse-name-link,
#race-entries .ml-horse-name,
#race-entries td a,
#race-entries .horse-detail-btn,
#race-entries button {
    font-size: 0.8rem !important;
}

/* 獨贏位置表格標題欄位置中 */
#race-entries th {
    text-align: center !important;
}

#race-entries .win-odds,
#race-entries .place-odds {
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    font-variant-numeric: tabular-nums; /* 使用等寬數字字體 */
    transition: background-color 0.3s ease, color 0.3s ease;
    text-align: right !important;
}

/* 獨贏位置表格高亮樣式 - 參考連贏位置Q表格 */
#race-entries .win-odds.hot-odds,
#race-entries .place-odds.hot-odds {
    background-color: #ffcdd2 !important;
    font-weight: 700 !important;
    border-radius: 3px !important;
}

/* 連贏位置Q表格文字大小優化 */
#quin-odds {
    font-size: 0.8rem !important;
}

#quin-odds th,
#quin-odds td {
    font-size: 0.8rem !important;
    padding: 0.2rem !important;
}

#quin-odds .quin-odds,
#quin-odds .place-quin-odds {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    padding: 0.1rem 0.05rem !important;
    min-width: 30px !important;
    text-align: center !important;
}

#odds-update-time {
    font-size: 0.9rem;
    font-weight: bold;
    color: #1976d2;
    background-color: #e3f2fd;
    padding: 5px 10px;
    border-radius: 4px;
    display: inline-block;
    margin-left: 10px;
}

.odds-cell {
    font-weight: bold;
    text-align: center;
}

.odds-cell.highlight {
    background-color: #e8f4ff;
}

.quin-table td {
    text-align: center;
    font-size: 0.7rem;
    padding: 3px !important;
}

.quin-header {
    background-color: #f8f9fa;
    font-weight: bold;
}

.odds-changed {
    animation: flash 1s;
}

.odds-cell.hot-odds {
    background-color: #ffebee !important;
}

td.quin-odds.hot-odds {
    background-color: #ffcdd2 !important;
}

td.place-quin-odds.hot-odds {
    background-color: #ffccbc !important;
}

.quin-odds {
    background-color: #e3f2fd;
}

.place-quin-odds {
    background-color: #fff3e0;
}




.place-quin-label {
    background-color: #fff3e0;
    border: 1px solid #ffe0b2;
    color: #000;
    margin-left: 10px;
}

td.odds-cell {
    text-align: center;
    height: 28px;
    min-width: 28px;
    padding: 3px !important;
}

td.quin-odds {
    background-color: #e3f2fd !important;
}

td.place-quin-odds {
    background-color: #fff3e0 !important;
}

@keyframes flash {
    0% { background-color: #fff3cd; }
    100% { background-color: transparent; }
}

/* 機器學習概率變動效果 */
.ml-prob-changed {
    animation: ml-prob-flash 1s;
}

@keyframes ml-prob-flash {
    0% { background-color: #fff3cd; }
    100% { background-color: transparent; }
}

/* 機器學習最高概率紅色背景 */
td.ml-highest-prob {
    background-color: #ffcdd2 !important;
    font-weight: bold !important;
    color: #c62828 !important;
    border: 2px solid #d32f2f !important;
    box-shadow: 0 0 5px rgba(213, 47, 47, 0.3) !important;
}

/* 確保機器學習表格中的最高概率樣式優先級更高 */
.ml-predictions-table td.ml-highest-prob {
    background-color: #ffcdd2 !important;
    font-weight: bold !important;
    color: #c62828 !important;
    border: 2px solid #d32f2f !important;
    box-shadow: 0 0 5px rgba(213, 47, 47, 0.3) !important;
}

/* 退出馬匹樣式 */
.horse-withdrawn {
    background-color: #6c757d !important;
    color: #fff !important;
}

/* 推薦圖示樣式 */
.recommendation-icon-cell {
    width: 50px;
    padding: 8px 4px !important;
}

.recommendation-icon {
    font-size: 16px;
    color: #ffc107;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    animation: recommendation-pulse 2s infinite;
}

@keyframes recommendation-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 馬匹詳細資料Modal樣式 */
.horse-detail-btn {
    transition: all 0.2s ease;
}

.horse-detail-btn:hover {
    color: #0a58ca !important;
    text-decoration: underline !important;
}

#horseDetailModal .modal-dialog {
    max-width: 900px;
}

@media (max-width: 768px) {
    #horseDetailModal .modal-dialog {
        max-width: 95%;
        margin: 0.5rem auto;
    }
    
    #horseDetailModal .modal-content {
        border-radius: 0.5rem;
    }
}

#horseDetailModal .card {
    border: 1px solid #dee2e6;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

#horseDetailModal .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

#horseDetailModal .table th {
    border-top: none;
    font-size: 0.9rem;
}

#horseDetailModal .table td {
    vertical-align: middle;
    padding: 0.5rem;
}

#horseDetailModal .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* 馬匹基本資料樣式 */
.horse-info-item {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
}

.horse-info-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.horse-info-value {
    color: #212529;
    font-size: 0.875rem;
    font-weight: 500;
}

/* 響應式基本資料布局 */
@media (min-width: 992px) {
    .horse-info-item {
        margin-bottom: 0.5rem;
        min-height: 80px;
    }
}

@media (max-width: 991.98px) {
    .horse-info-item {
        margin-bottom: 0.75rem;
        min-height: 70px;
    }
}

@media (max-width: 576px) {
    .horse-info-item {
        margin-bottom: 1rem;
        min-height: 60px;
        padding: 0.75rem;
    }
    
    .horse-info-label {
        font-size: 0.8rem;
    }
    
    .horse-info-value {
        font-size: 0.8rem;
    }
}

/* 統計資料樣式 */
.stats-item {
    text-align: center;
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
}

/* 過往記錄表格響應式設計 */
@media (max-width: 768px) {
    #horse-records-table {
        font-size: 0.75rem;
    }
    
    #horse-records-table th,
    #horse-records-table td {
        padding: 0.25rem;
        white-space: nowrap;
    }
    
    #horse-records-table .table-responsive {
        border: none;
    }
}

.stats-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0d6efd;
}

.stats-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* 回到頁頂按鈕 */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    border: none;
    background-color: #0d6efd;
    color: white;
    font-size: 18px;
}

#back-to-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

#back-to-top.show {
    display: block;
}

/* 響應式設計 */
@media (max-width: 768px) {
    #back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}

.horse-withdrawn td {
    background-color: #6c757d !important;
    color: #fff !important;
}

.horse-withdrawn .odds-cell {
    background-color: #6c757d !important;
    color: #fff !important;
}

.horse-withdrawn .odds-cell.hot-odds {
    background-color: #6c757d !important;
    color: #fff !important;
}

/* 馬名連結樣式 */
.horse-name-link {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.horse-name-link:hover {
    color: #0b5ed7;
    text-decoration: underline;
    font-weight: 600;
}

.horse-withdrawn .horse-name-link {
    color: #fff;
}

.horse-withdrawn .horse-name-link:hover {
    color: #e9ecef;
    text-decoration: underline;
}

/* 自定義淺啡色標籤 */
.badge.bg-light-brown {
    background-color: #d2b48c !important;
    color: #000 !important;
}

/* 星爆圖案命中標籤樣式 - 使用完美的星形 clip-path */
.hit-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 40px;
    height: 40px;
    background: #E02020;
    clip-path: polygon(
        79.39% 90.45%, 50.00% 69.00%, 20.61% 90.45%, 31.93% 55.87%, 2.45% 34.55%, 
        38.83% 34.63%, 50.00% 0.00%, 61.17% 34.63%, 97.55% 34.55%, 68.07% 55.87%
    );
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 星爆中心圓形 */
.hit-badge .badge-icon {
    position: relative;
    z-index: 3;
    font-size: 1.2rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 不同名次的星爆標籤顏色 - 使用 clip-path 方法 */
.hit-badge.champion {
    background: #E02020; /* 紅色 - 冠軍 */
}

.hit-badge.runner-up {
    background: #28a745; /* 綠色 - 亞軍 */
}

.hit-badge.third-place {
    background: #17a2b8; /* 藍色 - 季軍 */
}

.hit-badge.fourth-place {
    background: #6c757d; /* 灰色 - 殿軍 */
}

/* 星爆圖案動畫效果 - 簡單脈衝，無旋轉 */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 8px rgba(224, 32, 32, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
}


/* 不同名次的星爆標籤顏色 */
.hit-badge.champion {
    background: #E02020; /* 紅色 - 冠軍 */
}

.hit-badge.runner-up {
    background: #28a745; /* 綠色 - 亞軍 */
}

.hit-badge.third-place {
    background: #17a2b8; /* 藍色 - 季軍 */
}

.hit-badge.fourth-place {
    background: #6c757d; /* 灰色 - 殿軍 */
}

/* 並排布局優化 */
.odds-sidebar {
    min-height: 400px;
}

.odds-sidebar .card {
    border: 1px solid #dee2e6;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.odds-sidebar .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 0.5rem 0.75rem;
}

.odds-sidebar .card-body {
    padding: 0.5rem;
}

/* 響應式調整 */
@media (max-width: 991.98px) {
    .odds-sidebar {
        margin-top: 1rem;
    }
}

@media (max-width: 767.98px) {
    .odds-sidebar .card-body {
        padding: 0.25rem;
    }
    
    .odds-table-container {
        font-size: 0.6rem;
    }
    
    .odds-label {
        font-size: 0.6rem;
        padding: 1px 3px;
    }
    
    .table-compact {
        font-size: 0.7rem;
    }
    
    .table-compact td, 
    .table-compact th {
        padding: 0.25rem !important;
    }
    
    /* 機器學習推薦手機版布局 - 一行顯示兩隻馬匹 */
    #ml-recommendations .col-md-6.col-lg-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* 機器學習推薦卡片在手機版的樣式調整 */
    #ml-recommendations .card {
        font-size: 0.8rem;
    }
    
    #ml-recommendations .card-body {
        padding: 0.5rem;
    }
    
    #ml-recommendations .card-title {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    #ml-recommendations .small {
        font-size: 0.7rem;
    }
    
    /* 騎師Q組合手機版布局 - 一行顯示兩個卡片 */
    #jockey-quinella-cards .col-lg-3.col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* 騎師Q組合卡片在手機版的樣式調整 */
    #jockey-quinella-cards .card {
        font-size: 0.8rem;
    }
    
    #jockey-quinella-cards .card-body {
        padding: 0.5rem;
    }
    
    #jockey-quinella-cards .card-header {
        padding: 0.5rem;
    }
    
    #jockey-quinella-cards .card-header h6 {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    #jockey-quinella-cards .table {
        font-size: 0.7rem;
    }
    
    #jockey-quinella-cards .table th,
    #jockey-quinella-cards .table td {
        padding: 0.25rem 0.2rem;
    }
    
    #jockey-quinella-cards .small {
        font-size: 0.65rem;
    }
}

/* 新的機器學習馬匹列表樣式 */
.ml-horse-item {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 16px;
    background-color: #fff;
    transition: all 0.3s ease;
}

.ml-horse-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.ml-horse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ml-horse-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ml-horse-number {
    background-color: #007bff;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.ml-horse-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: #333;
}

.ml-confidence {
    background-color: #e9ecef;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.ml-probabilities {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ml-prob-item {
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.ml-prob-label {
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 4px;
}

.ml-prob-value {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* 概率顏色標示 */
.ml-prob-item.highest-prob {
    background-color: #ffebee !important;
    border-color: #ffcdd2 !important;
    color: #c62828 !important;
}

.ml-prob-item.high-change {
    background-color: #e8f5e8 !important;
    border-color: #c8e6c9 !important;
    color: #2e7d32 !important;
}

.ml-prob-item.extreme-change {
    background-color: #fff3e0 !important;
    border-color: #ffcc02 !important;
    color: #ef6c00 !important;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .ml-probabilities {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ml-horse-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}


/* 預計跑法排位視覺化樣式 */
.predicted-position-visual {
    padding: 20px 10px;
    background: linear-gradient(to right, #f8f9fa 0%, #ffffff 50%, #f8f9fa 100%);
    border-radius: 8px;
    position: relative;
}

.position-row-container {
    position: relative;
}

.position-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.position-horse-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.horse-number-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.horse-number-circle:hover {
    transform: scale(1.1);
}

    .horse-number-circle.border-danger {
        border-color: #dc3545;
        color: #dc3545;
    }

    .horse-number-circle.border-warning {
        border-color: #ffc107;
        color: #ffc107;
    }

    .horse-number-circle.border-primary {
        border-color: #0d6efd;
        color: #0d6efd;
    }

    .horse-number-circle.border-success {
        border-color: #198754;
        color: #198754;
    }

    .horse-number-circle.border-info {
        border-color: #0dcaf0;
        color: #0dcaf0;
    }

.horse-name {
    font-size: 0.85rem;
    max-width: 80px;
    word-wrap: break-word;
    margin-top: 8px;
    font-weight: 500;
}

.horse-draw {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 4px;
}

.position-label-right {
    text-align: right;
    padding-right: 20px;
}

.position-label-left {
    text-align: left;
    padding-left: 20px;
}

/* 桌面版顯示馬名和檔位 */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    /* 手機版隱藏桌面版馬名和檔位 */
    .desktop-only {
        display: none !important;
    }
    
    /* 手機版顯示馬名 */
    .mobile-only {
        display: block !important;
    }
    
    .predicted-position-visual {
        padding: 8px 2px;
    }
    
    .position-row {
        justify-content: flex-end;
        flex-wrap: nowrap; /* 強制單行顯示，不換行 */
        gap: 1px;
        padding: 5px 0;
        overflow-x: auto; /* 如果超過寬度，允許橫向滾動 */
        -webkit-overflow-scrolling: touch; /* iOS 平滑滾動 */
    }
    
    .position-horse-item {
        min-width: 38px;
        max-width: 38px;
        flex-shrink: 0; /* 防止縮小 */
        margin: 0;
    }
    
    .horse-number-circle {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
        border-width: 2px;
    }
    
    .horse-name-mobile {
        font-size: 0.48rem !important;
        max-width: 38px !important;
        word-wrap: break-word;
        margin-top: 1px !important;
        line-height: 1.1 !important;
        color: #495057;
        font-weight: 500;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        height: 1.1rem; /* 固定高度，確保兩行文字 */
    }
    
    .position-label-right,
    .position-label-left {
        padding: 0 5px;
        font-size: 0.75rem;
    }
    
    .arrow-separator {
        margin: 5px 0 !important;
        font-size: 0.8rem;
    }
    
    .arrow-separator i {
        font-size: 1rem !important;
    }
}

/* 賠率走勢表格樣式 */
.odds-trend-container {
    margin-bottom: 1rem;
}

.odds-trend-table {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.odds-trend-table th {
    font-size: 0.8rem;
    white-space: nowrap;
    vertical-align: middle;
    padding: 0.5rem 0.25rem;
}

.odds-trend-table td {
    vertical-align: middle;
    padding: 0.4rem 0.25rem;
    text-align: center;
}

/* 馬名欄位寬度限制 */
.odds-trend-table .horse-name-col {
    width: 90px;
    max-width: 90px;
    min-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.odds-trend-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* 賠率走勢背景色 */
.odds-trend-table tbody tr.bg-danger-light {
    background-color: #ffcdd2 !important; /* 紅色 - 最低賠率 */
}

.odds-trend-table tbody tr.bg-danger-light:hover {
    background-color: #ef9a9a !important;
}

.odds-trend-table tbody tr.bg-danger-light td {
    background-color: transparent !important;
}

.odds-trend-table .bg-success-light {
    background-color: #e8f5e9 !important; /* 淺綠色 - 賠率下降 >= 20% */
}

.odds-trend-table .bg-brown {
    background-color: #efebe9 !important; /* 淺啡色 - 賠率下降 >= 50% */
    font-weight: 600;
}

/* 賠率走勢響應式設計 */
/* 桌面版：顯示表格，隱藏卡片 */
.odds-trend-desktop {
    display: block;
}

.odds-trend-mobile {
    display: none;
}

/* 手機版：隱藏表格，顯示卡片 */
@media (max-width: 768px) {
    .odds-trend-desktop {
        display: none !important;
    }
    
    .odds-trend-mobile {
        display: block !important;
    }
    
    /* 手機版卡片樣式 - 緊湊設計，無需滾動 */
    .odds-trend-mobile-card {
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        margin-bottom: 0.5rem !important;
    }
    
    .odds-trend-mobile-card .card-body {
        padding: 0.5rem !important;
    }
    
    .odds-trend-mobile-card .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.4rem;
    }
    
    .odds-trend-mobile-card .fw-bold {
        font-size: 0.8rem;
    }
    
    .odds-trend-mobile-card .row {
        margin: 0;
    }
    
    .odds-trend-mobile-card .row.g-1 > * {
        padding: 0.125rem;
    }
    
    .odds-trend-mobile-card .small {
        font-size: 0.65rem;
        margin-bottom: 0.125rem;
        line-height: 1.2;
    }
    
    .odds-trend-mobile-card .bg-primary.bg-opacity-10,
    .odds-trend-mobile-card .bg-info.bg-opacity-10 {
        padding: 0.375rem 0.25rem !important;
    }
    
    .odds-trend-mobile-card .col-6 .fw-bold {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    .odds-trend-title {
        font-size: 0.85rem;
        margin-bottom: 0.5rem !important;
    }
    
    .odds-trend-title small {
        font-size: 0.7rem;
    }
    
    /* 背景色樣式在手機版也適用 */
    .odds-trend-mobile-card .bg-success-light {
        background-color: #e8f5e9 !important;
    }
    
    .odds-trend-mobile-card .bg-brown {
        background-color: #efebe9 !important;
        font-weight: 600;
    }
    
    .horse-number-circle {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
        margin: 0 auto 2px !important;
        border-width: 2px !important; /* 縮小邊框 */
    }
    
    .position-label-right,
    .position-label-left {
        text-align: center;
        padding: 0;
        font-size: 0.7rem;
    }
    
    /* 確保箭頭和文字也縮小 */
    .position-row-container .text-center {
        font-size: 0.75rem;
    }
    
    .position-row-container .bi-arrow-left {
        font-size: 1rem !important;
    }
}
