/* ========================================
   GLOBAL STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
}

/* ========================================
   HEADER SECTION
   ======================================== */
header {
    background-color: #284734;
    color: white;
    padding: 30px 0;
    margin-bottom: 30px;
}

header .container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.banner-logo {
    height: 80px;
    width: auto;
}

header h1 {
    color: white;
    margin-bottom: 10px;
    text-align: center;
}

.subtitle {
    text-align: leftr;
    color: rgba(255,255,255,0.9);
    font-size: 18px;
}

/* ========================================
   MAIN CONTAINER
   ======================================== */
.container {
    max-width: 90%;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========================================
   TAB NAVIGATION
   ======================================== */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #ddd;
}

.tab-button {
    background-color: #284734;
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
    margin-right: 10px;
}

.tab-button:hover {
    background-color: #1a2e21;
}

.tab-button.active {
    background-color: #1a2e21;
}

/* ========================================
   EVENTS SECTION
   ======================================== */
#eventsContainer {
    width: 100%;
    margin-top: 20px;
}

.event-card {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.event-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.event-card h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

.event-card p {
    color: #666;
    margin-bottom: 10px;
}

.event-card button {
    background-color: #284734;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: background-color 0.3s;
}

.event-card button:hover {
    background-color: #284734;
}

/* ========================================
   EVENT RESULTS / DETAILS VIEW
   ======================================== */
.results-container {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.back-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 20px;
    font-size: 14px;
}

.back-button:hover {
    background-color: #5a6268;
}

.category-results {
    margin-bottom: 30px;
}

.category-results h3 {
    color: #284734;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #284734;
}

/* ========================================
   RIDER SEARCH SECTION
   ======================================== */
.search-container {
    position: relative;
    margin-bottom: 30px;
}

.search-box {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.search-box:focus {
    outline: none;
    border-color: #284734;
}

#riderDropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.dropdown-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

#riderResults {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* ========================================
   FILTER CONTROLS
   ======================================== */
.filter-container {
    margin-bottom: 15px;
    background-color: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filter-container label {
    font-weight: bold;
    margin-right: 10px;
}

.filter-container select {
    padding: 5px 10px;
    font-size: 14px;
}

#eventTypeFilter {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* ========================================
   TABLES - GENERAL STYLES
   ======================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #284734;
    color: white;
    font-weight: bold;
}

tr:hover {
    background-color: #f5f5f5;
}

table td button {
    background-color: #284734;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

table td button:hover {
    background-color: #284734;
}

/* ========================================
   EVENTS TABLE - COLUMN WIDTHS
   ======================================== */
/* Specific column widths for events table */
#eventsContainer table th:nth-child(1),
#eventsContainer table td:nth-child(1) {
    width: 7%; /* Event Type */
}

#eventsContainer table th:nth-child(2),
#eventsContainer table td:nth-child(2) {
    width: 13%; /* Date */
}

#eventsContainer table th:nth-child(3),
#eventsContainer table td:nth-child(3) {
    width: 28%; /* Event Name - reduced */
}

#eventsContainer table th:nth-child(4),
#eventsContainer table td:nth-child(4) {
    width: 22%; /* Location */
}

#eventsContainer table th:nth-child(5),
#eventsContainer table td:nth-child(5) {
    width: 15%; /* Host - increased */
}

#eventsContainer table th:nth-child(6),
#eventsContainer table td:nth-child(6) {
    width: 12%; /* Results */
    text-align: center;
}

/* ========================================
   FILTER CONTAINER - REDUCE LABEL SPACING
   ======================================== */
.filter-container label {
    margin-right: 0px; /* Reduce space between label text and dropdown */
}

.filter-container select {
    margin-right: 0px; /* Space after each dropdown before next label */
}

/* ========================================
   EVENT DETAILS PAGE - OVERRIDE TABLE WIDTHS
   ======================================== */
/* Reset table widths when inside results-container (event details view) */
.results-container table th,
.results-container table td {
    width: auto !important; /* Override the events table widths */
}

