/* Theme foundation */
:root {
    --site-ink: #13222f;
    --site-muted: #52606d;
    --site-card: rgba(255, 255, 255, 0.78);
    --site-line: rgba(19, 34, 47, 0.14);
    --site-shadow: 0 14px 32px rgba(10, 31, 45, 0.14);
    --site-accent: #ff7a18;
}

body.site-shell {
    min-height: 100vh;
    color: var(--site-ink);
    background:
        radial-gradient(circle at 18% 8%, rgba(125, 218, 255, 0.25), rgba(125, 218, 255, 0) 40%),
        radial-gradient(circle at 86% 14%, rgba(255, 214, 144, 0.24), rgba(255, 214, 144, 0) 38%),
        #edf4f7;
    position: relative;
}

.site-backdrop {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image:
        linear-gradient(160deg, rgba(8, 35, 48, 0.58) 0%, rgba(8, 35, 48, 0.2) 38%, rgba(6, 16, 25, 0.56) 100%),
        url('/assets/img/site-background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.site-navbar {
    background: linear-gradient(90deg, rgba(13, 36, 52, 0.92), rgba(16, 64, 83, 0.9));
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 22px rgba(8, 24, 33, 0.28);
}

.site-navbar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-navbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    flex: 1 1 auto;
}

.site-navbar-user {
    margin-left: auto;
    flex: 0 0 auto;
}

.site-navbar-user form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}

.site-navbar-user .badge-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.site-navbar-breadcrumb-wrap {
    min-width: 0;
    max-width: 100%;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.site-logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.88);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
}

.site-main {
    position: relative;
    z-index: 1;
}

.welcome-hero {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 1rem;
    backdrop-filter: blur(2px);
}

.welcome-hero h1 {
    color: #ffffff;
    text-shadow: 0 3px 14px rgba(0, 0, 0, 0.35);
}

.card,
.alert,
.breadcrumb,
.pagination .page-link,
.table-responsive,
.traces-table tr {
    background-color: var(--site-card);
    border-color: var(--site-line);
    box-shadow: var(--site-shadow);
}

.breadcrumb {
    backdrop-filter: blur(6px);
    border: 1px solid var(--site-line);
    border-radius: 0.7rem;
    padding: 0.45rem 0.75rem;
}

