/* Adapted from Next.js styling for Socca League Table */

.liga-table-wrapper {
    width: 100%;
    max-width: 1240px;
    margin: 20px auto 40px;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0 16px;
    font-family: 'Jost', sans-serif;
    color: #fff;
}

/* GLOBAL RESET FOR THIS COMPONENT */
.liga-table-wrapper * {
    box-sizing: border-box;
}

.liga-table-title {
    color: #fff;
    font-size: 40px;
    font-weight: 800;
    line-height: 1.2;
    margin: 0;
}

/* Header row with subtitle and datepicker */
.liga-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.liga-table-subtitle {
    color: #b7aadf;
}

.liga-season-select {
    flex-shrink: 0;
}

.liga-select-shell {
    position: relative;
    width: 100%;
    max-width: 283px;
    min-height: 46px;
    background: #231c3d;
    border: 1px solid #6f58cf;
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(139, 116, 241, 0.15) inset;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.liga-select-icon {
    color: #b9a8ff;
    pointer-events: none;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding-left: 12px;
}

.liga-select-shell::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #b9a8ff;
    border-bottom: 2px solid #b9a8ff;
    transform: translateY(-62%) rotate(45deg);
    pointer-events: none;
    z-index: 2;
}

.liga-select {
    background: transparent;
    color: #f5f7ff;
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    height: 46px;
    padding: 0 3em 0 0.5em;
    border: 0;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    font-family: 'Jost', sans-serif;
    min-width: 0;
}

.liga-select:hover,
.liga-select:focus {
    background: rgba(139, 116, 241, 0.12);
}

.liga-select option {
    background: #231c3d;
    color: #f5f7ff;
}

/* Mobile Dual Tabs: Full / Form - STYLED LIKE TEAMSTAT TABS */
.liga-table-tabs {
    display: none;
    gap: 0;
    background: #67708a;
    border-radius: 6px;
    padding: 4px;
}

.liga-tab-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: #f4f6fb;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.liga-tab-btn.active {
    background: #8650f0;
    color: #fff;
}

.liga-tab-btn:hover:not(.active) {
    color: #fff;
}

/* Table Container (Next.js Card Style - Aligned to #302c54) */
.liga-table-scroll {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #302c54; /* white-25 */
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    margin-top: 6px;
}

/* Layout Structure */
.liga-table-head,
.liga-table-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 800px; /* Increased min-width to prevent squashing */
}

.liga-table-head {
    color: #d0d5dd; /* Next.js gray-500 */
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    padding: 8px 12px;
    border-bottom: 0;
    background: transparent;
    margin-bottom: 4px;
}

.liga-table-row {
    padding: 10px 16px;
    border-bottom: 0;
    color: #eaecf0; /* Next.js gray-600 */
    background: #302c54; /* white-25 */
    border-radius: 6px;
    margin-bottom: 4px;
    border-left: 3px solid transparent;
}

/* --- STRIPING (Next.js Pattern) --- */
.liga-table-row:nth-child(odd) {
    background: #2b2149; /* gray-100-background */
}

.liga-table-row.promoted {
    border-left-color: #39d68d;
}

/* --- LEFT SECTION (Rank + Team) --- */
.liga-table-head .left,
.liga-table-row .left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

