/* ==============================================
   CupResults Mobile-Responsive CSS
   Similar pattern to RaceTrax with MobileSection/NonMobileSection
   Implements 2-row-per-driver layout on mobile devices
   ============================================== */

/* Default: Desktop view */
.cup-results-mobile-section {
    display: none;
}

.cup-results-desktop-section {
    display: block;
}

/* Base table styles */
.cup-results-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    table-layout: fixed; /* Fixed layout for consistent column widths */
}

.cup-results-table th,
.cup-results-table td {
    padding: 8px 10px;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    border-left: none;
    border-right: none;
    vertical-align: middle;
}

/* Add border to first and last columns for table frame */
.cup-results-table th:first-child,
.cup-results-table td:first-child {
    border-left: 1px solid #ddd;
}

.cup-results-table th:last-child,
.cup-results-table td:last-child {
    border-right: 1px solid #ddd;
}

.cup-results-table thead {
    background-color: #f8f9fa;
    font-weight: bold;
}

.cup-results-table tbody tr:hover {
    background-color: #f1f1f1;
}

/* Car and Make cells - ensure images scale properly */
.cup-results-table .car-cell img,
.cup-results-table .make-cell img {
    max-height: 18px;
    width: auto;
    display: inline-block;
}

/* Hide LED column on both desktop and mobile */
.cup-results-table th.col-led,
.cup-results-table td.col-led {
    display: none !important;
}

/* Center headings on all screen sizes */
.cup-results-header {
    text-align: center;
    margin-bottom: 5px;
}

.cup-results-header h2 {
    margin: 5px 0;
    font-size: 36px;
    font-weight: bold;
}

/* Cup Results Logo Styling */
.cup-results-logo {
    max-width: 100%;
    height: auto;
    max-height: 80px;
    display: block;
    margin: 10px auto;
}

.cup-results-car-type {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    color: #0b49b5;
    font-weight: 800;
    font-size: 18px;
    text-align: center;
    margin: 0;
    line-height: 1;
}

.cup-results-selectors {
    text-align: center;
    margin-bottom: 10px;
    padding: 5px 10px;
}

/* Desktop-specific dropdown layout */
.cup-results-selectors-inline {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

/* Race selector wrapper - contains dropdown and filter button */
.race-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 800px;
}

