/* ================================================================
   TIBD – Widget 03: Ty Le Keo
   ================================================================ */

.tibd-keo * { box-sizing: border-box; }

/* ---- Day nav (gom ca tab LIVE) ---- */
.tibd-keo-daynav { margin-bottom: 0; }

/* Tab LIVE trong menu ngay */
.tibd-keo-livetab {
    border: 1px solid rgba(224,49,49,.3) !important;
    color: var(--c-red, #e03131) !important;
}
.tibd-keo-livetab .lm-live-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--c-red, #e03131);
    animation: lm-pulse 1.4s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 2px;
}
.tibd-keo-livetab.active,
.tibd-keo-livetab.tibd-keo-live-active {
    background: var(--c-red, #e03131) !important;
    border-color: var(--c-red, #e03131) !important;
    color: #fff !important;
}
.tibd-keo-livetab.active .lm-live-dot,
.tibd-keo-livetab.tibd-keo-live-active .lm-live-dot { background: #fff; }

.tibd-keo-live-header {
    background: rgba(224,49,49,.06) !important;
    border-left: 3px solid var(--c-red, #e03131);
}

/* ================================================================
   CSS VARIABLES — dung chung cho header va row de dong bo width
   Tong min-width = time + team + cell*4 + 1x2
   = 56 + 150 + 76*4 + 52 = 562px
   ================================================================ */
:root {
    --keo-w-time: 56px;   /* cot gio + phong do */
    --keo-w-team: 150px;  /* cot ten doi */
    --keo-w-cell: 90px;   /* cot keo chap / tai xiu — tang len cho de doc */
    --keo-w-1x2:  52px;   /* cot 1x2 */
}

/* ================================================================
   TABLE WRAPPER
   ================================================================ */
.tibd-keo-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Header cot ---- */
.tibd-keo-col-header {
    display: flex;
    align-items: stretch;
    background: var(--c-bg2, #f8f9fa);
    border-bottom: 2px solid var(--c-border, #e9ecef);
    font-size: 11px;
    font-weight: 700;
    color: var(--c-muted, #868e96);
    text-transform: uppercase;
    letter-spacing: .04em;
    min-width: 618px;
}

.tibd-keo-col-header .ch-time {
    width: var(--keo-w-time);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    border-right: 1px solid var(--c-border, #e9ecef);
    text-align: center;
}
.tibd-keo-col-header .ch-team {
    width: var(--keo-w-team);
    flex-shrink: 0;
    padding: 6px 8px;
    border-right: 1px solid var(--c-border, #e9ecef);
    display: flex;
    align-items: center;
}
.tibd-keo-col-header .ch-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-right: 1px solid var(--c-border, #e9ecef);
}
.tibd-keo-col-header .ch-group:last-child { border-right: none; }

.tibd-keo-col-header .ch-group-label {
    text-align: center;
    padding: 3px 0;
    font-size: 10px;
    font-weight: 700;
    color: var(--c-text, #212529);
    border-bottom: 1px solid var(--c-border, #e9ecef);
    background: var(--c-bg2, #f8f9fa);
}
.tibd-keo-col-header .ch-subs {
    display: flex;
    flex: 1;
}
.tibd-keo-col-header .ch-subs .sub-cell {
    width: var(--keo-w-cell);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px 2px;
    border-right: 1px solid var(--c-border, #e9ecef);
    text-align: center;
    font-size: 10px;
}
.tibd-keo-col-header .ch-subs .sub-1x2 {
    width: var(--keo-w-1x2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px 2px;
    border-right: 1px solid var(--c-border, #e9ecef);
    text-align: center;
    font-size: 10px;
}
.tibd-keo-col-header .ch-subs .sub-cell:last-child,
.tibd-keo-col-header .ch-subs .sub-1x2:last-child { border-right: none; }

/* ================================================================
   MATCH ROW
   ================================================================ */
.tibd-keo-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--c-border, #e9ecef);
    min-width: 618px;
    background: var(--c-bg, #fff);
    transition: background .12s;
}
.tibd-keo-row:last-child { border-bottom: none; }
.tibd-keo-row:nth-child(odd)  { background: var(--c-bg,  #ffffff) !important; }
.tibd-keo-row:nth-child(even) { background: var(--c-bg2, #f8f9fa) !important; }
.tibd-keo-row:hover           { background: var(--c-bg3, #f1f3f5) !important; }

/* Cot gio + phong do */
.tibd-keo-col-time {
    width: var(--keo-w-time);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3px 2px;
    border-right: 1px solid var(--c-border, #e9ecef);
    gap: 2px;
}
.tibd-keo-date   { font-size: 10px; color: var(--c-muted, #868e96); line-height: 1.3; }
.tibd-keo-time   { font-size: 12px; font-weight: 700; color: var(--c-red, #e03131); line-height: 1.3; }
.tibd-keo-score  { font-size: 13px; font-weight: 800; color: var(--c-red, #e03131); line-height: 1.3; }
.tibd-keo-minute { font-size: 10px; color: var(--c-red, #e03131); font-weight: 600; line-height: 1.3; }

/* Cot ten doi — co dinh, khong flex */
.tibd-keo-col-team {
    width: var(--keo-w-team);
    flex-shrink: 0;
    padding: 3px 6px;
    border-right: 1px solid var(--c-border, #e9ecef);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}
.tibd-keo-teams {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tibd-keo-home,
.tibd-keo-away {
    font-size: 12px;
    font-weight: 500;
    color: var(--c-text, #212529);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.tibd-keo-favor   { color: var(--c-red, #e03131); font-weight: 700; }
.tibd-keo-winning { color: var(--c-red, #e03131); font-weight: 700; }

/* Nut phong do — nam trong col-time, gon nho */
.tibd-keo-phongdo-btn {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--c-bg3, #f1f3f5);
    border: 1px solid var(--c-border, #e9ecef);
    color: var(--c-blue, #1971c2);
    cursor: pointer;
    transition: all .12s;
    user-select: none;
    line-height: 1.5;
    letter-spacing: .02em;
}
.tibd-keo-phongdo-btn:hover {
    background: var(--c-blue, #1971c2);
    color: #fff;
    border-color: var(--c-blue, #1971c2);
}

/* ================================================================
   CELLS KEO
   Layout: [sub-line | sub-odds]
   sub-line: keo chap / muc tai xiu (mau do)
   sub-odds: odds home tren, odds away duoi (mau den)
   ================================================================ */
.tibd-keo-cell {
    width: var(--keo-w-cell);
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    border-right: 1px solid var(--c-border, #e9ecef);
    padding: 0;
}
.tibd-keo-cell:last-child { border-right: none; }

/* Sub-cot trai: keo chap / muc tai xiu — KHONG co border-right */
.tibd-keo-sub-line {
    width: 44%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 3px 2px 3px 3px;
    /* Khong co border-right — bo theo yeu cau */
}
.tibd-keo-line-val {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-red, #e03131); /* do theo ban goc */
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Sub-cot phai: odds home + odds away — mau den */
.tibd-keo-sub-odds {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 3px 3px 3px 1px;
    align-items: flex-end;
}
.tibd-keo-sub-odds span {
    font-size: 11px;
    font-weight: 600;
    color: var(--c-text, #212529); /* den theo yeu cau */
    line-height: 1.4;
    text-align: right;
    display: block;
    white-space: nowrap;
}

/* 1x2: 3 gia tri W/D/L xep doc, mau den */
.tibd-keo-1x2 {
    width: var(--keo-w-1x2);
    flex-direction: column;
    justify-content: space-around;
    padding: 3px 4px;
    align-items: flex-end;
}
.tibd-keo-1x2 span {
    font-size: 11px;
    font-weight: 600;
    color: var(--c-text, #212529);
    text-align: right;
    display: block;
    line-height: 1.4;
    width: 100%;
    white-space: nowrap;
}

/* ================================================================
   MODAL PHONG DO
   ================================================================ */
.tibd-keo-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    padding: 16px;
}
.tibd-keo-overlay.active { display: flex; }
.tibd-keo-modal {
    background: var(--c-bg, #fff);
    border-radius: var(--c-radius, 6px);
    width: 100%;
    max-width: 680px;
    max-height: 84vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    animation: tibd-popup-in .2s ease;
}
.tibd-keo-modal-close {
    position: sticky;
    top: 0;
    float: right;
    background: var(--c-bg2, #f8f9fa);
    border: none;
    border-radius: 0 var(--c-radius,6px) 0 var(--c-radius,6px);
    width: 32px; height: 32px;
    font-size: 18px;
    cursor: pointer;
    color: var(--c-muted, #868e96);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.tibd-keo-modal-close:hover { color: var(--c-red, #e03131); }
.tibd-keo-modal-body {
    padding: 12px 16px 16px;
    font-size: 13px;
    color: var(--c-text, #212529);
    clear: both;
    overflow-x: auto;
}
.tibd-keo-modal-body table { width:100%; border-collapse:collapse; font-size:13px; }
.tibd-keo-modal-body td, .tibd-keo-modal-body th {
    padding: 5px 7px;
    border-bottom: 1px solid var(--c-border, #e9ecef);
}
.tibd-keo-modal-body th {
    background: var(--c-bg2, #f8f9fa);
    font-weight: 600; font-size: 12px;
}
.tibd-keo-modal-body tr:first-child td[colspan] {
    background: #004118; color: #fff; font-weight: 700; padding: 6px 8px;
}
.tibd-keo-modal-body tr:nth-child(odd)  td { background: var(--c-bg2, #f8f9fa); }
.tibd-keo-modal-body tr:nth-child(even) td { background: var(--c-bg, #fff); }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
    :root {
        --keo-w-time: 48px;
        --keo-w-team: 110px;
        --keo-w-cell: 76px;
        --keo-w-1x2:  44px;
    }
    .tibd-keo-date { display: none; }
    .tibd-keo-phongdo-btn { display: none; }
}
