/* Custom CSS for Race Manager */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --app-navbar-height: 56px;
}

html, body {
    margin: 0;
    padding: 0;
    /* Let the browser know to use the full viewport height */
    /*height: 100dvh;*/
    /* Optionally, you can use max-height: 100dvh if needed */
    /*max-height: 100dvh;*/
    width: 100%;
    height: 100%;
    overflow-x: hidden;
     
}

body {
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-area-bottom);
}


.navbar {
    margin: 0;
    padding-top: var(--safe-area-top);
    justify-content: space-between; /* or other appropriate value */
}

.app-main-shell {
    flex: 1;
    padding-top: calc(var(--app-navbar-height) + 0.75rem);
}

.app-flash-shell {
    margin-top: 0.15rem;
}

.app-content-shell {
    margin-top: 0.05rem;
}

.page-hero-card {
    padding: 1.5rem;
    background: linear-gradient(180deg, #f8f9fb 0%, #f2f4f7 100%);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 1.5rem;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.page-eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6c757d;
}

.page-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.05;
}

.page-back-button {
    white-space: nowrap;
}

.page-form-card {
    border-radius: 1.5rem;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem 1.5rem;
}

.audit-entry-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1rem;
}

.audit-details-box {
    padding: 0.8rem 0.9rem;
    border-radius: 0.9rem;
    background: #f8f9fb;
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.page-back-button-icon {
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-hero-card-compact {
    padding: 1rem 1.15rem;
}

.page-title-compact {
    font-size: clamp(1.85rem, 3.4vw, 2.55rem);
    line-height: 1;
}

.race-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    font-size: 0.95rem;
}

.race-status-card .card-body {
    padding: 1.15rem;
}

.race-status-card-sticky {
    position: sticky;
    top: calc(var(--app-navbar-height) + 0.35rem);
    z-index: 1015;
}

.race-page-hero-row {
    flex-wrap: nowrap;
}

.race-page-hero-main {
    min-width: 0;
    flex: 1 1 auto;
}

.race-page-back-button {
    flex: 0 0 auto;
}

.race-start-form {
    display: grid;
    gap: 0.75rem;
}

.race-start-checkbox {
    margin-bottom: 0;
}

.race-start-button {
    min-height: 3rem;
}

.race-participants-header {
    row-gap: 0.65rem;
}

.race-participants-title {
    font-size: 1.2rem;
}

.race-participants-actions {
    justify-content: flex-end;
}

.race-participants-card .table thead th {
    white-space: nowrap;
}

.race-running-meta {
    font-size: 1rem;
}

.race-stopwatch-wrap {
    display: grid;
    gap: 0.15rem;
}

.race-stopwatch-label {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
}

.race-stopwatch-value {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1;
}

.results-table-header {
    background: linear-gradient(180deg, rgba(248, 249, 251, 0.95) 0%, rgba(248, 249, 251, 0) 100%);
}

.race-results-table thead th {
    border-top: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
}

.race-results-accordion {
    --bs-accordion-border-color: rgba(15, 23, 42, 0.08);
}

.race-result-item {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    margin-bottom: 0.85rem;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.race-result-toggle {
    padding: 1rem 1.05rem;
}

.race-result-toggle:not(.collapsed) {
    background-color: #f8f9fb;
    box-shadow: none;
}

.race-result-toggle:focus {
    box-shadow: none;
}

.race-result-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.race-result-main {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.race-result-number {
    min-width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef2f6;
    font-weight: 700;
}

.race-result-name {
    font-weight: 700;
    line-height: 1.2;
}

.race-result-subtle {
    font-size: 0.85rem;
    color: #6c757d;
}

.race-result-time {
    padding: 0.45rem 0.75rem;
    border-radius: 0.85rem;
    background: #212529;
    color: #fff;
    font-weight: 700;
    white-space: nowrap;
}

.race-result-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.race-result-detail-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.manual-result-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.manual-result-input {
    max-width: 130px;
}

.participant-stat-grid {
    display: grid;
    gap: 0.35rem;
}

.compact-help .helper-copy {
    display: none !important;
}

.guide-content-card .card-body {
    padding: 1.5rem;
}

.guide-toc {
    background: #f8f9fb;
}

.guide-toc-subitem {
    margin-left: 0.35rem;
}

.guide-markdown h1,
.guide-markdown h2,
.guide-markdown h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.guide-markdown h1:first-child,
.guide-markdown h2:first-child,
.guide-markdown h3:first-child {
    margin-top: 0;
}

.guide-markdown p,
.guide-markdown ul,
.guide-markdown ol {
    margin-bottom: 1rem;
}

.guide-markdown code {
    padding: 0.15rem 0.4rem;
    border-radius: 0.4rem;
    background: rgba(17, 24, 39, 0.08);
    font-size: 0.92em;
}

.offset-picker-shell {
    display: grid;
    gap: 0.75rem;
}

.offset-picker-minutes {
    max-width: 220px;
}

.offset-picker-seconds {
    flex-wrap: wrap;
}

.bulk-participant-grid {
    display: grid;
    gap: 0.75rem;
}

.add-participant-hero-row {
    flex-wrap: nowrap;
}

.add-participant-hero-main {
    min-width: 0;
    flex: 1 1 auto;
}

.add-participant-single-card,
.add-participant-bulk-card {
    border-radius: 1.15rem;
}

.add-participant-single-card {
    border: 1px solid rgba(13, 110, 253, 0.18);
    background: linear-gradient(180deg, rgba(13, 110, 253, 0.06), rgba(255, 255, 255, 0.95));
}

.add-participant-bulk-card {
    border: 1px solid rgba(255, 193, 7, 0.28);
    background: linear-gradient(180deg, rgba(255, 193, 7, 0.08), rgba(255, 255, 255, 0.96));
}

.bulk-participant-actions {
    position: sticky;
    bottom: 0;
    padding-top: 0.75rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.96) 28%, rgba(255, 255, 255, 1));
}

.bulk-participant-actions-top {
    position: static;
    padding-top: 0;
    background: transparent;
}

.bulk-participant-actions .btn {
    width: 100%;
}

.add-participant-current-card {
    border: 1px solid rgba(25, 135, 84, 0.18);
    background: linear-gradient(180deg, rgba(25, 135, 84, 0.05), rgba(255, 255, 255, 0.96));
}

.add-participant-primary-actions .btn {
    min-width: 140px;
}

.add-participant-bridge-actions .btn {
    min-width: 180px;
}

@media (min-width: 576px) {
    .bulk-participant-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.race-participants-wrap[data-layout="grid"] .race-participants-table-wrap {
    display: none;
}

.race-participant-grid {
    display: none;
}

.race-participants-wrap[data-layout="grid"] .race-participant-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.race-participant-grid-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    padding: 0.75rem;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
    background: #fff;
    display: grid;
    gap: 0.45rem;
}

.race-participant-grid-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.race-participant-grid-number {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
}

.race-participant-grid-finish {
    min-width: 2.2rem;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.race-participant-grid-name {
    font-size: 0.85rem;
    color: #6c757d;
    min-height: 2.2em;
    line-height: 1.15;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.race-participant-grid-status,
.race-participant-grid-done {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.race-participant-grid-done {
    color: #198754;
}

.race-confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(2px);
    z-index: 1080;
}

.race-confirm-modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 1090;
}

.race-confirm-modal-card {
    width: min(100%, 420px);
    background: #fff;
    border-radius: 1.15rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
    overflow: hidden;
}

.race-confirm-modal-header,
.race-confirm-modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.85rem;
}

.race-confirm-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.race-confirm-modal-body {
    padding: 0 1rem 1rem;
    color: #495057;
}

.race-confirm-modal-actions {
    justify-content: flex-end;
    padding-top: 0;
    padding-bottom: 1rem;
}

.standings-table thead th {
    white-space: nowrap;
}

.standings-table td,
.standings-table th {
    vertical-align: middle;
}

.standings-points-badge {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
}

@media (max-width: 575.98px) {
    .standings-table {
        font-size: 0.92rem;
    }

    .standings-table thead th {
        white-space: normal;
        line-height: 1.1;
    }

    .standings-table th,
    .standings-table td {
        padding: 0.55rem 0.45rem;
    }

    .standings-number-col {
        display: none;
    }

    .standings-points-badge {
        font-size: 0.82rem;
        font-weight: 500;
        padding: 0.3rem 0.5rem;
    }
}

/* Hamburger Icon adjustments */
.navbar-toggler {
    padding: 0;
    margin: 0;
    border: none; /* Optional: To remove the default border */
}

.nav-link {
    padding-right: 0.5rem !important; /* Adjust padding as needed for the link */
}


.card {
    margin-bottom: 15px; /* Space between participant cards */
}

.footer {
    margin-top: 20px; /* Space above the footer */
    background-color: #f8f9fa;
    padding: 10px 0;
    text-align: center;
    position: relative;
    bottom: 0;
    width: 100%;
}

.main-content {
    flex-grow: 1;
    overflow-y: auto;
}

/* Make stopwatch larger */
#stopwatch_l {
    font-size: 3rem;
    font-weight: bold;
    margin: 0;
}

