:root {
    --primary-color: #0077be;
    --secondary-color: #00a8e8;
    --accent-color: #f7b538;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333;
    --text-secondary: #666;
    --border-radius: 12px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.container {
    max-width: 95%;
    /* Wider layout */
    margin: 0 auto;
    padding: 0 20px;
}

.brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    height: 50px;
    width: auto;
}

.brand h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2.5rem 20px;
    text-align: center;
    border-radius: 0 0 50% 50% / 20px;
    margin-bottom: 2rem;
}

.hero h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Section Titles */
.section-title {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    border-left: 5px solid var(--accent-color);
    padding-left: 10px;
}

/* Top Events (Cards) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 3rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.card-image {
    width: 100%;
    height: 150px;
    background-color: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.card-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
}

.btn-pill {
    display: inline-block;
    padding: 5px 15px;
    background-color: var(--accent-color);
    color: #fff;
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none;
    font-weight: bold;
    align-self: flex-start;
    margin-top: auto;
}

/* List View (Table Grid) */
.list-grid-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

.tournament-table {
    width: 100%;
    border-collapse: collapse;
}

.tournament-table th,
.tournament-table td {
    padding: 20px 25px;
    /* Larger padding */
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 1.1rem;
    /* Larger font */
}

.tournament-table th {
    background-color: #f9f9f9;
    color: var(--secondary-color);
    font-weight: 600;
}

.tournament-table tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.tournament-table tr:hover {
    background-color: #f0f7fb;
}

.tournament-table td i {
    color: var(--accent-color);
    margin-right: 5px;
}


/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 2rem;
}

.btn {
    padding: 8px 20px;
    background-color: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:hover,
.btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* Modal/Detailed View */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    width: 95%;
    /* Wider on mobile */
    max-width: 1400px;
    height: 90vh;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}

.btn-refresh {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
    transform: rotate(180deg);
}

.btn-refresh:active {
    transform: rotate(180deg) scale(0.95);
}


.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f9f9f9;
}

/* Accordion Styles */
.accordion-item {
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.accordion-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background-color: #fff;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background-color: #f0f7fb;
}

.accordion-header.active {
    background-color: #e3f2fd;
    border-bottom: 1px solid #bbdefb;
}

.accordion-title {
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    gap: 15px;
    align-items: center;
}

.accordion-icon {
    transition: transform 0.3s;
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    padding: 0;
}

.accordion-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Results Table inside Accordion */
.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th,
.results-table td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.results-table th {
    background-color: #fafafa;
    color: #666;
    font-weight: 600;
}

.results-table tr:last-child td {
    border-bottom: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .accordion-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    /* Mobile Table Scroll */
    .accordion-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
    }

    .results-table {
        min-width: 600px;
        /* Force minimum width to trigger scroll if needed */
    }

    .results-table th,
    .results-table td {
        padding: 10px;
        /* Reduce padding on mobile */
        font-size: 0.85rem;
    }
}

/* Result Details Styles */
.swimmer-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.swimmer-row:hover {
    background-color: #f1f8ff;
}

.diff-improve {
    color: #28a745;
    /* Green */
    font-weight: 600;
}

.diff-worse {
    color: #dc3545;
    /* Red */
    font-weight: 600;
}

.diff-neutral {
    color: #6c757d;
}

.partials-row {
    display: none;
    background-color: #f8f9fa;
}

.partials-row.active {
    display: table-row;
}

.partials-container {
    padding: 15px;
    border-top: 2px dashed #e9ecef;
}

.partials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.partial-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.partial-label {
    font-size: 0.75rem;
    color: #6c757d;
    display: block;
    margin-bottom: 2px;
}

.partial-value {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}