/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --secondary: #f9ab00;
    --success: #34a853;
    --danger: #ea4335;
    --dark: #202124;
    --gray-900: #3c4043;
    --gray-700: #5f6368;
    --gray-500: #9aa0a6;
    --gray-300: #dadce0;
    --gray-100: #f1f3f4;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font-main: 'Roboto', sans-serif;
    --font-heading: 'Oswald', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--gray-100);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== HEADER ===== */
.header {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
}

.logo-icon {
    flex-shrink: 0;
}

.site-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--dark);
}

.site-subtitle {
    font-size: 0.8rem;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    text-decoration: none;
    color: var(--gray-700);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== HERO ===== */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 40px 0;
}

.event-info h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.event-info p {
    font-size: 1rem;
    opacity: 0.9;
}

/* ===== FILTERS ===== */
.filters-section {
    margin-top: -20px;
    position: relative;
    z-index: 10;
    padding-bottom: 20px;
}

.filters-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.filters-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--gray-900);
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 16px;
    align-items: end;
}

.filter-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-main);
    transition: border-color 0.2s;
    background: var(--white);
}

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

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: end;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

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

.btn-outline:hover {
    background: var(--primary-light);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #2d9249;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #d33426;
}

/* ===== RESULTS ===== */
.results-section {
    padding: 20px 0 60px;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.results-header h3 {
    font-size: 0.95rem;
    color: var(--gray-700);
    font-weight: 400;
}

/* Desktop Table */
.table-wrapper {
    overflow-x: auto;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th {
    background: var(--gray-100);
    padding: 14px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-300);
    user-select: none;
}

.results-table th.sortable {
    cursor: pointer;
}

.results-table th.sortable:hover {
    color: var(--primary);
}

.results-table th.sort-asc::after {
    content: ' ▲';
    font-size: 0.7rem;
}

.results-table th.sort-desc::after {
    content: ' ▼';
    font-size: 0.7rem;
}

.results-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}

.results-table tbody tr:hover {
    background: var(--primary-light);
}

.results-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.results-table tbody tr:nth-child(even):hover {
    background: var(--primary-light);
}

.position-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
}

.position-1 {
    background: #ffd700;
    color: #7a6200;
}

.position-2 {
    background: #e0e0e0;
    color: #555;
}

.position-3 {
    background: #cd7f32;
    color: #fff;
}

.dorsal-badge {
    display: inline-block;
    background: var(--dark);
    color: var(--white);
    padding: 2px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
}

.category-tag {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.time-display {
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
}

.diff-display {
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* Mobile Cards */
.results-cards {
    display: none;
}

.result-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
}

.result-card .card-position {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    min-width: 40px;
}

.result-card .card-info h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.result-card .card-info .card-meta {
    font-size: 0.8rem;
    color: var(--gray-700);
}

.result-card .card-time {
    text-align: right;
}

.result-card .card-time .time {
    font-weight: 600;
    font-size: 1rem;
}

.result-card .card-time .diff {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ===== EMPTY & LOADING STATES ===== */
.empty-state, .loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-700);
}

.empty-state svg {
    color: var(--gray-500);
    margin-bottom: 16px;
}

.empty-state h4 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== FOOTER ===== */
.footer {
    background: var(--dark);
    color: var(--gray-500);
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        gap: 8px;
    }

    .site-title {
        font-size: 1.2rem;
    }

    .hero {
        padding: 30px 0;
    }

    .event-info h2 {
        font-size: 1.5rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: row;
    }

    .filter-actions .btn {
        flex: 1;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .table-wrapper {
        display: none;
    }

    .results-cards {
        display: block;
    }
}

@media (max-width: 480px) {
    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .site-title {
        font-size: 1rem;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* ===== ADMIN PAGE STYLES ===== */
.admin-section {
    padding: 40px 0;
}

.admin-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.admin-card h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--dark);
}

.admin-card p {
    color: var(--gray-700);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-main);
    transition: border-color 0.2s;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area svg {
    color: var(--gray-500);
    margin-bottom: 12px;
}

.upload-area p {
    margin-bottom: 4px;
}

.upload-area .upload-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: none;
}

