:root {
    /* Bootstrap palette overrides - SGE Theme */
    --bs-primary: #2c3e50;
    --bs-primary-rgb: 44, 62, 80;
    --bs-secondary: #34495e;
    --bs-secondary-rgb: 52, 73, 94;
    --bs-info: #1566a8;
    --bs-info-rgb: 21, 102, 168;
    /* NE PAS surcharger --bs-tertiary-bg ici : Bootstrap l'utilise pour
       input-group-text (#f8f9fa) — écraser avec #fff le rend invisible. */
}

[data-bs-theme="dark"] {
    /* Conserver la couleur navbar en mode sombre */
    --bs-primary: #2c3e50;
    --bs-primary-rgb: 44, 62, 80;
    /* Info plus clair pour lisibilité sur fond sombre */
    --bs-info: #5ba3d9;
    --bs-info-rgb: 91, 163, 217;
    /* Tertiary : fond légèrement distinct du body dark */
    --bs-tertiary-bg: #1e2125;
    --bs-tertiary-bg-rgb: 30, 33, 37;
}

/* Fix dark mode : bg-light reste #f8f9fa → éléments de saisie invisibles.
   Couvre : icône loupe, bouton reset (×), input des formulaires de recherche. */
[data-bs-theme="dark"] .input-group-text.bg-light,
[data-bs-theme="dark"] .btn.bg-light,
[data-bs-theme="dark"] .form-control.bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    border-color: var(--bs-border-color) !important;
    color: var(--bs-body-color) !important;
}

/* Fix dark mode : Bootstrap hardcode --bs-table-color:#000 sur table-secondary
   → texte noir sur fond sombre = illisible. */
[data-bs-theme="dark"] .table-secondary {
    --bs-table-color: var(--bs-body-color);
    --bs-table-color-state: var(--bs-body-color);
    --bs-table-bg: rgba(108, 117, 125, 0.2);
    --bs-table-striped-color: var(--bs-body-color);
    --bs-table-hover-color: var(--bs-body-color);
}

/* Utility: tertiary background for neutral surfaces */
.bg-tertiary {
    background-color: var(--bs-tertiary-bg) !important;
}

.event-context-banner {
    border-left: .25rem solid var(--bs-info);
    background-color: rgba(var(--bs-info-rgb), 0.12);
    color: #0d3b5e;
}
[data-bs-theme="dark"] .event-context-banner {
    color: #a8d4f5;
}

.event-scope-disabled {
    opacity: 0.55 !important;
    pointer-events: none !important;
}

#currentEventLabel {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 160px;
    vertical-align: middle;
}


@font-face {
    font-family: 'Numberplate';
    src: url('../font/NumberplateLL-SwitzerlandRd.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}


.container { 
    margin-top: 50px; 
    max-width: 1280px;
    padding-bottom: 3rem;
}

/* Table enhancements */

.table thead th {
    text-transform: uppercase;
    font-size: 0.875em;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--bs-secondary-color);
    background-color: var(--bs-tertiary-bg);
}

/* Horizontal scroll indicators for tables */
.table-responsive {
    background: 
        linear-gradient(to right, var(--bs-card-bg) 30%, transparent), 
        linear-gradient(to left, var(--bs-card-bg) 30%, transparent) 100% 0, 
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .12), transparent), 
        radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .12), transparent) 100% 0;
    background-repeat: no-repeat;
    background-color: var(--bs-card-bg);
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table,
.table-responsive .table > :not(caption) > * > * {
    background-color: transparent !important;
}

@media (max-width: 768px) {
    .table-responsive::-webkit-scrollbar {
        height: 4px;
        display: block;
    }
    .table-responsive::-webkit-scrollbar-thumb {
        background: var(--bs-border-color);
        border-radius: 4px;
    }
}

/* Layout components */
#public-login-stage {
    --public-login-banner-offset: 0px;
    --public-login-notice-top: 1.5rem;
    position: relative;
    min-height: calc(100vh - var(--public-login-banner-offset));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

#public-login-notice {
    position: fixed;
    top: var(--public-login-notice-top);
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100vw - 2rem));
    z-index: 1030;
}

#login-container {
    width: min(400px, 100%);
    max-width: 400px;
    margin: 0 auto;
}

#app-content { display: none; }

/* Specific UI Elements */
.brand-tag {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-secondary);
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.875em;
    font-weight: 600;
    text-transform: uppercase;
}

.cursor-pointer { cursor: pointer; }

/* Quill editor: use inherited font-size inside settings pane */
#pane-settings-content .ql-container { font-size: inherit !important; }

