/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Color Variables */
    --byu-blue: #002E5D;
    --orem-blue: #004b8c;
    --orem-gold: #fdbb31;
    --provo-green: #005a2b;
    --lonepeak-maroon: #800000;
    --lonepeak-black: #000000;
    --lonepeak-gold: #FFD700;
    --text-dark: #333;
    --text-light: #fff;
    --bg-light: #f8f9fa;
    --border-color: #dee2e6;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --success-color: #28a745;
    --transition-speed: 0.2s;
}

/* Body Styles */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.5;
    padding: 20px;
}

/* Header Styles */
header.header-container {
    max-width: 1200px;
    margin: 0 auto 2rem;
    padding: 1rem;
    text-align: center;
}

h1 {
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-size: 2rem;
}

p.description {
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

/* Navigation and Buttons */
nav {
    margin-bottom: 1.5rem;
}

.toggle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 3rem;
    height: 1.5rem;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: background-color var(--transition-speed);
    border-radius: 1.5rem;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 1rem;
    width: 1rem;
    left: 0.25rem;
    bottom: 0.25rem;
    background-color: white;
    transition: transform var(--transition-speed);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--text-dark);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(1.5rem);
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.button {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    cursor: pointer;
    border: 2px solid var(--text-dark);
    border-radius: 4px;
    background-color: white;
    transition: background-color var(--transition-speed), color var(--transition-speed), border-color var(--transition-speed);
}

.button[aria-pressed="true"],
.button.active {
    background-color: var(--text-dark);
    color: var(--text-light);
    border-color: var(--text-dark);
}

.button:hover {
    background-color: var(--text-dark);
    color: var(--text-light);
}

.search-container {
    text-align: center;
    margin-bottom: 1rem;
}

#search-input {
    width: 80%;
    max-width: 400px;
    padding: 0.5rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: border-color var(--transition-speed);
}

#search-input:focus {
    border-color: var(--text-dark);
    outline: none;
}

/* Table Styles */
.table-container {
    max-width: 100%;
    overflow-x: auto;
    margin-top: 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    background-color: white;
}

.loading-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 6px solid var(--bg-light);
    border-top: 6px solid var(--text-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 600px;
}

colgroup col:first-child { width: 15%; }
colgroup col:nth-child(2) { width: 10%; }
colgroup col:nth-child(3) { width: 20%; }
colgroup col:nth-child(4) { width: 20%; }
colgroup col:nth-child(5) { width: 15%; }
colgroup col:nth-child(6) { width: 10%; }
colgroup col:last-child { width: 10%; }

th, td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border-color);
    vertical-align: middle;
}

th {
    background-color: var(--text-dark);
    color: var(--text-light);
    font-weight: 600;
}

.sort-button {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-weight: bold;
}

.sort-button:focus {
    outline: 2px dashed var(--text-light);
    outline-offset: 4px;
}

/* Team-specific styles */
.byu {
    background-color: var(--byu-blue);
    color: var(--text-light);
}

.orem {
    background-color: var(--orem-blue);
    color: var(--orem-gold);
}

.provo {
    background-color: var(--provo-green);
    color: var(--text-light);
}

.lonepeak {
    background-color: var(--lonepeak-maroon);
    color: var(--lonepeak-gold);
}

.game-soon {
    position: relative;
}

.past-game {
    opacity: 0.7;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    color: #fff;
    border-radius: 999px;
    text-align: center;
}

.tag.home {
    background-color: var(--success-color);
}

.tag.away {
    background-color: var(--error-color);
}

.tag.neutral {
    background-color: var(--warning-color);
    color: var(--text-dark);
}

/* Position the Game Type cell relatively */
td:nth-child(7) {
    position: relative;
    padding-right: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .filter-buttons button {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: max-content;
    }

    table {
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    #search-input {
        width: 100%;
    }

    .filter-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .button {
        width: 100%;
    }
}

/* Hover Effects */
table tbody tr:hover {
    filter: brightness(1.2);
    cursor: pointer;
    transition: filter 0.3s;
}

/* Add specific hover rules for each team */
.byu:hover {
    background-color: color-mix(in srgb, var(--byu-blue) 90%, white);
}

.orem:hover {
    background-color: color-mix(in srgb, var(--orem-blue) 90%, white);
}

.provo:hover {
    background-color: color-mix(in srgb, var(--provo-green) 90%, white);
}

.lonepeak:hover {
    background-color: color-mix(in srgb, var(--lonepeak-maroon) 90%, white);
}

/* Focus Styles */
button:focus, .toggle-switch input:focus + .toggle-slider, .sort-button:focus {
    outline: 2px dashed var(--text-dark);
    outline-offset: 4px;
}