.alert-success {
    background: #e6f4ea;
    color: #137333;
    border: 1px solid #34a853;
}

.alert-error {
    background: #fce8e6;
    color: #c5221f;
    border: 1px solid #ea4335;
}

.alert.show {
    display: block;
}

.data-preview {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

.data-preview table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-preview th,
.data-preview td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
    text-align: left;
}

.data-preview th {
    background: var(--gray-100);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.instructions-list {
    list-style: none;
    counter-reset: step;
}

.instructions-list li {
    counter-increment: step;
    padding: 12px 0;
    padding-left: 40px;
    position: relative;
    border-bottom: 1px solid var(--gray-100);
}

.instructions-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 12px;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.instructions-list li:last-child {
    border-bottom: none;
}

.template-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}


/* ===== LANDING PAGE ===== */
.landing-body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
}

.landing-header {
    text-align: center;
    padding: 60px 20px 30px;
    color: var(--white);
}

.landing-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.landing-subtitle {
    font-size: 1rem;
    opacity: 0.7;
    text-transform: capitalize;
}

.landing-main {
    padding: 20px 0 60px;
}

.landing-choose {
    text-align: center;
    color: var(--white);
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 400;
    margin-bottom: 32px;
    opacity: 0.9;
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 800px;
    margin: 0 auto;
}

.event-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px;
    text-align: center;
}

.event-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

.event-card-logo {
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.event-card-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.event-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.event-card-info {
    margin-bottom: 20px;
}

.event-card-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.event-card-desc {
    font-size: 0.9rem;
    color: var(--gray-700);
}

.event-card-action .btn {
    padding: 12px 32px;
    font-size: 1rem;
}

/* Landing page loading/empty in dark mode */
.landing-body .loading-state,
.landing-body .empty-state {
    color: rgba(255,255,255,0.7);
}

.landing-body .spinner {
    border-color: rgba(255,255,255,0.2);
    border-top-color: var(--white);
}

.landing-body .footer {
    background: transparent;
    color: rgba(255,255,255,0.4);
}

@media (max-width: 600px) {
    .landing-title {
        font-size: 1.8rem;
    }

    .landing-header {
        padding: 40px 20px 20px;
    }

    .events-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .event-card {
        padding: 24px 20px;
    }

    .event-card-logo {
        width: 120px;
        height: 120px;
    }
}


/* ===== QR CODE SECTION ===== */
.qr-section {
    padding: 20px 0 40px;
}

.qr-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    max-width: 240px;
    margin: 0 auto;
    backdrop-filter: blur(4px);
}

.qr-code {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.qr-code svg {
    width: 180px;
    height: 180px;
    background: white;
    padding: 10px;
    border-radius: 8px;
}

.qr-text {
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
}


/* ===== VIEW TOGGLE BUTTONS ===== */
.view-toggle {
    display: inline-flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--primary);
    margin-right: 8px;
}

.btn-toggle {
    padding: 8px 16px;
    border: none;
    background: var(--white);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

.btn-toggle:hover {
    background: var(--primary-light);
}

.btn-toggle.active {
    background: var(--primary);
    color: var(--white);
}

@media (max-width: 768px) {
    .results-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .view-toggle {
        margin-right: 0;
    }
}


/* ===== MULTI-SELECT DROPDOWN ===== */
.multi-select {
    position: relative;
}

.multi-select-header {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-main);
    background: var(--white);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--gray-700);
    transition: border-color 0.2s;
}

.multi-select-header:hover {
    border-color: var(--primary);
}

.multi-select-header.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.multi-select-header.has-selection {
    color: var(--dark);
    font-weight: 500;
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.multi-select-dropdown.show {
    display: block;
}

.multi-select-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.multi-select-item:hover {
    background: var(--primary-light);
}

.multi-select-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.multi-select-item label {
    cursor: pointer;
    flex: 1;
    margin: 0;
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: var(--dark);
}


/* ===== VISITOR COUNTER ===== */
.visitor-counter {
    position: fixed;
    bottom: 12px;
    right: 12px;
    z-index: 50;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.visitor-counter:hover {
    opacity: 1;
}

.visitor-counter img {
    height: 22px;
    border-radius: 4px;
}
