/* ==========================================================================
   Kinetic Seven - SportsPress Compatibility Styles (REVISION 2)
   Fix for table layouts, text colors, zebras, and single match layout
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Global Overrides (Link Colors & Backgrounds)
   -------------------------------------------------------------------------- */
/* Reset any blue link styling to use theme colors */
.sportspress a,
.sportspress a:link,
.sportspress a:visited,
.sp-template a,
.sp-template a:link,
.sp-template a:visited {
    color: var(--k-text-primary, #ffffff) !important;
    text-decoration: none !important;
    transition: color 0.3s ease;
}

.sportspress a:hover,
.sp-template a:hover {
    color: var(--k-primary, #e62117) !important;
}

/* --------------------------------------------------------------------------
   1. Tables Base (League Tables, Player Stats, Event Lists)
   -------------------------------------------------------------------------- */
.sportspress table,
.sp-template table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: var(--k-surface-0, #0a0a0a) !important;
    table-layout: auto !important;
    border-radius: 0;
    overflow: hidden;
    margin-bottom: 20px;
}

/* Cell padding & vertical align */
.sportspress td,
.sportspress th {
    padding: 14px 10px !important;
    vertical-align: middle !important;
    text-align: center !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Left align just the names */
.sportspress th.data-name,
.sportspress td.data-name {
    text-align: left !important;
}

/* Headers style */
.sportspress h4,
.sp-template h4,
.sportspress .sp-table-caption,
.sp-template .sp-table-caption {
    text-align: center !important;
    text-transform: uppercase;
    font-family: var(--k-font-display, 'Space Grotesk', sans-serif);
    margin-bottom: 15px;
    width: 100%;
    display: block;
}

.sportspress th,
.sp-template th {
    background-color: var(--k-primary, #990000) !important;
    color: #ffffff !important;
    font-family: var(--k-font-display, 'Space Grotesk', sans-serif) !important;
    font-size: 0.95rem !important;
    text-transform: uppercase;
    font-weight: 800 !important;
    letter-spacing: 0.05em;
    border: none !important;
    text-align: center !important;
}

/* Permitir centrado en incidencias */
.sportspress table.sp-event-performance th.data-name,
.sportspress table.sp-event-performance th.data-name * {
    text-align: center !important;
}

/* Zebra Stripes (Pares e Impares) para TODO tipo de tabla SP */
.sportspress tbody tr:nth-child(odd) td,
.sportspress tbody tr.odd td,
.sp-template tbody tr:nth-child(odd) td {
    background-color: var(--k-surface-1, #131313) !important;
}

.sportspress tbody tr:nth-child(even) td,
.sportspress tbody tr.even td,
.sp-template tbody tr:nth-child(even) td {
    background-color: var(--k-surface-0, #0a0a0a) !important;
}

/* Highlight specific columns like Points */
.sportspress td.data-pts {
    font-weight: 900 !important;
    color: var(--k-primary, #e62117) !important;
    font-size: 1.1rem !important;
}

.sportspress time,
.sportspress .sp-result {
    font-family: var(--k-font-display, 'Epilogue', sans-serif);
    font-weight: 800;
}

/* --------------------------------------------------------------------------
   2. Event Blocks (Non-table match cards)
   -------------------------------------------------------------------------- */
.sp-template-event-blocks .sp-event-block {
    display: flex;
    flex-direction: column;
    padding: 20px !important;
    border-radius: 0;
    margin-bottom: 15px;
    border-left: 4px solid var(--k-surface-1, #131313);
    transition: all 0.3s ease;
}

/* Zebra para bloques pares/impares si no son tablas */
.sp-template-event-blocks .sp-event-block:nth-child(odd) {
    background-color: var(--k-surface-1, #131313) !important;
}
.sp-template-event-blocks .sp-event-block:nth-child(even) {
    background-color: var(--k-surface-0, #0a0a0a) !important;
}

.sp-template-event-blocks .sp-event-block:hover {
    border-left-color: var(--k-primary, #e62117);
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Time & Result in small blocks */
.sp-template-event-blocks time,
.sp-event-blocks .sp-result {
    color: var(--k-primary, #e62117) !important;
    font-size: 1.2rem;
}

/* --------------------------------------------------------------------------
   3. Single Match / Event - Hero Banner (El problema del detalle cortado)
   -------------------------------------------------------------------------- */
/* Reset the specific event logos table to Flexbox to act as a proper Hero */
.sportspress table.sp-event-logos {
    display: block !important;
    width: 100% !important;
    background: var(--k-surface-2, #1c1b1b) !important;
    padding: 40px 20px !important;
    border-radius: 0;
    border: 1px solid var(--k-surface-3, #2a2a2a) !important;
    border-top: 5px solid var(--k-primary, #990000) !important;
    margin: 20px auto 40px auto !important;
    box-sizing: border-box;
}

.sportspress table.sp-event-logos tbody {
    display: block !important;
    width: 100% !important;
}

.sportspress table.sp-event-logos tr {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: stretch !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
}

/* 3 Equal columns for: Logo 1 | Result | Logo 2 */
.sportspress table.sp-event-logos td {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 33.33% !important;
    border: none !important;
    padding: 0 10px !important;
    background: transparent !important;
    white-space: normal !important;
}

/* Result box in the middle */
.sportspress table.sp-event-logos td.sp-event-results {
    width: 33.33% !important;
    color: #ffffff !important; /* Force all text to white */
}

.sportspress table.sp-event-logos td.sp-event-results .sp-result,
.sportspress table.sp-event-logos td.sp-event-results h5.sp-result {
    display: inline-block !important;
    font-size: 3rem !important;
    font-weight: 900 !important;
    color: var(--k-surface-1, #131313) !important;
    background: var(--k-kinetic-pink, #ffb4a8) !important;
    padding: 10px 30px !important;
    border-radius: 0 !important;
    line-height: 1 !important;
    margin-bottom: 15px !important;
    margin-top: 15px !important;
}

.sportspress table.sp-event-logos td.sp-event-results time,
.sportspress table.sp-event-logos td.sp-event-results a {
    font-size: 1.1rem !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    display: block !important;
    margin-top: 5px;
}

/* Team Logos & Names */
.sportspress table.sp-event-logos img {
    max-width: 120px !important;
    height: auto !important;
    filter: drop-shadow(0px 8px 16px rgba(0,0,0,0.5)) !important;
    margin-bottom: 10px !important;
}

.sportspress table.sp-event-logos td.sp-event-logo a,
.sportspress table.sp-event-logos td.sp-event-logo > a {
    font-family: var(--k-font-display, 'Space Grotesk', sans-serif) !important;
    font-size: 1.6rem !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    color: #ffffff !important;
    text-align: center !important;
    word-break: break-word !important;
    white-space: normal !important;
    line-height: 1.2 !important;
    display: block !important; /* Ensure it behaves smoothly if it is wrapped in breaks */
}

/* --------------------------------------------------------------------------
   4. Force Framework Layout Container (Content Centering)
   -------------------------------------------------------------------------- */
#k-app-wrapper.k-elementor-fw-grid #k-main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Media Query for Mobile Hero Match */
@media screen and (max-width: 768px) {
    .sportspress table.sp-event-logos tr {
        flex-direction: column !important;
        gap: 30px !important;
    }
    
    .sportspress table.sp-event-logos td {
        width: 100% !important;
    }

    .sportspress table.sp-event-logos td.sp-event-results {
        order: -1 !important; /* Move result/time to top on mobile */
    }
}

/* ==========================================================================
   5. SINGLE MATCH BRUTALIST OVERRIDES (FORCING ALL TEMPLATES)
   ========================================================================== */
.single-sp_event .sp-template-event-logos table,
.single-sp_event .sp-template-event-details,
.single-sp_event .sp-template-event-blocks .sp-event-block,
.single-sp_event .sp-event-blocks {
    background: var(--k-surface-2, #1c1b1b) !important;
    border: 1px solid var(--k-surface-3, #2a2a2a) !important;
    border-top: 5px solid var(--k-primary, #990000) !important;
    border-radius: 0 !important;
}

/* Forzar color blanco a la fecha, links y cualquier texto del header */
.single-sp_event .sp-event-results time,
.single-sp_event .sp-event-results a,
.single-sp_event .sp-event-details time,
.single-sp_event .sp-event-block time,
.single-sp_event .sp-event-block a,
.single-sp_event .sp-event-date time {
    color: #ffffff !important;
    font-family: var(--k-font-display, 'Space Grotesk', sans-serif) !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
}

/* Nombres de los clubes en header: Uppercase & 900 weight */
.single-sp_event .sp-event-logo a,
.single-sp_event .sp-event-logo > a,
.single-sp_event h4.sp-event-title a,
.single-sp_event .sp-team-name a {
    font-family: var(--k-font-display, 'Space Grotesk', sans-serif) !important;
    font-size: 1.6rem !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    color: #ffffff !important;
    text-align: center !important;
}

/* Hacer que el resultado principal resalte con el color Pink */
.single-sp_event .sp-result,
.single-sp_event h5.sp-result,
.single-sp_event .sp-event-results .sp-result {
    display: inline-block !important;
    font-size: 3rem !important;
    font-weight: 900 !important;
    color: var(--k-surface-1, #131313) !important;
    background: var(--k-kinetic-pink, #ffb4a8) !important;
    padding: 10px 30px !important;
    border-radius: 0 !important;
    line-height: 1 !important;
}

/* Centrar nombres de los clubes en encabezados de tabla (incidencias) */
.single-sp_event table.sp-event-performance th,
.single-sp_event table.sp-event-performance th.data-name {
    text-align: center !important;
}

/* Centrar títulos faltantes (h3, h4, caption) en todas estas secciones */
.single-sp_event .sp-template h3,
.single-sp_event .sp-template h4,
.single-sp_event h4,
.single-sp_event h4.sp-table-caption,
.single-sp_event h3.sp-table-caption {
    text-align: center !important;
    text-transform: uppercase;
    font-family: var(--k-font-display, 'Space Grotesk', sans-serif) !important;
    width: 100% !important;
    display: block !important;
    margin-bottom: 20px !important;
}

/* Recuadro sutil para las Incidencias y listas inferiores */
.single-sp_event .sp-template-event-performance,
.single-sp_event .sp-template-event-timeline,
.single-sp_event .sp-template-event-lists {
    background: var(--k-surface-1, #131313) !important;
    border: 1px solid var(--k-surface-3, #2a2a2a) !important;
    padding: 25px !important;
    margin-bottom: 30px !important;
}

/* ==========================================================================
   6. MOBILE VIEW OPTIMIZATIONS (No-scroll, Centered Layout)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* 1. Prevent Horizontal Scroll Systematically */
    body, html, .sportspress, .sp-template {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* 2. Tables Base Scaling - Reduce widths, paddings, and font sizes */
    .sportspress table,
    .sp-template table {
        width: 100% !important;
        table-layout: auto !important;
        word-break: break-word !important; /* Wrap long team / player names */
    }

    /* Extreme padding reduction to fit 7-8 columns (GD, Pts, etc.) */
    .sportspress th,
    .sp-template th {
        font-size: 0.65rem !important; /* Smaller header text */
        padding: 6px 2px !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
    }

    .sportspress td,
    .sp-template td {
        font-size: 0.75rem !important;
        padding: 8px 2px !important;
    }

    /* 3. Club column: hide text names, show only crests, left-aligned */
    .sportspress th.data-name,
    .sp-template th.data-name {
        text-align: left !important;
    }

    .sportspress td.data-name,
    .sp-template td.data-name {
        text-align: left !important;
        font-size: 0 !important;       /* Hides the bare text-node (team name) */
        line-height: 0 !important;      /* Collapse any residual line-height */
    }

    /* Keep logo visible at proper size */
    .sportspress td.data-name .team-logo,
    .sp-template td.data-name .team-logo {
        font-size: 1rem !important;     /* Restore font context for children */
        line-height: normal !important;
        display: inline-block !important;
        vertical-align: middle !important;
    }

    /* 4. Adjust Logos Inside Tables */
    .sportspress td.data-name img,
    .sp-template td.data-name img {
        display: inline-block !important;
        margin: 0 !important;
        max-width: 24px !important;     /* Compact size for mobile */
        height: auto !important;
        vertical-align: middle !important;
    }

    /* Hide any anchor-wrapped team name text too */
    .sportspress td.data-name > a,
    .sp-template td.data-name > a {
        font-size: 0 !important;
        line-height: 0 !important;
    }

    .sportspress td.data-name > a .team-logo,
    .sp-template td.data-name > a .team-logo {
        font-size: 1rem !important;
        line-height: normal !important;
    }

    /* 4.5 Restore player names in single event boxscores */
    .sportspress table.sp-event-performance td.data-name,
    .sp-template table.sp-event-performance td.data-name,
    .sportspress table.sp-event-performance td.data-name > a,
    .sp-template table.sp-event-performance td.data-name > a {
        font-size: 0.75rem !important;
        line-height: normal !important;
    }

    /* 5. Emphasize Points slightly but keep sizes manageable */
    .sportspress td.data-pts {
        font-size: 0.85rem !important;
    }

    /* 6. Reduce rank/position column space */
    .sportspress th.data-rank,
    .sportspress td.data-rank {
        padding: 8px 1px !important;
        font-size: 0.7rem !important;
        width: 1% !important; /* Forces it to be as small as possible */
    }
}