/* Ensure category breakdown tables use their own widths */
.results-container .category-table-4col th:nth-child(1),
.results-container .category-table-4col td:nth-child(1) {
    width: 40% !important;
}

.results-container .category-table-4col th:nth-child(2),
.results-container .category-table-4col td:nth-child(2) {
    width: 10% !important;
    text-align: center;
}

.results-container .category-table-4col th:nth-child(3),
.results-container .category-table-4col td:nth-child(3) {
    width: 40% !important;
}

.results-container .category-table-4col th:nth-child(4),
.results-container .category-table-4col td:nth-child(4) {
    width: 10% !important;
    text-align: center;
}



/* ========================================
   RIDER RESULTS TABLE - COLUMN WIDTHS
   ======================================== */
#riderResults table th:nth-child(1),
#riderResults table td:nth-child(1) {
    width: 120px; /* Date */
}

#riderResults table th:nth-child(2),
#riderResults table td:nth-child(2) {
    width: 260px; /* Event */
}

#riderResults table th:nth-child(3),
#riderResults table td:nth-child(3) {
    width: 10px; /* Type */
}

#riderResults table th:nth-child(4),
#riderResults table td:nth-child(4) {
    width: 200px; /* Location */
}

#riderResults table th:nth-child(5),
#riderResults table td:nth-child(5) {
    width: 100px; /* Category */
    text-align: left;
}

#riderResults table th:nth-child(6),
#riderResults table td:nth-child(6) {
    width: 50px; /* Position */
}

#riderResults table th:nth-child(7),
#riderResults table td:nth-child(7) {
    width: 50px; /* Finishers */
}

.ulster-champion {
    font-weight: bold;
    color: #2c5f2d;
    margin: 5px 0;
    font-size: 1.05em;
}


/* ========================================
   EVENT STATS TABLE - COLUMN WIDTHS
   ======================================== */
#statsContainer table th:nth-child(1),
#statsContainer table td:nth-child(1) {
    width: 30%; /* Venue */
}

#statsContainer table th:nth-child(2),
#statsContainer table td:nth-child(2) {
    width: 12%; /* Times used */
}

#statsContainer table th:nth-child(3),
#statsContainer table td:nth-child(3) {
    width: 28%; /* Attendees */
}

#statsContainer table th:nth-child(4),
#statsContainer table td:nth-child(4) {
    width: 30%; /* Years used */
}
/* ========================================
   CATEGORY BREAKDOWN TABLES (4-COLUMN)
   ======================================== */
.category-breakdown {
    margin-top: 30px;
    max-width: 800px;
}

