/* widget.css - Football Odds Widget Responsive Styles
   Desktop/Tablet: Time | Match side-by-side
   Mobile (<=900px): Time above Match (stacked), sticky left/top
*/

/* ===========================
   CSS Variables
=========================== */
:root {
    --odds-header-height: 0px;
    --odds-columns-height: 48px;

    /* default widths for desktop/tablet */
    --col-team: 350px;  /* width of first column (team area) */
    --col-odd: 120px;   /* width of each odds column */
}

/* ===========================
   Base styles
=========================== */
.football-odds-widget {
    font-family: "Helvetica Neue", Arial, sans-serif;
}

.football-odds-inner {
    margin-top: 8px;
}

/* ---------------------------
   Top header
--------------------------- */
.odds-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #3b3b3b;
    color: #fff;
    padding: 10px 12px;
    border-radius: 6px;
}
.odds-header .title {
    font-weight: 700;
    font-size: 16px;
}
.odds-header .controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.refresh-btn.loading {
    opacity: 0.6;
    transform: rotate(20deg);
    transition: transform 0.2s;
}

button.refresh-btn.button

 {
    border: none;
}
/* ---------------------------
   Body wrapper (scrollable)
--------------------------- */
.odds-body-wrapper {
    overflow-x: auto;                 /* allow horizontal scroll */
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* ---------------------------
   Header grid (columns)
   First column: Time + Match
--------------------------- */
.odds-columns-header {
    display: flex;
    
    gap: 8px;
    padding: 8px 12px;
    
    color: #fff;
    font-weight: 600;
        top: calc(var(--odds-header-height, 0px));
    z-index: 50;
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
    align-items: center;
    
}

/* First header cell: Time + Match labels */
.odds-columns-header .col-team {
    display: flex;
    flex-direction: row;  /* Desktop/Tablet: side-by-side */
    gap: 12px;
    align-items: center;
}

.col-team{
width: 30% !important;
    max-width: 30% !important;
}

.col.team-block {
    width: 30% !important;
    max-width: 30% !important;
}
.col {
    flex-grow: 1;
}

.odds-columns-header .col-team .label-time {
    font-size: 13px; font-weight: 700;
}
.odds-columns-header .col-team .label-match {
    font-size: 13px; font-weight: 700; opacity: 0.95;
}

/* Other header columns */
.odds-columns-header .col {
    padding: 6px 4px;
    font-size: 13px;
    text-align: left;
}

/* ---------------------------
   Odds body container
--------------------------- */
.football-odds-inner .odds-body {

    min-width: 100%;
}

/* League title row (sticky below header) */
.league-section {
    
    position: relative;
}

.league-row {
    position: relative;
  
}

.league-row .league-cell {
    background: #eaf6fb;
    padding: 8px 10px;
    font-weight: 700;
    color: #333;
    border-radius: 4px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.02);
    position: sticky;
    left: 0;
    top: calc(var(--odds-header-height, 0px) + var(--odds-columns-height, 48px));
    z-index: 45;
    display: inline-block;
    max-width: 100%;
    width: 100%;
}

/* ---------------------------
   Match row grid
--------------------------- */
.match-card {
    display: flex;
    
    gap: 8px;
    padding: 10px;
    align-items: start;
    
    position: relative;
    background: #fff;
}
.match-card:last-child { border-bottom: none; }
.match-card .col {
    padding: 6px;
}

/* ---------------------------
   Team block (first grid column)
   Contains time + match area
--------------------------- */

/* ทีมต่อ - สีแดง */
.team-giving {
    color: #e74c3c !important;
    font-weight: 600;
}

/* ทีมรอง - สีดำ */
.team-receiving {
    color: #2c3e50 !important;
}
.team-block {
    display: flex;
    flex-direction: row;  /* Desktop/Tablet: Time | Match */
    gap: 12px;
    align-items: center;
}

