/* ==========================================================================
   ROSTER.CSS - Mobile card layout for roster table (view_roster.jsp)
   At 768px and below: hide thead, present each row as a card with data-label.
   ========================================================================== */

/* Search filter: label and input on same row, input fills remaining width (all viewports) */
.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
    margin: 0;
}

.dataTables_wrapper .dataTables_filter input {
    flex: 1;
    min-width: 0;
}

/* Page title: widget-header style (primary bg, white text, roster page only) */
.roster-page .tn-page-header {
    background-color: var(--site-primary);
    color: var(--color-text-on-primary);
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 8px;
}

.roster-page .tn-page-title {
    font-size: 1.75em;
    margin: 0;
    color: var(--color-text-on-primary);
    line-height: 1.25;
}

/* Collapse photo column to exactly content width so other columns get more room */
th.roster-thumb-col,
td.roster-thumb {
    width: 1px;
    white-space: nowrap;
}

.roster-thumb img { 
    width: 75px;
    height: 75px;
}

/* Portal tracker: narrow Pos and Height/Weight so Status fits on fewer lines */
.roster-page--portal table#roster th.roster-col-pos,
.roster-page--portal table#roster td[data-label="Pos"],
.dataTables_wrapper .roster-page--portal table#roster th.roster-col-pos,
.dataTables_wrapper .roster-page--portal table#roster td[data-label="Pos"] {
    width: 48px;
    max-width: 48px;
    box-sizing: border-box;
}
.roster-page--portal table#roster th.roster-col-hw,
.roster-page--portal table#roster td[data-label="Height / Weight"],
.dataTables_wrapper .roster-page--portal table#roster th.roster-col-hw,
.dataTables_wrapper .roster-page--portal table#roster td[data-label="Height / Weight"] {
    width: 85px;
    max-width: 85px;
    box-sizing: border-box;
}
.roster-page--portal table#roster td[data-label="Status"],
.dataTables_wrapper .roster-page--portal table#roster td[data-label="Status"] {
    white-space: nowrap;
}
.roster-page--portal table#roster td[data-label="Status"] .material-icons,
.dataTables_wrapper .roster-page--portal table#roster td[data-label="Status"] .material-icons {
    vertical-align: middle;
    line-height: 1;
}

/* Desktop: table stays as-is. */

/* Dark mode: page header and mobile card header bars — rich dark gradient instead of flat orange */
html.dark-mode .roster-page .tn-page-header,
html.dark-mode .roster-table-container table#roster tbody td[data-label="#"],
html.dark-mode .dataTables_wrapper table#roster tbody td[data-label="#"],
html.dark-mode .roster-table-container table#roster tbody td.player-name,
html.dark-mode .dataTables_wrapper table#roster tbody td.player-name {
    background: var(--dm-premium-bg) !important;
}

/* ==========================================================================
   RESPONSIVE: mobile (≤768px) — card layout, no sort headers
   ========================================================================== */