.category-breakdown h3 {
    color: #284734;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.category-table-4col {
    width: 100%;
    max-width: 800px;
    border-collapse: collapse;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.category-table-4col th {
    background-color: #284734;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: bold;
}

.category-table-4col th:nth-child(1) {
    width: 40%;
}

.category-table-4col th:nth-child(2) {
    width: 10%;
    text-align: center;
}

.category-table-4col th:nth-child(3) {
    width: 40%;
}

.category-table-4col th:nth-child(4) {
    width: 10%;
    text-align: center;
}

.category-table-4col td {
    padding: 10px 12px;
    border-bottom: 1px solid #ddd;
}

.category-table-4col td:nth-child(1) {
    width: 40%;
}

.category-table-4col td:nth-child(3) {
    width: 40%;
}

.category-table-4col td.count-cell {
    text-align: center;
    width: 10%;
}

.category-table-4col tbody tr:hover {
    background-color: #f5f5f5;
}

.category-table-4col .totals-row {
    background-color: #f0f0f0;
    font-weight: bold;
    border-top: 2px solid #284734;
}

.category-table-4col .totals-row:hover {
    background-color: #f0f0f0 !important;
}

.category-table-4col tbody tr:last-child td {
    border-bottom: none;
}

/* ========================================
   FOOTER
   ======================================== */
footer {
    background-color: #284734;
    color: white;
    text-align: center;
    padding: 15px 0;
    margin-top: 40px;
}

footer p {
    margin: 0;
    font-size: 14px;
}

footer a {
    color: #90EE90;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ========================================
   MOBILE
   ======================================== */

/* Mobile-responsive styles */
@media screen and (max-width: 768px) {
    /* Container padding */
    .container {
        padding: 10px;
    }
    
    /* Header */
    header .container {
        flex-direction: column;
        text-align: center;
    }
    
    header h1 {
        font-size: 1.5rem;
        margin: 10px 0;
    }
    
    header .subtitle {
        font-size: 0.9rem;
    }
    
    .banner-logo {
        max-width: 150px;
        margin-bottom: 10px;
    }
    
    /* Tabs */
    .tabs {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .tab-button {
        font-size: 0.85rem;
        padding: 8px 12px;
        flex: 1 1 calc(50% - 5px); /* 2 buttons per row */
        min-width: 120px;
    }
    
    /* Filter containers */
    .filter-container {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }
    
    .filter-container label {
        margin-left: 0 !important;
        margin-top: 10px;
        display: block;
    }
    
    .filter-container select,
    .filter-container button {
        width: 100%;
        margin-left: 0 !important;
        float: none !important;
    }
    
    /* Tables */
    table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    table th,
    table td {
        padding: 8px 4px;
    }
    
    /* Hide less important columns on very small screens */
    @media screen and (max-width: 480px) {
        table th:nth-child(4),
        table td:nth-child(4) {
            display: none; /* Hide Location column */
        }
        
        table th:nth-child(5),
        table td:nth-child(5) {
            display: none; /* Hide Host column */
        }
    }
    
    /* Buttons */
    button {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .back-button {
        margin-bottom: 15px;
    }
    
    /* Results container */
    .results-container {
        padding: 10px;
    }
    
    .results-container h2 {
        font-size: 1.3rem;
    }
    
    .results-container h3 {
        font-size: 1.1rem;
    }
    
    /* Category breakdown tables */
    .category-table-4col {
        font-size: 0.8rem;
    }
    
    .category-table-4col th,
    .category-table-4col td {
        padding: 6px 3px;
    }
    
    /* Search box */
    .search-box {
        width: 100%;
        font-size: 1rem;
    }
    
    /* Dropdown */
    .dropdown-item {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    /* Stats and info boxes */
    #topAttendees div,
    #champsSummary div,
    #aboutContent div {
        padding: 10px;
    }
    
    /* Footer */
    footer {
        font-size: 0.85rem;
        padding: 15px 10px;
    }
    
    /* Ulster champion notes */
    .ulster-champion {
        font-size: 0.9rem;
    }
}

/* Tablet styles */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    .tab-button {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
    
    table {
        font-size: 0.9rem;
    }
}

/* Ensure tables don't break layout */
table {
    width: 100%;
    max-width: 100%;
}

/* Make filter container flexible */
.filter-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}


/* ========================================
   CHART CONTAINER - MOBILE RESPONSIVE
   ======================================== */

#chartContainer {
    max-width: 900px;
    margin: 20px auto 40px auto;
    position: relative;
    height: 400px; /* Changed from height to min-height */
}

#chartContainer canvas {
    max-height: 100%;
}

/* Mobile - Make charts taller */
@media screen and (max-width: 768px) {
    #chartContainer {
        height: 400px; /* Taller on mobile */
        max-width: 100%;
        margin: 20px 0;
    }
}

/* Very small screens - Even taller for readability */
@media screen and (max-width: 480px) {
    #chartContainer {
        height: 400px; /* Extra tall on small phones */
    }
}

.chart-commentary {
    margin-top: 20px;
    margin-bottom: 40px; 
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    text-align: center;
}


.discipline-btn {
    padding: 8px 16px;
    margin: 0 5px;
    border: 2px solid #284734;
    background-color: white;
    color: #284734;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.discipline-btn:hover {
    background-color: #f0f0f0;
}

.discipline-btn.active {
    background-color: #284734;
    color: white;
}

