:root {
    --primary-color: #d32f2f;
    /* KartNation Red - adjust if needed */
    --secondary-color: #212121;
    --background-color: #f5f5f5;
    --text-color: #333;
    --card-bg: rgba(255, 255, 255, 0.9);
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Global Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding-top: 70px;
    /* Space for fixed navbar */
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background-color: #ffffff;
    /* White background */
    color: var(--secondary-color);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    border-bottom: 1px solid #eee;
}

.navbar-brand img {
    height: 40px;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 30px;
    margin: 0;
    padding: 0;
    align-items: center;
}

.nav-links a {
    color: var(--secondary-color);
    /* Dark text */
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    font-size: 0.95rem;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #ffffff;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1;
    border-radius: 8px;
    padding: 10px 0;
    border: 1px solid #eee;
    top: 100%;
    left: 0;
}

.dropdown-content a {
    color: var(--secondary-color);
    padding: 10px 20px;
    text-decoration: none;
    display: block;
    transition: background-color 0.2s;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
    color: var(--primary-color);
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown:hover>a {
    color: var(--primary-color);
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Cards Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 1px;
    /* Sharper corners for a modern feel, or slightly rounded */
    border-radius: 12px;
    padding: 0;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.card-img {
    width: 100%;
    height: 140px;
    object-fit: contain;
    /* Ensure full image is visible */
    background-color: #f9f9f9;
    /* Lighter background for better contrast */
    padding: 10px;
    /* Add breathing room */
}

.card-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    margin: 0 0 10px 0;
    color: var(--secondary-color);
    font-size: 1.25rem;
}

.card-text {
    font-size: 0.95rem;
    color: #555;
    flex-grow: 1;
    margin-bottom: 15px;
}

/* Standardized Buttons */
.btn-primary,
.btn {
    background-color: #d32f2f;
    color: white;
    border: 1px solid #d32f2f;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    /* Optional global min-width, can be overridden */
    box-shadow: 0 2px 5px rgba(211, 47, 47, 0.3);
    box-sizing: border-box;
    text-decoration: none;
}

.btn-primary:hover,
.btn:hover {
    background-color: #b71c1c;
    border-color: #b71c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(211, 47, 47, 0.4);
    color: white;
}

.btn-primary:disabled,
.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: #fff;
    border: 1px solid #ccc;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    text-decoration: none;
    min-width: 160px;
}

.btn-outline:hover {
    border-color: #d32f2f;
    color: #d32f2f;
    background-color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-outline ion-icon {
    font-size: 1.1rem;
    vertical-align: middle;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: inline-block;
}

.status-programada {
    background: #e3f2fd;
    color: #1976d2;
}

.status-inscricoes {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-encerrada {
    background: #eee;
    color: #666;
}

.status-sorteada {
    background: #fff3e0;
    color: #ef6c00;
}


/* Completed/Encerrada Cards */
.card.status-encerrada,
.card.status-bateriaconcluida {
    background-color: #f4f4f4;
    border-color: #ddd;
}

.card.status-encerrada .calendar-date,
.card.status-bateriaconcluida .calendar-date {
    background-color: #e0e0e0;
    color: #888;
}

/* Footer */
footer {
    background-color: var(--secondary-color);
    color: #ccc;
    padding: 40px 0;
    margin-top: 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 30px;
}

.footer-section h3 {
    color: white;
    margin-top: 0;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li a {
    color: #ccc;
    text-decoration: none;
}

.social-links a {
    color: white;
    margin-right: 15px;
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 70px;
        left: 0;
        background-color: #ffffff;
        padding: 20px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        border-bottom: 2px solid var(--primary-color);
        text-align: center;
        max-height: calc(100vh - 70px);
        box-sizing: border-box;
        /* Fix width issues with padding */
        /* Limit height to viewport minus navbar */
        overflow-y: auto;
        /* Enable vertical scroll */
        -webkit-overflow-scrolling: touch;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        width: 100%;
        padding: 0;
        /* Removed padding */
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-links li:last-child {
        border-bottom: none;
    }

    .nav-links a {
        color: var(--secondary-color) !important;
        font-size: 1rem;
        display: block;
        width: 100%;
        padding: 3px 0;
        line-height: 1.2;
    }

    /* Specific overrides for Login/Profile buttons to ensure visibility */
    .nav-links a.btn-nav-login,
    .nav-links a.btn-nav-profile {
        color: white !important;
        margin-top: 5px;
    }

    /* PWA Buttons mobile override */
    #install-button,
    #notif-button {
        color: white !important;
        justify-content: center;
    }

    /* Adjust dropdowns for Mobile (Accordion Style) */
    .dropdown-content {
        position: static;
        display: none;
        box-shadow: none;
        border: none;
        width: 100%;
        background-color: #f0f0f0;
        /* Distinct grey background */
        margin-top: 2px;
        border-radius: 4px;
        padding: 5px 0;
    }

    .dropdown-content a {
        font-size: 0.85rem !important;
        padding: 6px 15px !important;
        text-align: left;
        border-bottom: 1px solid #e0e0e0;
        background-color: transparent !important;
    }

    .dropdown-content a:last-child {
        border-bottom: none;
    }

    .dropdown.active .dropdown-content {
        display: block;
    }

    /* CRITICAL: Totally disable hover-trigger on mobile to prevent flickering/concurrency */
    .dropdown:hover .dropdown-content {
        display: none !important;
    }

    .dropdown.active:hover .dropdown-content {
        display: block !important;
    }

    .dropdown.active>a {
        color: var(--primary-color) !important;
        background-color: #f8f9fa;
    }

    .menu-toggle {
        display: block;
        z-index: 1001;
        /* Above the links */
    }
}

/* Calendar List Styles */
.calendar-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 800px;
    margin: 0 auto;
}

.calendar-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 20px;
}

