/* ================================================================
   TIBD – Widget 02: Du Doan Ma Cao
   Mo rong design system League Manager
   ================================================================ */

/* Wrapper chinh */
.tibd-ddmc { position: relative; }
.tibd-ddmc * { box-sizing: border-box; }

/* ---- Reset style bang goc tu nguon ---- */
.tibd-ddmc table.prd_tb {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 0;
}
.tibd-ddmc table.prd_tb td {
    border: none;
    padding: 0;
    font-size: 14px;
    color: var(--c-text, #212529);
    vertical-align: middle;
}

/* Cot logo doi */
.tibd-ddmc td.tpr_img {
    width: 28px;
    text-align: center;
}
.tibd-ddmc td.tpr_img img {
    display: block;
    margin: auto;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Cot VS */
.tibd-ddmc td.tpr_vs {
    width: 28px;
    text-align: center;
}
.tibd-ddmc td.tpr_vs a {
    color: var(--c-red, #e03131) !important;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    cursor: default;
    pointer-events: none;
}

/* Cot ty so */
.tibd-ddmc td.tpr_ss {
    width: 100px;
    color: var(--c-blue, #1971c2);
    font-weight: 600;
    font-size: 13px;
    text-align: center;
    padding: 0 4px !important;
}

/* Cot ten doi */
.tibd-ddmc td.tpr_l,
.tibd-ddmc td.tpr_r {
    width: calc(50% - 93px);
    font-size: 13px;
    font-weight: 500;
}
.tibd-ddmc td.tpr_l {
    text-align: right;
    padding-right: 8px !important;
}
.tibd-ddmc td.tpr_r {
    padding-left: 8px !important;
}
.tibd-ddmc td.tpr_l a,
.tibd-ddmc td.tpr_r a {
    font-weight: 600;
    color: var(--c-text, #212529);
    text-decoration: none;
    cursor: default;
    pointer-events: none;
}

/* Mau highlight */
.tibd-ddmc span.red   { color: var(--c-red, #e03131); }
.tibd-ddmc span.green { color: #2f9e44; }
.tibd-ddmc span.blue  { color: var(--c-blue, #1971c2); }

/* ---- Khoi du doan (.prd_bar) ---- */
.tibd-ddmc .prd_bar {
    border: 1px solid var(--c-border, #e9ecef);
    border-radius: var(--c-radius, 6px);
    overflow: hidden;
    margin-bottom: 8px;
    background: var(--c-bg, #fff);
}
.tibd-ddmc .prd_bar:last-child { margin-bottom: 0; }

/* Header tran dau (bang chon - .prd_tbar) */
.tibd-ddmc .prd_tbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 5px 10px;
    background: var(--c-bg2, #f8f9fa);
    border-bottom: 1px solid var(--c-border, #e9ecef);
    flex-wrap: wrap;
}

/* Gio va ngay trong prd_tbar */
.tibd-ddmc .prd_tbar font {
    flex: 1;
    font-size: 11px;
    color: var(--c-muted, #868e96);
}

/* Nut popup trong prd_tbar */
.tibd-ddmc .prd_tbar > a {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    background: var(--c-bg3, #f1f3f5);
    color: var(--c-text, #212529) !important;
    border: 1px solid var(--c-border, #e9ecef);
    transition: all 0.15s;
    text-decoration: none !important;
    user-select: none;
}
.tibd-ddmc .prd_tbar > a:hover {
    background: var(--c-text, #212529);
    color: var(--c-bg, #fff) !important;
    border-color: var(--c-text, #212529);
}

/* Noi dung chinh cua prd_bar */
.tibd-ddmc .prd_cnt {
    padding: 10px 12px;
    font-size: 13px;
}

/* Dong tran dau ben trong prd_cnt */
.tibd-ddmc .prd_cnt .prd_tb tr {
    border-bottom: 1px solid var(--c-border, #e9ecef);
}
.tibd-ddmc .prd_cnt .prd_tb tr:last-child {
    border-bottom: none;
}
.tibd-ddmc .prd_cnt .prd_tb td {
    padding: 7px 0;
}

/* ---- Quang cao ---- */
.tibd-ddmc-ad {
    margin-bottom: 8px;
    text-align: center;
}
.tibd-ddmc-ad img {
    max-width: 100%;
    display: block;
    margin: auto;
    border-radius: var(--c-radius, 6px);
}

/* ================================================================
   POPUP OVERLAY
   ================================================================ */
.tibd-ddmc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    padding: 16px;
}
.tibd-ddmc-overlay.active {
    display: flex;
}

.tibd-ddmc-popup {
    background: var(--c-bg, #fff);
    border-radius: var(--c-radius, 6px);
    width: 100%;
    max-width: 620px;
    max-height: 82vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    animation: tibd-popup-in 0.2s ease;
}
@keyframes tibd-popup-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tibd-ddmc-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: 36px;
    height: 36px;
    font-size: 20px;
    cursor: pointer;
    color: var(--c-muted, #868e96);
    line-height: 1;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tibd-ddmc-close:hover { color: var(--c-red, #e03131); }

.tibd-ddmc-popup-body {
    padding: 16px 20px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--c-text, #212529);
    clear: both;
}
.tibd-ddmc-popup-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.tibd-ddmc-popup-body td,
.tibd-ddmc-popup-body th {
    padding: 6px 8px;
    border-bottom: 1px solid var(--c-border, #e9ecef);
    color: var(--c-text, #212529);
}
.tibd-ddmc-popup-body th {
    background: var(--c-bg2, #f8f9fa);
    font-weight: 600;
    font-size: 12px;
}
.tibd-ddmc-popup-body img {
    max-width: 100%;
}

/* Loading spinner */
.tibd-ddmc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    color: var(--c-muted, #868e96);
    font-size: 13px;
}
.tibd-ddmc-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--c-border, #e9ecef);
    border-top-color: var(--c-red, #e03131);
    border-radius: 50%;
    animation: tibd-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes tibd-spin { to { transform: rotate(360deg); } }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 480px) {
    .tibd-ddmc td.tpr_ss  { width: 70px; font-size: 12px; }
    .tibd-ddmc td.tpr_img { width: 22px; }
    .tibd-ddmc td.tpr_vs  { width: 22px; }
    .tibd-ddmc .prd_cnt   { padding: 8px; }
    .tibd-ddmc-popup { max-height: 90vh; }
    .tibd-ddmc-popup-body { padding: 12px; }
}