.discipline-btn-female {
    padding: 8px 16px;
    margin: 0 5px;
    border: 2px solid #8B4513;
    background-color: white;
    color: #8B4513;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.discipline-btn-female:hover {
    background-color: #f0f0f0;
}

.discipline-btn-female.active {
    background-color: #8B4513;
    color: white;
}

/* ========================================
   ULSTER CHAMPIONS - MOBILE RESPONSIVE
   ======================================== */

/* Hide columns on mobile for Ulster Champions table */
@media screen and (max-width: 768px) {
    #champsContainer table thead tr th:nth-child(1),  /* Hide Event Type */
    #champsContainer table thead tr th:nth-child(2),  /* Hide Date */
    #champsContainer table thead tr th:nth-child(3),  /* Hide Event Name */
    #champsContainer table thead tr th:nth-child(4),  /* Hide Category */
    #champsContainer table thead tr th:nth-child(7)   /* Hide Results button */
    {
        display: none;
    }
    
    #champsContainer table tbody tr td:nth-child(1),  /* Hide Event Type */
    #champsContainer table tbody tr td:nth-child(2),  /* Hide Date */
    #champsContainer table tbody tr td:nth-child(3),  /* Hide Event Name */
    #champsContainer table tbody tr td:nth-child(4),  /* Hide Category */
    #champsContainer table tbody tr td:nth-child(7)   /* Hide Results button */
    {
        display: none;
    }
    
    /* Make Year and Rider Name columns visible and full width */
    #champsContainer table thead tr th:nth-child(5),  /* Year */
    #champsContainer table thead tr th:nth-child(6)   /* Rider Name */
    {
        display: table-cell;
    }
    
    #champsContainer table tbody tr td:nth-child(5),  /* Year */
    #champsContainer table tbody tr td:nth-child(6)   /* Rider Name */
    {
        display: table-cell;
    }
    
    /* Make rows clickable - add pointer cursor */
    #champsContainer table tbody tr {
        cursor: pointer;
    }
    
    /* Optional: Add hover effect to show rows are clickable */
    #champsContainer table tbody tr:hover {
        background-color: #f0f0f0;
    }
    
    /* Hide the table initially on mobile */
    #champsContainer table {
        display: none;
    }
    
    /* Show table when it has the 'visible' class */
    #champsContainer table.visible {
        display: table;
    }
    
    /* Style the View Riders button */
    #viewRidersBtn {
        background-color: #284734;
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 4px;
        cursor: pointer;
        font-size: 16px;
        margin-top: 10px;
        width: 100%;
    }
    
    #viewRidersBtn:disabled {
        background-color: #ccc;
        cursor: not-allowed;
    }
}

/* ========================================
   RIVALS SECTION - SEARCH BOXES
   ======================================== */

#rivalsSection .filter-container {
    background-color: transparent;
    padding: 0;
    box-shadow: none;
}

.rivals-search-group {
    position: relative;
    margin-bottom: 30px;
}

.rivals-search-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
    font-size: 16px;
}

#riderASearch,
#riderBSearch {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
}

#riderASearch:focus,
#riderBSearch:focus {
    outline: none;
    border-color: #284734;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.search-result-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

#selectedRiderA,
#selectedRiderB {
    margin-top: 10px;
    font-weight: bold;
    color: #2c5f2d;
    min-height: 24px;
}

#compareRidersBtn {
    background-color: #284734;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#compareRidersBtn:hover {
    background-color: #1a2e21;
}

#compareRidersBtn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#clearRidersBtn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

#clearRidersBtn:hover {
    background-color: #5a6268;
}

/* ========================================
   MAP CONTAINER
   ======================================== */

#mapContainer {
    width: 100%;
    height: 600px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.custom-marker {
    background: transparent;
    border: none;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 15px;
}

@media screen and (max-width: 768px) {
    #mapContainer {
        height: 400px;
    }
    
    #venueModal {
        width: 90% !important;
        max-width: 90% !important;
        padding: 20px !important;
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    #eventsContainer {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 14px;
    }
    
    th, td {
        padding: 8px;
    }
}