/**
 * MFT Football Odds - New Layout CSS v6.0
 * Thiết kế theo file design.png
 * 
 * @package MFT_Football_Odds
 * @version 6.0
 */

/* ========================================================================
   CSS CUSTOM PROPERTIES
   ======================================================================== */
:root {
    /* Colors */
    --mft-bg: #ffffff;
    --mft-surface: #ffffff;
    --mft-border: rgba(0, 0, 0, 0.08);
    --mft-border-strong: rgba(0, 0, 0, 0.12);
    
    /* Text Colors */
    --mft-text-primary: #1a1a1a;
    --mft-text-secondary: #4a4a4a;
    --mft-text-muted: #9ca3af;
    
    /* Accent Colors */
    --mft-accent-red: #c41e3a;
    --mft-accent-red-dark: #9a1830;
    --mft-live-color: #e74c3c;
    --mft-trend-up: #22c55e;
    --mft-trend-down: #ef4444;
    
    /* League Header */
    --mft-league-bg: #e5e5e5;
    --mft-league-text: #1a1a1a;
    
    /* Odds Colors */
    --mft-odds-line-color: #2563eb;
    --mft-odds-value-color: #1a1a1a;
    
    /* Spacing */
    --mft-spacing-xs: 4px;
    --mft-spacing-sm: 8px;
    --mft-spacing-md: 12px;
    --mft-spacing-lg: 16px;
    --mft-spacing-xl: 24px;
    
    /* Border Radius */
    --mft-radius-sm: 4px;
    --mft-radius-md: 6px;
    --mft-radius-lg: 8px;
    
    /* Shadows */
    --mft-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --mft-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --mft-shadow-dropdown: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Dark Mode */
html[data-color-scheme='dark'] {
    --mft-bg: #1a1a1a;
    --mft-surface: #242424;
    --mft-border: rgba(255, 255, 255, 0.08);
    --mft-border-strong: rgba(255, 255, 255, 0.12);
    
    --mft-text-primary: #f5f5f5;
    --mft-text-secondary: #d4d4d4;
    --mft-text-muted: #737373;
    
    --mft-league-bg: #2d2d2d;
    --mft-league-text: #f5f5f5;
    
    --mft-odds-value-color: #f5f5f5;
}

/* ========================================================================
   MAIN CONTAINER
   ======================================================================== */
.mft-odds-widget {
    width: 100%;
    max-width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: var(--mft-text-primary);
    background: var(--mft-bg);
    border-radius: var(--mft-radius-md);
}

/* ========================================================================
   HEADER SECTION
   ======================================================================== */
.mft-odds-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--mft-spacing-lg);
    padding: var(--mft-spacing-lg) 0;
    margin-bottom: var(--mft-spacing-md);
}

/* Title Badge - Theo design.png */
.mft-odds-title-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--mft-spacing-sm) var(--mft-spacing-lg);
    clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
    min-width: 280px;
}

.mft-badge-main {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: var(--mft-spacing-xs);
}