.btn-primary {
    background: linear-gradient(120deg, #1f8f54, #44b36e);
    border-color: #1f8f54;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(120deg, rgba(16, 64, 83, 0.92), rgba(33, 91, 114, 0.92));
    border-color: #1a7a48;
}

/* GPX table responsive behavior: desktop table, mobile cards */
.traces-table {
    margin-bottom: 0;
}

.gpx-upload-toggle summary {
    cursor: pointer;
    list-style: none;
}

.gpx-upload-toggle summary::-webkit-details-marker {
    display: none;
}

.gpx-upload-toggle summary::after {
    content: 'Afficher';
    float: right;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #ffffff;
    background: rgba(31, 143, 84, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    line-height: 1.2;
}

.gpx-upload-toggle[open] summary::after {
    content: 'Masquer';
    background: rgba(16, 64, 83, 0.92);
}

.badge-chip {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #ffffff;
    background: rgba(31, 143, 84, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    line-height: 1.2;
    text-decoration: none;
}

.badge-chip:hover,
.badge-chip:focus {
    color: #ffffff;
    background: rgba(16, 64, 83, 0.92);
    text-decoration: none;
}

.badge-chip-button {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    margin: 0;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.breadcrumb-navbar {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: none;
    white-space: nowrap;
    overflow-x: auto;
    max-width: 100%;
}

.breadcrumb-navbar .breadcrumb-item,
.breadcrumb-navbar .breadcrumb-item.active {
    color: rgba(255, 255, 255, 0.9);
}

.breadcrumb-navbar .breadcrumb-item + .breadcrumb-item::before {
    color: rgba(255, 255, 255, 0.72);
}

.breadcrumb-chip {
    font-size: 0.68rem;
    padding: 0.16rem 0.5rem;
    text-transform: none;
    letter-spacing: 0.01em;
}

@media (max-width: 767.98px) {
    .table-responsive:has(.traces-table) {
        overflow: visible;
    }

    .traces-table thead {
        display: none;
    }

    .traces-table,
    .traces-table tbody,
    .traces-table tr,
    .traces-table td {
        display: block;
        width: 100%;
    }

    .traces-table tr {
        background: rgba(255, 255, 255, 0.74);
        border: 1px solid rgba(0, 0, 0, 0.12);
        border-radius: 0.75rem;
        padding: 0.65rem 0.8rem;
        margin-bottom: 0.8rem;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
    }

    .traces-table td {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        border: 0;
        padding: 0.28rem 0;
        white-space: normal;
    }

    .traces-table td::before {
        content: attr(data-label);
        display: inline-block;
        flex: 0 0 6.6rem;
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        color: #6c757d;
        letter-spacing: 0.04em;
        margin-bottom: 0;
        line-height: 1.2;
    }

    .traces-table td > * {
        flex: 0 0 auto;
        max-width: 100%;
    }

    .traces-table td[data-label="Actions"] {
        align-items: flex-start;
    }

    .traces-table td[data-label="Actions"]::before {
        padding-top: 0.22rem;
    }

    .traces-table td[data-label="Actions"] a,
    .traces-table td[data-label="Actions"] button,
    .traces-table td[data-label="Actions"] form {
        margin-right: 0.28rem;
        margin-top: 0;
        width: auto;
    }

    .traces-table td[data-label="Actions"] .btn {
        line-height: 1.1;
        padding-top: 0.18rem;
        padding-bottom: 0.18rem;
    }

    .traces-table td .mobile-owner-visibility {
        display: inline-flex;
        margin-left: 0.35rem;
    }

    .traces-table td[data-label="Visibilite"] {
        display: none;
    }
}

@media (min-width: 768px) {
    .traces-table td .mobile-owner-visibility {
        display: none;
    }
}

.gpx-detail-layout {
    display: grid;
    gap: 1rem;
}

.gpx-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
}

.gpx-metrics {
    display: grid;
    gap: 0.65rem;
}

.gpx-metric {
    background: rgba(248, 249, 250, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.7rem;
    padding: 0.6rem 0.7rem;
}

.gpx-metric-line {
    margin: 0;
    font-size: 0.95rem;
}

.gpx-metric-value {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2a37;
}

.gpx-metric-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #6c757d;
}

.gpx-chart-wrap {
    position: relative;
    height: 210px;
}

.gpx-chart-wrap--compact {
    height: 140px;
}

.gpx-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.gpx-qr-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
}

.gpx-qr-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 16, 24, 0.62);
}

.gpx-qr-modal__dialog {
    position: relative;
    width: min(92vw, 360px);
    margin: 8vh auto 0;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(19, 34, 47, 0.16);
    border-radius: 0.9rem;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    padding: 1rem;
}

.gpx-qr-modal__close {
    position: absolute;
    top: 0.45rem;
    right: 0.55rem;
    border: 0;
    background: transparent;
    color: #52606d;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}

.gpx-qr-modal__canvas-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(19, 34, 47, 0.12);
    border-radius: 0.7rem;
    padding: 0.55rem;
}

.gpx-qr-modal__canvas-wrap canvas {
    width: min(100%, 256px);
    height: auto;
}

.gpx-map-panel {
    overflow: hidden;
}

.gpx-map-canvas {
    height: 380px;
}

@media (min-width: 992px) {
    .gpx-detail-layout {
        grid-template-columns: 300px minmax(0, 1fr);
        align-items: stretch;
    }

    .gpx-map-canvas {
        min-height: 520px;
        height: calc(100vh - 230px);
        max-height: 760px;
    }
}

@media (max-width: 575.98px) {
    .site-navbar-row {
        align-items: flex-start;
    }

    .site-navbar-left {
        flex-basis: 100%;
        flex-wrap: wrap;
        gap: 0.55rem;
    }

    .site-navbar-user {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }

    .site-brand span {
        font-size: 0.98rem;
    }

    .site-logo {
        width: 38px;
        height: 38px;
    }

    .site-backdrop {
        background-attachment: scroll;
        background-position: 58% center;
    }

    .gpx-map-canvas {
        height: 300px;
    }

    .gpx-chart-wrap--compact {
        height: 130px;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .site-backdrop {
        background-position: 56% center;
    }
}