/* Make stopwatch larger */
#stopwatch_s {
    font-size: 3rem;
    font-weight: bold;
    margin: 0;
}


/* Adjust spacing for mobile screens */
@media (max-width: 576px) {
    .container {
        padding: 0.4rem 0.5rem;
    }

    .navbar {
        min-height: 48px;
    }

    .navbar .container-fluid {
        padding-left: 0.55rem;
        padding-right: 0.55rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .navbar-toggler {
        padding: 0.2rem 0.35rem;
        font-size: 0.95rem;
    }

    .app-main-shell {
        padding-top: calc(var(--app-navbar-height) + 0.35rem);
    }

    .app-flash-shell,
    .app-content-shell {
        margin-top: 0;
    }

    table {
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.5rem;
    }

    h1, h2 {
        font-size: 1.5rem;
    }

    .page-hero-card {
        padding: 0.75rem 0.85rem;
        border-radius: 0.95rem;
        margin-bottom: 0.65rem !important;
    }

    .page-hero-card-compact {
        padding: 0.65rem 0.75rem;
    }

    .page-title-compact {
        font-size: 1.2rem;
        line-height: 1.05;
    }

    .page-title {
        font-size: clamp(1.45rem, 5.5vw, 1.95rem);
        margin-bottom: 0.2rem !important;
    }

    .race-meta-row {
        font-size: 0.8rem;
        gap: 0.3rem 0.55rem;
    }

    .race-status-card .card-body {
        padding: 0.75rem;
    }

    .race-running-meta {
        font-size: 0.92rem;
    }

    .race-stopwatch-label {
        font-size: 0.82rem;
    }

    .race-stopwatch-value {
        font-size: 2.1rem;
    }

    .race-page-hero-row {
        align-items: center !important;
        gap: 0.6rem !important;
    }

    .race-page-back-button {
        margin-left: 0.1rem;
    }

    .page-back-button {
        justify-content: center;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }

    .page-back-button-icon {
        width: 2.1rem;
        min-width: 2.1rem;
        height: 2.1rem;
        align-self: flex-start;
    }

    .card .card-body {
        padding: 0.8rem;
    }

    footer {
        padding-top: 0.35rem !important;
        padding-bottom: calc(0.3rem + var(--safe-area-bottom)) !important;
    }

    footer p {
        margin-bottom: 0;
        font-size: 0.82rem;
    }

    .race-status-card {
        margin-bottom: 0.75rem !important;
    }

    .race-status-card .alert {
        padding: 0.7rem 0.8rem;
        margin-bottom: 0;
        font-size: 0.95rem;
    }

    .race-start-form {
        gap: 0.55rem;
        margin-top: 0.5rem !important;
    }

    .race-start-checkbox {
        margin-top: 0 !important;
    }

    .race-start-checkbox .form-check-label {
        font-size: 0.94rem;
    }

    .race-start-button {
        min-height: 2.8rem;
        font-size: 1rem;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    .race-start-button i {
        font-size: 1.2rem !important;
        margin-right: 0.4rem !important;
    }

    .race-participants-card {
        margin-bottom: 1rem !important;
    }

    .race-participants-header {
        margin-bottom: 0.65rem !important;
        align-items: center !important;
    }

    .race-participants-title {
        font-size: 1rem;
    }

    .race-participants-actions {
        width: auto;
        gap: 0.4rem !important;
    }

    .race-participants-actions > .btn {
        padding: 0.38rem 0.6rem;
        font-size: 0.88rem;
    }

    .race-participants-actions > .btn i {
        margin-right: 0.25rem !important;
        font-size: 0.88rem !important;
    }

    .race-participants-card .table {
        font-size: 0.82rem;
    }

    .race-participants-card th,
    .race-participants-card td {
        padding: 0.45rem 0.35rem;
    }

    .add-participant-hero-row {
        align-items: center !important;
        gap: 0.6rem !important;
    }

    .add-participant-single-card,
    .add-participant-bulk-card {
        border-radius: 0.95rem;
    }

    .add-participant-primary-actions {
        flex-direction: column;
    }

    .add-participant-primary-actions .btn {
        width: 100%;
        min-width: 0;
    }

    .add-participant-bridge-actions .btn {
        width: 100%;
    }

    .manual-result-form {
        align-items: stretch;
        width: 100%;
    }

    .manual-result-input,
    .manual-result-button {
        width: 100%;
        max-width: none;
    }

    .race-layout-toggle {
        width: 100%;
    }

    .race-layout-toggle .btn {
        flex: 1 1 0;
    }

    .race-grid-density-toggle {
        width: 100%;
    }

    .race-grid-density-toggle .btn {
        flex: 1 1 0;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="2"] .race-participant-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid-card {
        padding: 0.55rem;
        gap: 0.35rem;
        border-radius: 0.85rem;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid-top {
        gap: 0.3rem;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid-number {
        font-size: 1.3rem;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid-finish {
        min-width: 1.95rem;
        width: 1.95rem;
        height: 1.95rem;
        border-radius: 0.55rem;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid-name {
        font-size: 0.68rem;
        min-height: 1.7em;
    }

    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid-status,
    .race-participants-wrap[data-layout="grid"][data-grid-columns="3"] .race-participant-grid-done {
        font-size: 0.65rem;
    }
}


/* Ensure buttons are responsive and don't get hidden on small screens */
/*.btn {
    width: 50%; /* Makes the button full width on small screens */

/*}*/

/* @media (min-width: 768px) {
    .btn {
        width: auto; /* Revert to auto width on larger screens */
        /*display: block !important; /* Ensure buttons are stacked on larger screens */
/*   }
} */

/* Reduce unnecessary top space */
.container.mt-4 {
    margin-top: 1rem; /* Adjust to reduce the top margin */
}

/* Adjusted sidebar styles */
#sidebar {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    background-color: black;
    transition: all 0.3s;
    z-index: 1050; /* Ensure it sits above the content */
    padding: calc(20px + var(--safe-area-top)) 20px 20px;
    /* Remove full height and adjust alignment */
    max-height: 100%; /* Optional: Limit max height to fit content */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align items at the top */
}
#sidebar.active {
    left: 0;
}
#sidebar .close-btn {
    align-self: flex-end;
    font-size: 1.5rem;
    color: white;
}
#sidebar ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}
#sidebar ul li {
    margin-bottom: 15px;
}
#sidebar ul li a {
    color: white;
    text-decoration: none;
    font-size: 1.2rem;
}
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1040;
    visibility: hidden;
}
.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.user-icon {
    padding-right: 0 !important; /* Adjust this value to move it closer to the right edge */
    margin-right: 0 !important;/* Ensure margin-right is reset if it's previously set */
    align-items: right;
}


.bi.bi-person {
    margin-right: 0; /* Ensure the SVG itself has no margin */
}

.d-flex.ms-auto {
    margin-left: auto !important; /* Ensure it aligns to the right */
    padding-right: 0; /* No additional padding on the right */
}

.custom-modal-position .modal-dialog {
    margin-top: 15vh; /* Adjust this value to control the distance from the top */
}