.mft-badge-highlight {
    font-size: 18px;
    font-weight: 700;
    font-style: italic;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter Controls */
.mft-odds-filters {
    display: flex;
    align-items: center;
    gap: var(--mft-spacing-md);
    margin-right: var(--mft-spacing-lg);
}

/* Dropdown */
.mft-filter-dropdown {
    position: relative;
}

.mft-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: var(--mft-spacing-sm);
    padding: var(--mft-spacing-sm) var(--mft-spacing-md);
    background: var(--mft-surface);
    border: 1px solid var(--mft-border-strong);
    border-radius: var(--mft-radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--mft-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
    justify-content: space-between;
}

.mft-dropdown-toggle:hover {
    border-color: var(--mft-text-muted);
}

.mft-dropdown-toggle[aria-expanded="true"] {
    border-color: var(--mft-accent-red);
}

.mft-dropdown-toggle[aria-expanded="true"] .mft-dropdown-chevron {
    transform: rotate(180deg);
}

.mft-dropdown-chevron {
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.mft-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--mft-surface);
    border: 1px solid var(--mft-border-strong);
    border-radius: var(--mft-radius-md);
    box-shadow: var(--mft-shadow-dropdown);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.mft-dropdown-menu[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mft-dropdown-item {
    display: block;
    width: 100%;
    padding: var(--mft-spacing-sm) var(--mft-spacing-md);
    background: none;
    border: none;
    text-align: left;
    font-size: 14px;
    color: var(--mft-text-secondary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.mft-dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mft-dropdown-item.active {
    color: var(--mft-accent-red);
    font-weight: 600;
}

/* ========================================================================
   TABLE STYLES
   ======================================================================== */
.mft-odds-content {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mft-table-header-wrap {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--mft-surface);
}

.mft-odds-table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    table-layout: fixed;
}

/* Column Widths */
.mft-odds-table .col-time { width: 8%; }
.mft-odds-table .col-elapsed { width: 4%; }
.mft-odds-table .col-actions { width: 3%; }
.mft-odds-table .col-match { width: 33%; }
.mft-odds-table .col-odds { width: 5.5%; }
.mft-odds-table .col-odds-line { width: 6%; }
.mft-odds-table .col-odds-1x2 { width: 5%; }

/* Table Header */
.mft-odds-table thead {
    background: var(--mft-surface);
    border-bottom: 1px solid var(--mft-border-strong);
}

.mft-header-row th {
    padding: var(--mft-spacing-sm) var(--mft-spacing-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--mft-text-primary);
    text-align: center;
    border-bottom: none;
}

.mft-header-row .th-time,
.mft-header-row .th-match {
    text-align: center;
}

.mft-header-row .th-odds-group {
    border-left: 1px solid var(--mft-border);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.3px;
}

.mft-subheader-row th {
    padding: var(--mft-spacing-xs) var(--mft-spacing-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--mft-text-secondary);
    text-align: center;
    border-bottom: 1px solid var(--mft-border-strong);
}

.mft-subheader-row .th-sub-first {
    border-left: 1px solid var(--mft-border);
}

.mft-subheader-row .th-sub-middle {
    position: relative;
}

.th-chart-icon {
    width: 20px;
    height: 14px;
    vertical-align: middle;
    margin-left: var(--mft-spacing-xl);
    opacity: 0.7;
}

/* ========================================================================
   LEAGUE SECTION
   ======================================================================== */
.mft-league-section {
    margin-bottom: 0;
}

.mft-league-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--mft-spacing-md) var(--mft-spacing-lg);
    background: var(--mft-league-bg);
    cursor: default;
}

.mft-league-info {
    display: flex;
    align-items: center;
    gap: var(--mft-spacing-sm);
}

.mft-league-logo-wrap {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.mft-league-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mft-league-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--mft-league-text);
    text-transform: uppercase;
}

/* League Body */
.mft-league-body {
    background: var(--mft-surface);
}

.mft-league-section[data-collapsed="true"] .mft-league-body {
    display: none;
}

/* ========================================================================
   MATCH ROW
   ======================================================================== */
.mft-match-row {
    border-bottom: 1px solid var(--mft-border);
    transition: background 0.15s ease;
}

.mft-match-row:hover {
    background: rgba(0, 0, 0, 0.02);
}

.mft-match-row td {
    padding: var(--mft-spacing-sm) var(--mft-spacing-md);
    vertical-align: middle;
}

/* Time Cell */
.td-time {
    text-align: left;
}

.mft-time {
    font-size: 13px;
    color: var(--mft-text-secondary);
    white-space: nowrap;
}

/* Elapsed Cell */
.td-elapsed {
    text-align: center;
}

.mft-live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mft-ball-icon {
    width: 16px;
    height: 16px;
    animation: mft-ball-spin 2s linear infinite;
}

@keyframes mft-ball-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mft-elapsed {
    font-size: 12px;
    font-weight: 600;
    color: var(--mft-live-color);
}

/* Actions Cell */
.td-actions {
    text-align: center;
}

.mft-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 16px;
    margin-top: 5px;
    transition: all 0.2s ease;
}

.mft-play-icon {
    width: 100%;
    height: 100%;
}

.mft-play-icon--light {
    display: block;
}

.mft-play-icon--dark {
    display: none;
}

html[data-color-scheme='dark'] .mft-play-icon--light {
    display: block;
}

html[data-color-scheme='dark'] .mft-play-icon--dark {
    display: none;
}

/* Match Cell */
.td-match {
    padding: var(--mft-spacing-sm) var(--mft-spacing-md) !important;
}

.mft-match-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mft-spacing-sm);
    text-decoration: none;
    color: inherit;
}

.mft-team {
    display: flex;
    align-items: center;
    gap: var(--mft-spacing-xs);
    flex: 1;
    min-width: 0;
}