/* Rank Column */
.liga-table-head .left .data:first-child,
.liga-table-row .left .data:first-child {
    width: 40px;
    min-width: 40px;
    flex-shrink: 0;
    justify-content: flex-start;
    font-size: 16px;
    font-weight: 700;
}
.liga-table-head .left .data:first-child { color: #d0d5dd; font-size: 13px; font-weight: 600; }

/* Team Column Wrapper */
.liga-table-head .data.imageHeader,
.liga-table-row .data.col-team {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.col-team {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #eaecf0;
    font-size: 15px;
    font-weight: 600;
}

.col-team .imageWrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.col-team .image {
    min-width: 42px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 999px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
}

.col-team .image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.team-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
    font-weight: 600;
}

/* --- RIGHT SECTION (Stats) --- */
.liga-table-head .right,
.liga-table-row .right {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 0 0 auto;
}

.liga-table-head .right .data,
.liga-table-row .right .data {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 48px;
    min-width: 48px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

.liga-table-row .right .data.bold {
    font-weight: 700;
    color: #fff;
    font-size: 15px;
}

.liga-table-head .right .data {
    font-size: 12px;
    font-weight: 600;
    color: #d0d5dd;
}

/* Matches / Last 5 Column */
.liga-table-head .right .data.last,
.liga-table-row .right .data.matches {
    width: 132px;
    min-width: 132px;
    gap: 8px;
}

.data.matches .icon {
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.data.matches svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: block;
}

/* Legend */
.liga-table-legend {
    display: flex;
    justify-content: flex-start;
    gap: 40px;
    padding: 0 4px;
}

.liga-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.liga-legend-box {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.liga-legend-green { background-color: #39d68d; }
.liga-legend-red   { background-color: #d7263d; }

.liga-legend-text {
    color: #98a2b3;
    font-size: 12px;
    font-weight: 400;
}


/* --- TOGGLE LOGIC (Full vs Form) --- */

/* Desktop: Show everything */
@media (min-width: 1025px) {
    .liga-table-head .right .data.matches,
    .liga-table-head .right .data.last,
    .liga-table-row .right .data.matches {
        display: flex !important;
    }
}

@media (max-width: 1300px) {
    .liga-table-wrapper {
        padding: 0 12px;
    }
}

@media (max-width: 1024px) {
    .liga-table-wrapper {
        margin: 12px auto 28px;
    }

    .liga-table-title {
        font-size: 30px;
    }

    .liga-table-subtitle {
        font-size: 16px;
    }

    .liga-table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .liga-season-select { width: 100%; }
    .liga-select-shell { max-width: none; width: 100%; }

    .liga-table-tabs {
        display: flex;
    }

    /* Mobile Reset: Remove min-width to allow shrinking */
    .liga-table-head,
    .liga-table-row {
        min-width: 0;
    }

    /* Mobile Typography & Sizing */
    .liga-table-row .data,
    .liga-table-head .data {
        font-size: 11px;
    }

    /* Cosy columns in full mode */
    .liga-table-head .right .data,
    .liga-table-row .right .data {
        width: 26px;
        min-width: 26px;
    }

    /* Left section: tighter gap between rank and team */
    .liga-table-head .left,
    .liga-table-row .left {
        gap: 4px;
    }

    /* Smaller rank column — wide enough for header text "Rank" */
    .liga-table-row .left .data:first-child,
    .liga-table-head .left .data:first-child {
        width: 36px;
        min-width: 36px;
        font-size: 12px;
    }

    /* Team column */
    .col-team {
        gap: 0;
        font-size: 12px;
    }

    .col-team .imageWrapper {
        gap: 6px;
    }

    .col-team .image {
        min-width: 22px;
        width: 22px;
        height: 22px;
    }

    /* Single-line team name */
    .team-name,
    .col-team .imageWrapper p {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 110px;
    }

    /* Matches Column on Mobile */
    .liga-table-head .right .data.last, 
    .liga-table-row .right .data.matches {
        width: 100px;
        min-width: 100px;
    }

    .data.matches .icon {
        min-width: 16px;
        height: 16px;
    }

    .data.matches svg {
        width: 16px;
        height: 16px;
    }

    /* FORM MODE: Hide standard stats, show Matches (Last 5) */
    .liga-table-head.form-mode .right .data:not(.last),
    .liga-table-row.form-mode .right .data:not(.matches) {
        display: none !important;
    }
    
    .liga-table-head.form-mode .right .data.last,
    .liga-table-row.form-mode .right .data.matches {
        display: flex !important;
        justify-content: flex-end;
    }

    /* FULL MODE: Show standard stats, hide Matches (Last 5) */
    .liga-table-head.full-mode .right .data.last,
    .liga-table-row.full-mode .right .data.matches {
        display: none !important;
    }
    
    .liga-table-head.full-mode .right .data:not(.last),
    .liga-table-row.full-mode .right .data:not(.matches) {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    .liga-table-wrapper {
        margin: 12px auto 30px;
        padding: 0 8px;
    }

    .liga-table-title {
        font-size: 24px;
    }

    .liga-table-row {
        padding: 8px 6px;
    }

    .liga-table-head .right .data.last, 
    .liga-table-row .right .data.matches {
        width: 80px;
        min-width: 80px;
        gap: 4px;
    }
}