/* Dev environment banner */
.dev-banner {
    background-color: #ff9800;
    color: #000;
    text-align: center;
    padding: 5px;
    font-size: 0.8rem;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 1060;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.dev-env .navbar {
    top: var(--dev-banner-offset, 31px);
}
.dev-env #public-login-stage {
    --public-login-banner-offset: var(--dev-banner-offset, 31px);
    --public-login-notice-top: calc(var(--dev-banner-offset, 31px) + 1rem);
}

@media (max-width: 767.98px) {
    #public-login-stage {
        align-items: flex-start;
        padding-top: 8.5rem;
    }

    #public-login-notice {
        width: calc(100vw - 1rem);
    }
}

/* Correctif Bootstrap 5 : modal-dialog-centered + modal-fullscreen-*-down
   Sur écran étroit, align-items:center + le pseudo-élément ::before (espaceur
   de centrage vertical) empêchent modal-content de remplir toute la hauteur,
   laissant des zones transparentes. On force stretch et on supprime le spacer. */
@media (max-width: 991.98px) {
    .modal-fullscreen-lg-down.modal-dialog-centered {
        align-items: stretch;
    }
    .modal-fullscreen-lg-down.modal-dialog-centered::before {
        display: none;
    }
}

/* Correctif : <form> enfant direct de .modal-content casse le flex column de Bootstrap.
   Le form doit se comporter comme un flex item qui grandit, avec le body scrollable. */
#organizerModal .modal-content > form {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
#organizerModal .modal-content > form .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

/* Modal improvements for event editor */
.modal-event-dialog {
    max-width: min(1140px, calc(100vw - 96px));
}
#eventModal .modal-content {
    max-height: calc(100vh - 96px);
}
#eventModal .modal-body {
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.bi-spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

.export-icon {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.table-user-deactivated {
    background-color: #fff5f5 !important;
}

.table-user-deactivated td {
    color: #880000;
}

[data-bs-theme="dark"] .table-user-deactivated {
    background-color: rgba(136, 0, 0, 0.2) !important;
}

[data-bs-theme="dark"] .table-user-deactivated td {
    color: #ff8080;
}


/* License Plate Styles */
.license-plate {
    width: 54px;
    height: 42px;
    background-color: #ffffff !important;
    color-scheme: light;
    border: 1px solid #000;
    border-radius: 4px;
    display: inline-flex;
    flex-direction: column;
    padding: 3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-family: 'Numberplate', 'Inter', -apple-system, sans-serif;
    position: relative;
    user-select: none;
    vertical-align: middle;
}

.license-plate .top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 14px;
    margin-top: 1px;
    margin-bottom: 4px;
}

.license-plate .crest {
    width: 11px;
    height: 13px;
    background-color: #ffffff !important;
}

/* Action buttons styling: consistent sizing and inactive state */
.btn-action {
    min-width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: .5rem;
    padding-right: .5rem;
}

.table-actions-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem;
}

.table-actions-wrap > .btn,
.table-actions-wrap > a.btn,
.table-actions-wrap > .dropdown {
    flex: 0 0 auto;
}

/* Disabled buttons */
.btn:disabled,
.dropdown-item:disabled {
    opacity: 0.6;
}


.license-plate .canton, .license-plate .number {
    font-size: 16px;
    font-weight: normal;
    color: #1a1a1a !important;
    line-height: 1;
}

.license-plate .bottom-row {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1px;
}

/* Trials Section Styles */


.trial-validations-container {
    line-height: 1.4;
}

.trials-table {
    table-layout: auto;
}

.trials-table th:nth-child(1) {
    width: 20%;
}

.trials-table th:nth-child(2) {
    width: 20%;
}

.trials-table th:nth-child(3) {
    width: 25%;
}

.trials-table th:nth-child(4) {
    width: 25%;
}

.trials-table th:nth-child(5) {
    width: 10%;
}

/* ID formatting: bold part slightly larger */
.id-bold {
    font-size: 1.1em;
    letter-spacing: 0.02em;
}

/* ===== Harmonized Search Header Styles ===== */

/* Card headers with search integration */
.card-header {
    flex-wrap: wrap;
}

.search-input-group {
    flex: 1;
    max-width: 350px;
    min-width: 0;
}

.search-header-btn {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
}

/* Icon-only buttons on smaller screens */
.search-header-btn span {
    transition: opacity 0.2s ease;
}