.calendar-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    min-width: 60px;
    margin-right: 20px;
    color: var(--primary-color);
}

.calendar-date .day {
    font-size: 1.5rem;
    font-weight: 700;
}

.calendar-date .month {
    font-size: 0.9rem;
    text-transform: uppercase;
}

.calendar-info {
    flex-grow: 1;
}

.calendar-info h3 {
    margin: 0 0 5px 0;
    color: var(--secondary-color);
}

.calendar-info p {
    margin: 0;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.5;
}

.calendar-info ion-icon {
    vertical-align: middle;
    color: #888;
    margin-right: 5px;
}

.calendar-action {
    margin-left: 20px;
}

@media (max-width: 600px) {
    .calendar-item {
        flex-direction: column;
        text-align: center;
    }

    .calendar-date {
        margin-right: 0;
        margin-bottom: 15px;
        width: 100%;
    }

    .calendar-action {
        margin-left: 0;
        margin-top: 15px;
        width: 100%;
    }

    .calendar-action .btn {
        width: 100%;
    }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.tab-link {
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.tab-link:hover {
    color: var(--primary-color);
}

.tab-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Table container */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-top: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: #222;
    color: white;
    text-align: left;
    padding: 12px 15px;
    font-size: 0.85rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

/* Podium Positions */
.pos-1 {
    background-color: #fff9c4 !important;
    font-weight: 700;
}

.pos-2 {
    background-color: #f5f5f5 !important;
    font-weight: 700;
}

.pos-3 {
    background-color: #efebe9 !important;
    font-weight: 700;
}

.pos-top6 {
    background-color: #fafafa !important;
    font-style: italic;
}

.pos-1 td:first-child {
    color: #fbc02d;
    font-size: 1.1rem;
}

.pos-2 td:first-child {
    color: #9e9e9e;
    font-size: 1.1rem;
}

.pos-3 td:first-child {
    color: #8d6e63;
    font-size: 1.1rem;
}

.text-center {
    text-align: center !important;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 15px;
    max-width: 90%;
    width: 400px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--primary-color);
}

.modal-header {
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.modal-row:last-child {
    border-bottom: none;
}

.modal-label {
    font-weight: 500;
    color: #666;
}

.modal-value {
    font-weight: 700;
    color: #333;
}

/* Responsive Helpers for Table */
@media (max-width: 768px) {
    .d-none-mobile {
        display: none !important;
    }

    .d-block-mobile {
        display: block !important;
    }

    .table th,
    .table td {
        padding: 10px 5px;
        /* Tighter padding on mobile */
        font-size: 0.9rem;
    }

    .btn-details {
        background: #f0f0f0;
        border: none;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--secondary-color);
        cursor: pointer;
        margin: 0 auto;
        font-size: 1.2rem;
    }
}

@media (min-width: 769px) {
    .d-block-mobile {
        display: none !important;
    }
}


@media print {

    .navbar,
    footer,
    .calendar-actions-header,
    .calendar-action {
        display: none !important;
    }

    body {
        padding-top: 0;
        background: white;
    }

    .container {
        width: 100%;
        max-width: none;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}