.mft-team--home {
    justify-content: flex-end;
    text-align: right;
}

.mft-team--away {
    justify-content: flex-start;
    text-align: left;
}

.mft-team-rank {
    font-size: 11px;
    font-weight: 500;
    color: var(--mft-text-muted);
    flex-shrink: 0;
}

.mft-team-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--mft-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.mft-team-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mft-team-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Score */
.mft-score-wrap {
    flex-shrink: 0;
    padding: 0 var(--mft-spacing-sm);
}

.mft-vs {
    font-size: 12px;
    font-weight: 600;
    color: var(--mft-text-muted);
    padding: 4px 8px;
}

.mft-score {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: var(--mft-radius-sm);
}

html[data-color-scheme='dark'] .mft-score {
    background: #333;
}

.mft-score-home,
.mft-score-away {
    font-size: 14px;
    font-weight: 700;
    color: var(--mft-text-primary);
    min-width: 18px;
    text-align: center;
}

.mft-score-sep {
    font-size: 12px;
    color: var(--mft-text-muted);
}

/* Odds Cells */
.td-odds {
    text-align: center;
    padding: var(--mft-spacing-xs) var(--mft-spacing-sm) !important;
}

.td-odds--first {
    border-left: 1px solid var(--mft-border);
}

.mft-odds-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.mft-odds-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--mft-odds-value-color);
}

.mft-odds-line {
    font-size: 13px;
    font-weight: 600;
    color: var(--mft-odds-line-color);
}

.mft-trend-icon {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
}

.mft-trend-icon--trend-up {
    filter: hue-rotate(100deg);
}

/* No Matches */
.mft-no-matches {
    padding: var(--mft-spacing-xl) !important;
    text-align: center;
    color: var(--mft-text-muted);
    font-style: italic;
}

.mft-no-data {
    padding: var(--mft-spacing-xl);
    text-align: center;
    color: var(--mft-text-muted);
}

/* ========================================================================
   MOBILE STYLES
   ======================================================================== */
.mft-mobile-cards {
    display: none;
}

@media (max-width: 1024px) {
    .mft-odds-table {
        display: none;
    }
    
    .mft-table-header-wrap {
        display: none;
    }
    
    .mft-mobile-cards {
        display: block;
        padding: var(--mft-spacing-sm);
    }
}

/* Mobile Card */
.mft-mobile-card {
    background: var(--mft-surface);
    border: 1px solid var(--mft-border);
    border-radius: var(--mft-radius-lg);
    padding: var(--mft-spacing-md);
    margin-bottom: var(--mft-spacing-md);
}

.mft-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--mft-spacing-md);
}

.mft-mobile-time {
    font-size: 13px;
    color: var(--mft-text-secondary);
}

.mft-mobile-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--mft-live-color);
    font-weight: 600;
}

.mft-mobile-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 16px;
}

.mft-mobile-play .mft-play-icon {
    width: 100%;
    height: 100%;
}

.mft-mobile-play .mft-play-icon--light {
    display: block;
}

.mft-mobile-play .mft-play-icon--dark {
    display: none;
}

/* Mobile Match */
.mft-mobile-match {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mft-spacing-sm);
    margin-bottom: var(--mft-spacing-md);
    text-decoration: none;
    color: inherit;
}

.mft-mobile-team {
    display: flex;
    align-items: center;
    gap: var(--mft-spacing-xs);
    flex: 1;
    min-width: 0;
}

.mft-mobile-team--home {
    justify-content: flex-end;
}

.mft-mobile-team--away {
    justify-content: flex-start;
}

.mft-mobile-score {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: var(--mft-radius-md);
}

html[data-color-scheme='dark'] .mft-mobile-score {
    background: #333;
}

/* Mobile Markets */
.mft-mobile-markets {
    display: none;
    padding-top: var(--mft-spacing-md);
    border-top: 1px solid var(--mft-border);
}

.mft-mobile-markets[data-expanded="true"] {
    display: block;
}

.mft-mobile-market {
    margin-bottom: var(--mft-spacing-md);
}

.mft-mobile-market:last-child {
    margin-bottom: 0;
}

.mft-market-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--mft-text-primary);
    margin-bottom: var(--mft-spacing-sm);
    text-transform: uppercase;
}

.mft-market-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--mft-spacing-sm);
}

.mft-market-cell {
    text-align: center;
}

.mft-market-label {
    font-size: 11px;
    color: var(--mft-text-muted);
    margin-bottom: 2px;
}

