/* Base Styles */
body {
    background-color: var(--background);
    color: var(--text);
    font-family: var(--font-family);
    line-height: var(--line-height);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* Layout */
.container {
    max-width: 1200px;
    padding: var(--spacing-lg);
}

/* Cards */
article,
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

article:hover,
.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

/* Buttons */
button,
.btn {
    background-color: var(--primary);
    color: var(--primary-inverse);
    border: none;
    border-radius: var(--border-radius-pill);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0;
}

button:hover,
.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

button:active,
.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

button.outline,
.btn.outline {
    background-color: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

button.outline:hover,
.btn.outline:hover {
    background-color: var(--primary);
    color: var(--primary-inverse);
}

button:disabled {
    background-color: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Inputs */
input,
select,
textarea {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-focus);
    outline: none;
}

/* Checkbox */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25em;
    height: 1.25em;
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: var(--surface);
    display: inline-grid;
    place-content: center;
    margin-right: 0.5em;
    cursor: pointer;
}

input[type="checkbox"]::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--primary-inverse);
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

/* Fix Input Height to match Buttons */
input,
select {
    height: 42px;
    /* Explicit height to match button */
    padding: 0 var(--spacing-md);
    /* Center text vertically */
    display: inline-flex;
    align-items: center;
}

#rating_threshold {
    height: auto;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
}

/* Modal */
dialog article {
    border-radius: var(--border-radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
    padding: 0;
    /* Reset padding for custom header/content */
}

dialog header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing-md) var(--spacing-lg);
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
}

dialog header h4 {
    margin: 0;
    color: var(--text);
}

dialog .close {
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    text-decoration: none;
    transition: color 0.2s ease;
}

dialog .close:hover {
    color: var(--text);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.stat-card {
    background-color: var(--surface-hover);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* VS Badge */
.vs-badge {
    /* background-color: var(--surface); */
    color: var(--text-muted);
    font-size: 1.5rem;
    font-weight: 800;
    /* padding: var(--spacing-md); */
    /* border-radius: 50%; */
    /* width: 80px;
    height: 80px; */
    display: flex;
    align-items: center;
    justify-content: center;
    /* box-shadow: var(--shadow); */
    /* border: 4px solid var(--background); */
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background-color: var(--surface-hover);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: var(--spacing-md);
    border-bottom: 2px solid var(--border);
}

td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--surface-hover);
}

/* Comparator Flexbox Layout */
.comparator-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.vs-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Desktop layout - horizontal with centered content */
@media (min-width: 768px) {
    .comparator-container {
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        gap: var(--spacing-sm);
    }

    .competitor-a,
    .competitor-b {
        flex: 1 1 0;
        max-width: 33%;
    }

    .vs-container {
        flex: 0 0 100px;
        max-width: 100px;
    }
}

/* VS Badge */
.score-badge {
    background-color: var(--primary);
    color: var(--primary-inverse);
    font-weight: 700;
    font-size: 1.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius);
    min-width: 40px;
    text-align: center;
}

/* Competitor Cards */
.competitor-a {
    background-color: #0057B7;
    /* Ukraine Blue */
    color: white;
    border-color: #004494;
}

.competitor-a h3 {
    color: white;
}

.competitor-b {
    background-color: #FFDD00;
    /* Ukraine Yellow */
    color: #333;
    border-color: #E6C700;
}

.competitor-b h3 {
    color: #333;
}

/* Header Margins */
.competitor-card header,
.competitor-a header,
.competitor-b header {
    margin-top: 24px;
    margin-bottom: 24px;
    padding: 0;
    /* Reset padding if needed to rely on margin */
    background: transparent;
    /* Ensure header bg doesn't block card bg */
    border-bottom: none;
    /* Remove border if it looks bad on colored bg */
    text-align: center;
    /* Center the header text */
}

/* Ensure inputs inside colored cards are readable */
.competitor-a select,
.competitor-b select {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.competitor-a small,
.competitor-b small {
    color: rgba(255, 255, 255, 0.8);
    /* Lighter text for details on blue */
}

.competitor-b small {
    color: rgba(0, 0, 0, 0.7);
    /* Darker text for details on yellow */
}

/* Link styling for competitor details */
#e1_details a {
    color: white !important;
    text-decoration: none !important;
    border-bottom: 1px dashed white;
}

#e2_details a {
    color: black !important;
    text-decoration: none !important;
    border-bottom: 1px dashed black;
}

#matchesTable {
    font-size: 14px;
}

/* Censored name styling */
.censored {
    color: #999;
}

/* Mobile Responsive Fixes */
@media (max-width: 767px) {

    /* Make controls stack vertically and take full width */
    article .card>div[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #discipline {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Ensure parent divs don't overflow */
    #discipline+div,
    article .card>div>div {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Hide percentage cards on mobile, show only pie chart */
    #visualizationRow .percentage-card {
        display: none !important;
    }

    #visualizationRow {
        grid-template-columns: 1fr !important;
    }

    /* Make pie chart container square and fill width */
    #visualizationRow .stat-card {
        aspect-ratio: 1 / 1;
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
}

#countryModal ul {
    color: #090909;
}