/* Time area inside team-block */
.team-block .time-col {
    
    box-sizing: border-box;
    position: -webkit-sticky;
    position: sticky;
    left: 0;                 /* sticky left */
    z-index: 40;
    padding-right: 8px;
    border-right: 1px solid rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

/* Match area (right of time) */
.team-block .match-col {
    flex: 1 1 auto;
    display: block;
}

/* Status and meta info */
.status.live { display: none; }
.time-col .live-badge { 
    display: inline-block;
    background: #e74c3c;
    color: #fff;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 11px;
    margin-bottom: 6px;
}
.meta-date { font-size: 11px; color: #777; margin-top: 3px; }
.meta-time { font-size: 13px; font-weight: 700; margin-top: 2px; }

.match-col .team-home { color: #c0392b; }
.match-col .team-away { color: #333; margin-top: 4px; }
.match-col .team-draw { color: #999; font-size: 12px; }

/* Odds groups */
.odds-inline-group, .x12-group { display: flex; flex-direction: column; gap: 4px; }
.odds-val-row { font-size: 13px; font-weight: 700; }
.odds-pos { color: #0a7e07; }
.odds-neg { color: #c0392b; }
.odds-line-inline { font-size: 11px; color: #666; font-weight: 600; display: inline-block; margin-right: 6px; }
.odds-line-row { font-size: 11px; color: #666; font-weight: 600; margin-top: 4px; }

/* Fallback/empty cells */
.no-odds { color: #bbb; font-style: italic; }
.loading-cell, .error-cell { text-align: center; padding: 18px; color: #666; }

/*Span 1x2*/
span.x12-badge {
    color: #000000;
    background: #00B900;
    font-size: 12px;
    padding: 2px;
    border-radius: 3px;
    margin-right: 3px;
}
/* ===========================
   Mobile sticky + horizontal scroll
=========================== */
@media (max-width: 900px) {
    :root {
        --col-team: 200px;  /* ลดขนาดคอลัมน์ Time+Match บนมือถือ */
        --col-odd: 80px;   /* ลดขนาดคอลัมน์ออดส์เล็กน้อย */
    }

    .football-odds-inner .odds-body-wrapper {
        overflow-x: auto;   /* horizontal scroll for odds columns */
        -webkit-overflow-scrolling: touch;
       position: relative;
        
    }
    
    .football-odds-inner .odds-body {
        
        padding: 5px;
    }

    .match-card {
        display: grid;
        grid-template-columns: var(--col-team) repeat(6, var(--col-odd)); /* first column sticky, rest scrollable */
        gap: 6px;
        padding: 5px;
        border-radius: 6px;
        
        margin-bottom: 3px;
        position: relative;
        min-width: calc(var(--col-team) + 6 * var(--col-odd) + 5 * 6px + 8px);
    }

    .team-block {
        display: flex;
        
        position: sticky;        /* sticky left */
        left: 0;
        z-index: 60;
        background: #fff;
        gap: 6px;
        padding: 8px 8px 8px 8px;
        border-right: 2px solid #e0e0e0;
        box-shadow: 2px 0 4px rgba(0,0,0,0.05);
        min-width: var(--col-team);
        max-width: var(--col-team);
        text-align: center;
        border-radius: 5px;
    }

    .team-block .match-col {
        display: flex;
        flex-direction: column;
        gap: 3px;
        width: 100%;
    }

    .time-col {
    writing-mode: sideways-lr;
    width: auto;

    }
    .match-col .team-home,
    .match-col .team-away {
        font-size: 13px;
        line-height: 1.3;
        word-break: break-word;
    }

    .match-col .team-draw {
        font-size: 11px;
        margin-top: 2px;
    }

    /* Odds columns scrollable with background */
    .match-card .col:not(.team-block) {
        min-width: var(--col-odd);
        padding: 8px 4px;
        display: flex;
        flex-direction: column;
        text-align: center;
    }

    /* Header row: keep first column sticky */
    .odds-columns-header {
        display: flex;
        
        padding: 6px 8px 6px 0;
        
        top: var(--odds-header-height, 0px);
        z-index: 70;
        
        align-items: center;
        min-width: calc(var(--col-team) + 6 * var(--col-odd) + 5 * 6px + 8px);
        
    }

    .odds-columns-header .col-team {
        position: sticky;
        left: 0;
        
        z-index: 75;
        padding: 6px 8px;
        display: flex;
        flex-direction: row;
        gap: 4px;
        border-right: 2px solid rgba(0,0,0,0.2);
        box-shadow: 2px 0 4px rgba(0,0,0,0.1);
        min-width: var(--col-team);
        max-width: var(--col-team);
        justify-content: center;
    }

    .odds-columns-header .col-team .label-time,
    .odds-columns-header .col-team .label-match {
        font-size: 12px;
        font-weight: 700;
    }

    .odds-columns-header .col {
        text-align: center !important;
        font-size: 12px;
        padding: 4px 2px;
        min-width: var(--col-odd);
    }

    .league-section {

        position: relative;
        min-width: calc(var(--col-team) + 6 * var(--col-odd) + 5 * 6px + 8px);
    }

    .league-row {

        min-width: calc(var(--col-team) + 6 * var(--col-odd) + 5 * 6px + 16px);
    }

    .league-row .league-cell {
        background: #eaf6fb;
        padding: 8px 10px 8px 16px;
        display: block;
        width: 100%;
        min-width: calc(var(--col-team) + 6 * var(--col-odd) + 5 * 6px + 16px);
        font-size: 13px;
        font-weight: 700;
        border-left: 4px solid #3498db;
        box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    }
    
    .matches-container {
        position: relative;
    }

    /* ปรับแต่งเนื้อหาให้อ่านง่ายขึ้น */
    .meta-date {
        font-size: 10px;
    }
    
    .meta-time {
        font-size: 12px;
        font-weight: 700;
    }

    .odds-val-row {
        font-size: 12px;
    }

    .odds-line-inline {
        font-size: 10px;
        margin-right: 4px;
    }

    .x12-row {
        font-size: 11px;
    }
}


/* ===========================
   Optional stacked-mobile layout (no horizontal scroll)
=========================== */
.football-odds-widget.stacked-mobile .odds-columns-header { display: none; }
.football-odds-widget.stacked-mobile .odds-body-wrapper { overflow-x: visible; }
.football-odds-widget.stacked-mobile .match-card {
    grid-template-columns: 1fr;
    min-width: auto;
    display: grid;
    grid-template-areas:
        "team"
        "ft-hdp"
        "ft-ou"
        "ft-1x2"
        "h1-hdp"
        "h1-ou"
        "h1-1x2";
}
.football-odds-widget.stacked-mobile .team-block {
    grid-area: team;
    display: flex;
    flex-direction: column;
}
.football-odds-widget.stacked-mobile .team-block .time-col {
    position: sticky;
    top: calc(var(--odds-header-height,0px));
    z-index: 60;
}

/* ==========================================
   Grid 2x2 Layout Styles
   ========================================== */



.odds-grid.empty {
     padding: 8px;
    }

.grid-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    max-width: fit-content ;
    max-width: 80px;
}

.grid-cell {
    font-size: 12px;
    display: flex;
}

.grid-cell.line {
    justify-content: left;
}
.grid-cell.line.secondary {
    justify-content: left;
}
.grid-cell.odds.odds-pos {
    justify-content: right;
}
.grid-cell.odds.odds-neg {
    justify-content: right;
}

.grid-cell.label

 {
    justify-content: center;
}

.grid-cell.line 
 {
    justify-content: center;
}
.grid-cell.line.secondary {
    justify-content: center;
}


.odds-grid.three-cols {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.odds-grid.three-cols .grid-row {
    display: grid;
    grid-template-columns: 24px 20px 1fr; /* ปรับความกว้างแต่ละคอลัมน์ได้ */
    align-items: center;
    gap: 4px;
}

/* Responsive adjustments */
@media (max-width: 500px) {
        :root {
        --col-team: 160px;  /* ลดขนาดคอลัมน์ Time+Match บนมือถือ */
        --col-odd: 80px;   /* ลดขนาดคอลัมน์ออดส์เล็กน้อย */
    }

   .team-home.team-giving, .team-away.team-receiving, .team-away.team-giving, .team-home.team-receiving {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

    .team-block .time-col {
    border-right: none;
    min-width: 0px;
    align-items: center;
    

    flex-direction: row;

}
    .grid-cell {
        font-size: 10px;
        padding: 2px 4px;
        min-height: 16px;
    }
    
    .grid-cell.line {
        font-size: 9px;
    }

    .grid-row {

    max-width: 70px;
}
}

/* For 1X2 Grid specific styling */
.odds-grid.x12-grid .grid-cell.line {
    font-weight: 700;
    font-size: 11px;
}



/* Print styles */
@media print {
    .grid-cell.odds:hover {
        transform: none;
        box-shadow: none;
    }
}