/* Filter button styling */
.cup-results-filter-btn {
    height: 32px;
    min-width: 40px;
    padding: 4px 10px;
    border: 1px solid #006400;
    background-color: #fff;
    box-shadow: 0 8px 6px -6px black;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cup-results-filter-btn:hover {
    background-color: #f0f0f0;
    border-color: #004d00;
}

.cup-results-filter-btn:active {
    background-color: #e0e0e0;
    box-shadow: 0 4px 4px -4px black;
}

.cup-results-filter-btn .glyphicon {
    color: #006400;
    font-size: 14px;
}

/* Reduce dropdown height */
.cup-results-selectors .form-control {
    padding: 4px 8px;
    height: 32px;
    font-size: 14px;
}

/* MOBILE STYLES - Below 992px (matches RaceTrax breakpoint) */
@media only screen and (max-width: 991px) {
    /* Switch visibility */
    .cup-results-mobile-section {
        display: table !important;
        width: 100% !important;
    }

    .cup-results-desktop-section {
        display: none !important;
    }

    /* Adjust table for mobile */
    .cup-results-table {
        font-size: 14px;
        table-layout: fixed !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .cup-results-table th,
    .cup-results-table td {
        padding: 6px 4px;
        box-sizing: border-box;
    }

    /* Hide Make, Team, and LED columns on mobile - we'll show Make and Team in the secondary row */
    .cup-results-table th.col-make,
    .cup-results-table th.col-team,
    .cup-results-table td.col-make,
    .cup-results-table td.col-team,
    .cup-results-table th.col-led,
    .cup-results-table td.col-led {
        display: none !important;
    }

    /* Driver row - main information */
    .cup-results-table .driver-row-main {
        border-bottom: none !important;
    }

    .cup-results-table .driver-row-main td {
        padding-bottom: 4px;
        border-bottom: none;
    }

    /* Secondary row - team and make information */
    .cup-results-table .driver-row-secondary {
        background-color: #f8f9fa !important;
        border-top: none !important;
    }

    .cup-results-table .driver-row-secondary td {
        padding-top: 4px;
        padding-bottom: 8px;
        border-top: none;
        font-size: 13px;
        color: #555;
    }

    /* Blank cell under position column - very narrow */
    .cup-results-table .driver-row-secondary td.blank-cell {
        background-color: transparent;
        border-left: 1px solid #ddd;
        border-right: none;
        border-bottom: 1px solid #ddd;
        width: 5%;
        padding: 4px 2px;
    }

    /* Make badge cell - same width as Car column above */
    .cup-results-table .driver-row-secondary td.make-badge-cell {
        text-align: center;
        padding: 4px;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }

    /* Team info cell - extends across remaining columns, aligns with Driver column */
    .cup-results-table .driver-row-secondary td.team-info-cell {
        text-align: left;
        padding-left: 10px;
        border-right: 1px solid #ddd;
    }

    /* Ensure proper borders between driver groups */
    .cup-results-table .driver-row-secondary {
        border-bottom: 2px solid #ccc;
    }

    /* Adjust header text size on mobile */
    .cup-results-header h2 {
        font-size: 28px;
    }

    /* Cup Results Logo - slightly smaller on mobile */
    .cup-results-logo {
        max-height: 60px;
        margin: 5px auto;
    }

    .cup-results-car-type {
        font-size: 16px;
    }

    /* Adjust selector dropdowns for mobile */
    .cup-results-selectors .form-control {
        max-width: 100% !important;
        min-width: auto !important;
        margin-bottom: 4px;
    }

    .cup-results-selectors {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 5px 15px;
        margin-bottom: 5px;
    }

    .cup-results-selectors-inline {
        flex-direction: column;
        width: 100%;
    }

    /* Race selector wrapper in mobile - full width with button on same line */
    .race-selector-wrapper {
        width: 100%;
        max-width: 100%;
        flex-direction: row;
    }

    .race-selector-wrapper #RaceDDL_Cup {
        flex: 1;
        min-width: 0 !important;
    }

    /* Filter button in mobile view */
    .cup-results-filter-btn {
        min-width: 36px;
        padding: 4px 8px;
    }

    /* Mobile table column distribution for main row - 6 columns total (LED removed), must equal 100% */
    /* P column */
    .cup-results-table thead th:nth-child(1),
    .cup-results-table .driver-row-main td:nth-child(1) {
        width: 8%;
        text-align: center;
    }

    /* Car column */
    .cup-results-table thead th:nth-child(2),
    .cup-results-table .driver-row-main td:nth-child(2) {
        width: 12%;
        text-align: center;
    }

    /* Driver column */
    .cup-results-table thead th:nth-child(3),
    .cup-results-table .driver-row-main td:nth-child(3) {
        width: 32%;
        text-align: left;
    }

    /* Start column */
    .cup-results-table thead th:nth-child(4),
    .cup-results-table .driver-row-main td:nth-child(4) {
        width: 14%;
        text-align: center;
    }

    /* Finish column */
    .cup-results-table thead th:nth-child(5),
    .cup-results-table .driver-row-main td:nth-child(5) {
        width: 14%;
        text-align: center;
    }

    /* Behind column (LED column is hidden, so this is now 7th visible column) */
    .cup-results-table thead th:nth-child(7),
    .cup-results-table .driver-row-main td:nth-child(7) {
        width: 20%;
        text-align: center;
    }
}

/* Extra small devices - Further adjustments */
@media only screen and (max-width: 600px) {
    .cup-results-table {
        font-size: 12px;
    }

    .cup-results-table th,
    .cup-results-table td {
        padding: 4px 2px;
    }

    .cup-results-header h2 {
        font-size: 24px;
    }

    /* Cup Results Logo - even smaller on very small screens */
    .cup-results-logo {
        max-height: 50px;
        margin: 3px auto;
    }

    .cup-results-car-type {
        font-size: 14px;
    }

    /* Adjust column widths for smaller screens - 6 columns (LED removed) */
    .cup-results-table thead th:nth-child(1),
    .cup-results-table .driver-row-main td:nth-child(1) {
        width: 8%;
    }

    .cup-results-table thead th:nth-child(2),
    .cup-results-table .driver-row-main td:nth-child(2) {
        width: 13%;
    }

    .cup-results-table thead th:nth-child(3),
    .cup-results-table .driver-row-main td:nth-child(3) {
        width: 30%;
    }

    .cup-results-table thead th:nth-child(4),
    .cup-results-table .driver-row-main td:nth-child(4) {
        width: 14%;
    }

    .cup-results.table th:nth-child(5),
    .cup-results-table .driver-row-main td:nth-child(5) {
        width: 14%;
    }

    .cup-results-table thead th:nth-child(7),
    .cup-results-table .driver-row-main td:nth-child(7) {
        width: 21%;
    }
}

/* DESKTOP LAYOUT - Preserve and optimize for large screens */
@media only screen and (min-width: 992px) {
    .cup-results-desktop-section {
        display: table !important;
    }

    .cup-results-mobile-section {
        display: none !important;
    }

    /* Keep header centered but allow car type to align right on desktop */
    .cup-results-header {
        text-align: left;
    }

    .cup-results-header h2 {
        text-align: left;
    }

    /* Cup Results Logo - align left on desktop */
    .cup-results-logo {
        margin: 10px 0;
        max-height: 80px;
    }

    .cup-results-car-type {
        text-align: right;
    }

    /* Desktop table - FIXED column widths to fill 100% width */
    .cup-results-table {
        table-layout: fixed;
        width: 100%;
    }

    /* Column widths - totaling 100% to use full table width (LED column hidden, redistributed to other columns) */
    /* P column - compact */
    .cup-results-table th:nth-child(1),
    .cup-results-table td:nth-child(1) {
        width: 5%;
        text-align: center;
    }

    /* Car column - compact for image */
    .cup-results-table th:nth-child(2),
    .cup-results-table td:nth-child(2) {
        width: 8%;
        text-align: center;
    }

    /* Driver column - more space for names */
    .cup-results-table th:nth-child(3),
    .cup-results-table td:nth-child(3) {
        width: 20%;
        text-align: left;
    }

    /* Start column */
    .cup-results-table th:nth-child(4),
    .cup-results-table td:nth-child(4) {
        width: 9%;
        text-align: center;
    }

    /* Finish column */
    .cup-results-table th:nth-child(5),
    .cup-results-table td:nth-child(5) {
        width: 9%;
        text-align: center;
    }

    /* LED column is hidden (6th column) */

    /* Behind column (7th column) */
    .cup-results-table th:nth-child(7),
    .cup-results-table td:nth-child(7) {
        width: 10%;
        text-align: center;
    }

    /* Make column - for badge image (8th column) */
    .cup-results-table th:nth-child(8),
    .cup-results-table td:nth-child(8) {
        width: 10%;
        text-align: center;
    }

    /* Team column - gets remaining space (29% = 100% - sum of others) */
    .cup-results-table th:nth-child(9),
    .cup-results-table td:nth-child(9) {
        width: 29%;
        text-align: left;
        padding-left: 12px;
    }

    /* Dropdowns stay inline on desktop */
    .cup-results-selectors-inline {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    /* Ensure proper spacing and alignment */
    .cup-results-table th,
    .cup-results-table td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Driver and Team columns can wrap if needed */
    .cup-results-table th:nth-child(3),
    .cup-results-table td:nth-child(3),
    .cup-results-table th:nth-child(9),
    .cup-results-table td:nth-child(9) {
        white-space: normal;
        word-wrap: break-word;
    }
}