.mft-market-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--mft-text-primary);
    padding: var(--mft-spacing-sm);
    background: #f5f5f5;
    border-radius: var(--mft-radius-sm);
}

html[data-color-scheme='dark'] .mft-market-value {
    background: #333;
}

.mft-market-value--line {
    color: var(--mft-odds-line-color);
}

/* Mobile Toggle */
.mft-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--mft-spacing-sm);
    width: 100%;
    padding: var(--mft-spacing-sm) var(--mft-spacing-md);
    background: transparent;
    border: 1px solid var(--mft-border);
    border-radius: var(--mft-radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--mft-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mft-mobile-toggle:hover {
    background: rgba(0, 0, 0, 0.03);
}

.mft-mobile-toggle[aria-expanded="true"] .mft-toggle-chevron {
    transform: rotate(180deg);
}

.mft-toggle-chevron {
    transition: transform 0.2s ease;
}

/* ========================================================================
   RESPONSIVE ADJUSTMENTS
   ======================================================================== */
@media (max-width: 768px) {
    .mft-odds-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--mft-spacing-md);
    }
    
    .mft-odds-title-badge {
        min-width: auto;
    }
    
    .mft-badge-main,
    .mft-badge-highlight {
        font-size: 16px;
    }
    
    .mft-odds-filters {
        width: 100%;
        justify-content: flex-end;
    }
    
    .mft-dropdown-toggle {
        min-width: 120px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .mft-odds-filters {
        flex-direction: column;
        width: 100%;
    }
    
    .mft-filter-dropdown {
        width: 100%;
    }
    
    .mft-dropdown-toggle {
        width: 100%;
    }
    
    .mft-mobile-team .mft-team-name {
        max-width: 80px;
        font-size: 12px;
    }
}

/* ========================================================================
   PRINT STYLES
   ======================================================================== */
@media print {
    .mft-mobile-cards,
    .mft-mobile-toggle,
    .mft-play-btn,
    .mft-odds-filters {
        display: none !important;
    }
    
    .mft-odds-table {
        display: table !important;
    }
}

/* ========================================================================
   LIVE REFRESH ANIMATIONS
   ======================================================================== */

/* Loading state */
.mft-odds-widget.mft-loading {
    position: relative;
}

.mft-odds-widget.mft-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--mft-accent-red), transparent);
    animation: mft-loading-bar 1.5s infinite;
}

@keyframes mft-loading-bar {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Row updated animation */
.mft-match-row.mft-row-updated {
    animation: mft-row-flash 0.5s ease-out;
}

@keyframes mft-row-flash {
    0% { background-color: rgba(37, 99, 235, 0.1); }
    100% { background-color: transparent; }
}

/* Odds value changed animation */
.mft-odds-value.mft-odds-changed,
.mft-odds-line.mft-odds-changed {
    animation: mft-odds-pulse 0.5s ease-out;
}

@keyframes mft-odds-pulse {
    0% {
        transform: scale(1);
        color: var(--mft-accent-red);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
        color: inherit;
    }
}

/* Score changed animation */
.mft-score-home.mft-score-changed,
.mft-score-away.mft-score-changed {
    animation: mft-score-flash 1s ease-out;
}

@keyframes mft-score-flash {
    0%, 50% {
        background-color: var(--mft-accent-red);
        color: white;
        transform: scale(1.2);
    }
    100% {
        background-color: transparent;
        color: inherit;
        transform: scale(1);
    }
}

/* Trend icon animation */
.mft-trend-icon {
    animation: mft-trend-appear 0.3s ease-out;
}

@keyframes mft-trend-appear {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Live indicator pulse */
.mft-live-indicator {
    position: relative;
}

.mft-live-indicator::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background-color: var(--mft-live-color);
    border-radius: 50%;
    animation: mft-live-pulse 1.5s infinite;
}

@keyframes mft-live-pulse {
    0%, 100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 0.5;
        transform: translateY(-50%) scale(1.3);
    }
}

/* Ball icon animation for live matches */
.mft-ball-icon {
    animation: mft-ball-spin 2s linear infinite;
}

@keyframes mft-ball-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark mode adjustments for animations */
[data-theme="dark"] .mft-match-row.mft-row-updated {
    animation-name: mft-row-flash-dark;
}

@keyframes mft-row-flash-dark {
    0% { background-color: rgba(37, 99, 235, 0.2); }
    100% { background-color: transparent; }
}