/* Responsive behavior for buttons */
@media (max-width: 991.98px) {
    .search-input-group {
        flex-basis: 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .card-header {
        padding: 0.75rem !important;
        row-gap: 0.75rem;
    }
    
    .card-header h5 {
        font-size: 0.95rem;
    }
    
    .btn-group {
        flex-wrap: wrap;
    }
}

@media (max-width: 767.98px) {
    .card-header {
        padding: 0.5rem !important;
        column-gap: 0.5rem;
    }
    
    .card-header h5 {
        font-size: 0.9rem;
    }
    
    .search-input-group {
        flex-basis: 100%;
        margin-bottom: 0.5rem;
    }
    
    .search-input-group .input-group-text,
    .search-input-group .form-control,
    .search-input-group .btn {
        font-size: 0.875rem;
    }
    
    /* Hide text labels on extra small screens */
    .search-header-btn span.d-lg-inline {
        font-size: 0.75rem;
    }
}

/* Tooltips styling for better visibility */
.tooltip-inner {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
}

/* Button group responsiveness */
.btn-group {
    flex-shrink: 0;
    display: flex;
    gap: 0; /* remove gap between grouped buttons to avoid visual space */
}

/* Table-specific action buttons: align right and ensure consistent icon-button widths */
.table td .btn-group {
    justify-content: flex-end;
}

/* Global application table utility: consistent layout and ellipsis handling */
.app-table {
    width: 100%;
    table-layout: auto; /* allow natural column sizing unless specific width utilities applied */
}

.app-table th, .app-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Force uniform sizing for action buttons inside tables regardless of group composition */
.table td .btn-group > .btn,
.table td .btn-group > a.btn {
    box-sizing: border-box !important;
    flex: 0 0 44px !important; /* fixed width, prevents growing/shrinking */
    width: 44px !important;
    min-width: 44px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Center icon only, avoid icon stretching */
.table td .btn-group > .btn i,
.table td .btn-group > a.btn i {
    display: inline-block !important;
    width: auto !important;
    text-align: center !important;
}

/* Hide any accidental text label inside table action buttons to keep consistent width */
.table td .btn-group > .btn > span,
.table td .btn-group > a.btn > span {
    display: none !important;
}

.app-table td.users-actions-cell {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
}

#usersSection .table-responsive {
    overflow-x: clip;
    overflow-y: visible;
}

@media (max-width: 767.98px) {
    #usersSection .table-responsive {
        overflow-x: auto;
        overflow-y: auto;
    }
}

.users-actions-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem;
}

.users-actions-dropdown {
    flex: 0 0 auto;
}

.users-actions-dropdown > .dropdown-toggle {
    width: auto !important;
    min-width: 0 !important;
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
}

#usersSection .dropdown-menu {
    min-width: 16rem;
    z-index: 1070;
    background-color: var(--bs-body-bg) !important;
    border: 1px solid var(--bs-border-color);
    opacity: 1 !important;
    backdrop-filter: none !important;
}

#usersSection .dropdown-menu.show {
    opacity: 1 !important;
}

#usersSection .dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    white-space: normal;
    text-align: left;
    opacity: 1 !important;
}

#usersSection .dropdown-menu .dropdown-item i {
    flex: 0 0 1rem;
    width: 1rem;
    text-align: center;
}

/* Ensure badge alignment in headers */
.badge.small {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Basic brand logo sizing used across teams lists */
.brand-logo {
    height: 40px;
    width: auto;
    vertical-align: middle;
}

/* Brand logo sizing in team details: occupy one third of the containing column */
#teamDetailsBrandsList .brand-logo {
    width: 27%;
    height: auto;
    max-width: 100%;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

#teamDetailsBrandsList .brand-tag {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}


/* Séparateur vertical côté gauche à partir de lg */
@media (min-width: 992px) {
    .border-start-lg {
        border-left: 1px solid var(--bs-border-color) !important;
        padding-left: 1.5rem !important;
    }
}

/* En-têtes de tableau triables */
.th-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.th-sortable:hover {
    background-color: var(--bs-table-hover-bg, rgba(0,0,0,.04));
}
.th-sortable .sort-indicator {
    opacity: 0.25;
    font-size: .85em;
}
.th-sortable .sort-indicator--active {
    opacity: 0.8;
}

/* Icône Tabler motorbike (inline, style mask comme Bootstrap Icons) */
.ti-motorbike {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M16 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M7.5 14h5l4 -4h-10.5m1.5 4l4 -4'/%3E%3Cpath d='M13 6h2l1.5 3l2 4'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M16 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M7.5 14h5l4 -4h-10.5m1.5 4l4 -4'/%3E%3Cpath d='M13 6h2l1.5 3l2 4'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
}