@media (max-width: 768px) {
    .roster-page .tn-page-header {
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    .roster-page .tn-page-title {
        font-size: 1.35em;
    }

    .roster-table-container table#roster thead,
    .dataTables_wrapper table#roster thead {
        display: none !important;
    }

    /* Search filter: full width of toolbar on mobile */
    .dataTables_wrapper .dataTables_filter {
        width: 100%;
        float: none;
        text-align: left;
        margin-bottom: 10px;
    }

    .roster-table-container,
    .dataTables_wrapper {
        padding: 8px;
        background-color: var(--color-bg-light);
    }

    /* === Card: CSS Grid — col1 = # only (narrow), col2 = headshot, col3 = name/data === */
    .roster-table-container table#roster tbody tr,
    .dataTables_wrapper table#roster tbody tr {
        display: grid;
        grid-template-columns: auto 135px 1fr;
        background-color: var(--color-bg-surface);
        border: 1px solid var(--color-border);
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        margin-bottom: 12px;
        overflow: hidden;
    }

    .roster-table-container table#roster tbody tr:last-child,
    .dataTables_wrapper table#roster tbody tr:last-child {
        margin-bottom: 0;
    }

    /* Base td reset */
    .roster-table-container table#roster tbody td,
    .dataTables_wrapper table#roster tbody td {
        display: block;
        padding: 3px 12px;
        border: none;
        background: none !important;
    }

    /* --- Header bar: jersey # + player name (widget-header style) --- */
    .roster-table-container table#roster tbody td[data-label="#"],
    .dataTables_wrapper table#roster tbody td[data-label="#"] {
        grid-column: 1;
        grid-row: 1;
        background: var(--site-primary) !important;
        color: var(--color-text-on-primary);
        padding: 8px 0 8px 12px;
        display: flex;
        align-items: center;
        font-weight: 700;
        font-size: 16px;
        white-space: nowrap;
        width: auto !important;
        height: auto !important;
    }

    .roster-table-container table#roster tbody td.player-name,
    .dataTables_wrapper table#roster tbody td.player-name {
        grid-column: 2 / -1;
        grid-row: 1;
        background: var(--site-primary) !important;
        color: var(--color-text-on-primary);
        padding: 8px 12px 8px 4px;
        font-weight: 600;
        display: flex;
        align-items: center;
        min-width: 0;
    }

    /* Gymnastics rows have no "#" cell; keep name bar full-width and place Pos in data column */
    .roster-page--gymnastics .roster-table-container table#roster tbody td.player-name,
    .roster-page--gymnastics .dataTables_wrapper table#roster tbody td.player-name {
        grid-column: 1 / -1;
        padding-left: 12px;
    }

    .roster-page--gymnastics .roster-table-container table#roster tbody td:nth-child(3),
    .roster-page--gymnastics .dataTables_wrapper table#roster tbody td:nth-child(3) {
        grid-column: 3;
        grid-row: 2;
        padding-top: 8px;
    }

    /* Fallback for environments missing roster-page--gymnastics class (e.g., JSP not yet deployed) */
    .roster-table-container table#roster tbody tr > td.roster-thumb + td.player-name,
    .dataTables_wrapper table#roster tbody tr > td.roster-thumb + td.player-name {
        grid-column: 1 / -1;
        padding-left: 12px;
    }

    .roster-table-container table#roster tbody tr > td.roster-thumb + td.player-name + td[data-label="Pos"],
    .dataTables_wrapper table#roster tbody tr > td.roster-thumb + td.player-name + td[data-label="Pos"] {
        grid-column: 3;
        grid-row: 2;
        padding-top: 8px;
    }

    /* White text for links and spans inside header bar */
    .roster-table-container table#roster tbody td.player-name a,
    .roster-table-container table#roster tbody td.player-name span,
    .dataTables_wrapper table#roster tbody td.player-name a,
    .dataTables_wrapper table#roster tbody td.player-name span {
        color: var(--color-text-on-primary) !important;
    }

    /* --- Headshot: middle column, spans all data rows, left-justified --- */
    .roster-table-container table#roster tbody td.roster-thumb,
    .dataTables_wrapper table#roster tbody td.roster-thumb {
        grid-column: 2;
        grid-row: 2 / span 10;
        padding: 10px;
        max-width: none;
        width: auto;
        border-right: 1px solid var(--color-border-light);
        align-self: start;
        justify-self: start;
        text-align: left;
    }

    .roster-table-container table#roster tbody td.roster-thumb img,
    .dataTables_wrapper table#roster tbody td.roster-thumb img {
        width: 115px !important;
        min-width: 115px;
        height: auto !important;
        display: block;
        margin-right: auto;
        border-radius: 6px;
    }

    /* --- Data fields: right column, no labels --- */
    .roster-table-container table#roster tbody td:nth-child(n+4),
    .dataTables_wrapper table#roster tbody td:nth-child(n+4) {
        grid-column: 3;
        padding: 3px 12px;
    }

    /* First data field: breathing room below header */
    .roster-table-container table#roster tbody td:nth-child(4),
    .dataTables_wrapper table#roster tbody td:nth-child(4) {
        padding-top: 8px;
    }

    /* Last field: bottom padding */
    .roster-table-container table#roster tbody td:last-child,
    .dataTables_wrapper table#roster tbody td:last-child {
        padding-bottom: 10px;
    }

    /* --- Remove ALL data-label prefixes on mobile --- */
    .roster-table-container table#roster tbody td[data-label]::before,
    .dataTables_wrapper table#roster tbody td[data-label]::before {
        content: none !important;
    }

    /* Restore "#" prefix in header bar (white text) */
    .roster-table-container table#roster tbody td[data-label="#"]::before,
    .dataTables_wrapper table#roster tbody td[data-label="#"]::before {
        content: attr(data-label) !important;
        margin-right: 0;
        font-weight: 700;
        color: var(--color-text-on-primary);
    }

    /* No pseudo on headshot */
    .roster-table-container table#roster tbody td.roster-thumb::before,
    .dataTables_wrapper table#roster tbody td.roster-thumb::before {
        content: none !important;
    }

    /* No "Name:" label */
    .roster-table-container table#roster tbody td.player-name::before,
    .dataTables_wrapper table#roster tbody td.player-name::before {
        content: none !important;
    }
}
