/* Reset minimal
   Retour à une apparence plus sobre et propre, plus proche du design initial. */
html, body {
    min-height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #eef2f7;
    color: #1f2937;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Classement : les déplacements sont réalisés par la logique FLIP de home.js. */
#player-list-body > tr[data-player-id] {
    transition: transform 600ms ease, opacity 300ms ease;
}

#player-list-body > tr[data-player-id] > * {
    transition: background-color 500ms ease;
}

#player-list-body > tr.ranking-row-entering {
    animation: ranking-row-enter 300ms ease both;
}

#player-list-body > tr.ranking-row-moved-up > * {
    background-color: rgba(25, 135, 84, 0.12) !important;
}

#player-list-body > tr.ranking-row-moved-down > * {
    background-color: rgba(220, 53, 69, 0.10) !important;
}

@keyframes ranking-row-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loader réutilisable pour le chargement des pages et des données. */
.site-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    background: rgba(255, 255, 255, 0.94);
    color: #0f766e;
    font-weight: 700;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.site-loader-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.site-loader {
    --loader-size: 44px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    width: var(--loader-size);
    height: calc(var(--loader-size) * 0.5);
}

.site-loader-dot {
    width: calc(var(--loader-size) * 0.17);
    height: calc(var(--loader-size) * 0.17);
    flex-shrink: 0;
    border-radius: 50%;
    background: #0f766e;
    animation: site-loader-jump 1s ease-in-out infinite;
}

.site-loader-dot:nth-child(1) { animation-delay: -0.45s; }
.site-loader-dot:nth-child(2) { animation-delay: -0.3s; }
.site-loader-dot:nth-child(3) { animation-delay: -0.15s; }

.site-inline-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    color: #0f766e;
    font-weight: 600;
}

@keyframes site-loader-jump {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-200%); }
}

@media (prefers-reduced-motion: reduce) {
    .site-loader-dot {
        animation: none;
    }
}

.container, .container-fluid {
    position: relative;
    z-index: 1;
}

.navbar {
    position: relative;
    z-index: 5000;
    background: #ffffff;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.navbar-shell {
    display: flex;
    align-items: center;
    width: 100%;
    flex-wrap: nowrap;
}

.auth-block {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
}

.auth-block > .d-flex {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: auto;
    gap: 0 !important;
}

.auth-block > .d-flex > .dropdown,
.auth-block > .d-flex > .user-menu {
    margin: 0 !important;
}

#notificationsDropdown {
    margin-right: -1px !important;
}

.user-name {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 32px;
    margin-right: 0.5rem;
    line-height: 1.2;
    font-size: 1.05rem;
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
}

.btn.user-menu-button {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.02);
    color: #0f172a;
    padding: 0.45rem 0.65rem;
    font-size: 1.9rem !important;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: auto;
    height: auto;
    border-radius: 12px;
}

.btn.user-menu-button i {
    font-size: inherit;
    line-height: 1;
}

.btn.user-menu-button:hover,
.btn.user-menu-button:focus,
.btn.user-menu-button:active {
    background: rgba(15, 118, 110, 0.07) !important;
    color: #0f766e !important;
    box-shadow: none !important;
    border-color: rgba(15, 118, 110, 0.2);
}

.user-menu-dropdown {
    min-width: 220px;
    padding: 0.5rem 0;
}

.dropdown-item-text {
    display: block;
    padding: 0.5rem 1rem;
    color: #1f2937;
    font-weight: 600;
    white-space: normal;
}

.user-menu-dropdown .dropdown-item {
    padding: 0.6rem 1rem;
    font-weight: 500;
}

.navbar-brand-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: auto;
    flex: 0 0 auto;
}

.navbar .dropdown-menu {
    z-index: 5500 !important;
}

.navbar-brand {
    color: #0f172a !important;
    font-weight: 700;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    margin-right: 0;
}

.navbar-toggler {
    margin-left: auto;
    border: 1px solid rgba(15, 23, 42, 0.15);
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
}

#navbarNav {
    align-items: center;
    width: 100%;
}

.navbar-collapse {
    flex-grow: 1;
}

/* Desktop: les liens restent juste après le logo, pas à l'extrémité droite. */
@media (min-width: 992px) {
    #navbarNav {
        display: flex !important;
        width: auto;
        flex: 1 1 auto;
    }

    #main-nav-list {
        margin-right: 0 !important;
    }

    .auth-block {
        margin-left: auto;
    }
}

/* Responsive navbar logo and brand title */
.navbar-logo {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border: 2px solid rgb(185, 180, 180);
}
.brand-title {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Notifications dropdown max width on small screens */
.notifications-menu {
    width: 320px;
    max-width: 90vw;
}

.navbar .nav-link {
    color: #0f172a !important;
    font-weight: 600;
    transition: color 0.2s ease, transform 0.2s ease;
    margin-left: 0.75rem;
}

.navbar .nav-link:hover {
    color: #0f766e !important;
}

.navbar .nav-link.active {
    color: #0f766e !important;
    font-weight: 700;
}

.card,
.form-card {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

.card {
    padding: 2rem;
    margin-top: 1rem;
}

h1, h2, h3, h4, h5 {
    color: #0f172a;
    font-weight: 700;
}

.btn {
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 0.92rem;
    font-weight: 700;
}

.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
}

#notificationsDropdown {
    padding: 0.45rem 0.65rem;
    min-width: 52px;
    font-size: 1.9rem !important;
    line-height: 1;
    width: auto;
    height: auto;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.02);
    margin: 0;
}

.btn.user-menu-button {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.02);
    color: #0f172a;
    padding: 0.45rem 0.65rem;
    font-size: 1.9rem !important;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: auto;
    height: auto;
    border-radius: 12px;
    margin: 0;
}

#notificationsDropdown .fas {
    font-size: inherit;
    line-height: 1;
}

#nav-logout-btn,
#nav-login-btn,
#nav-register-btn,
#home-login-button,
#home-register-button,
#home-continue-button {
    padding: 0.5rem 0.9rem;
    font-size: 0.88rem;
    line-height: 1.2;
    white-space: nowrap;
}

#account-prompt-panel .d-flex {
    flex-wrap: wrap;
    justify-content: center !important;
    gap: 0.75rem;
}

#account-prompt-panel .d-flex > div:first-child {
    text-align: center;
    width: 100%;
}

.btn-primary {
    background: #0f766e;
    border-color: #0f766e;
    color: #ffffff;
}

.btn-primary:hover {
    background: #115e59;
    border-color: #115e59;
}

.btn-secondary,
.btn-outline-secondary {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

.btn-outline-success {
    color: #0f766e;
    border: 1.5px solid #0f766e;
    background: transparent;
}

.btn-outline-success:hover {
    background: rgba(15, 118, 110, 0.08);
    color: #0f172a;
}

.table-responsive {
    border-radius: 14px;
    overflow-x: auto !important;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    background: #ffffff;
    padding: 1rem;
}

.table {
    border-collapse: collapse;
    min-width: 600px;
    background: transparent;
}

.table th, .table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.table thead th {
    background: #0f766e;
    color: #ffffff;
    border: none;
    font-weight: 700;
}

.table tbody tr {
    background: #f8fafc;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.table tbody tr:hover {
    transform: translateY(-1px);
    background: #e2e8f0;
}

.form-label {
    font-weight: 700;
    color: #0f172a;
}

.form-control,
.form-select {
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    padding: 12px 14px;
    background: #ffffff;
}

.form-control:focus,
.form-select:focus {
    border-color: #0f766e;
    box-shadow: 0 0 0 0.15rem rgba(15, 118, 110, 0.18);
}

.footer-section {
    flex-shrink: 0;
    background: #0d2d4d;
    color: #f3f6fa;
    padding-top: 2rem;
    border-top: 3px solid #28a745;
}

.footer-title,
.footer-text,
.footer-contact li,
.footer-links a {
    color: #ffffff;
}

.footer-links a:hover,
.footer-contact li:hover {
    color: #8fe3a8;
}

.social-links {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-top: 1rem;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 1.6rem;
    text-decoration: none;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.social-links a:hover {
    background: rgba(40, 167, 69, 0.18);
    transform: translateY(-1px);
    color: #8fe3a8;
    text-decoration: none;
}

.footer-bottom {
    border-top: 1px solid rgba(15, 23, 42, 0.12);
}

@media (max-width: 768px) {
    .container,
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .navbar .nav-link {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }
}

/* Ensure auth area drops below nav links on mobile
   Make the right-side auth block stack vertically inside the collapsed menu */
@media (max-width: 768px) {
    .navbar-collapse {
        padding: 0.75rem 1rem;
    }
    #navbarNav.show,
    #navbarNav.collapsing {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Conserve la même mise en page pendant l'ouverture et la fermeture. */
    #navbarNav.collapsing {
        overflow: hidden;
        transition: height 0.3s ease-in-out;
    }
    .auth-block {
        width: 100%;
        margin-left: 0;
        justify-content: center;
    }
    .auth-block > .d-flex {
        width: 100%;
        justify-content: center;
        align-items: center;
        gap: 0.45rem;
    }
    .navbar-collapse .d-flex {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.45rem;
        width: 100%;
        flex-wrap: nowrap;
    }
    .navbar-collapse .d-flex > * {
        width: auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .navbar-collapse .d-flex .text-nowrap {
        width: 100%;
        overflow-wrap: anywhere;
    }
    .navbar-collapse .d-flex .btn {
        width: auto;
        min-width: 48px;
    }
    .navbar-collapse .dropdown {
        width: auto;
        display: flex;
        justify-content: center;
    }
    .navbar-collapse .dropdown .notifications-menu {
        width: 100%;
        max-width: 100%;
    }
    .user-menu,
    .dropdown {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .btn.user-menu-button,
    #notificationsDropdown {
        margin: 0;
        transform: scale(0.95);
    }
}

@media (max-width: 576px) {
    .navbar-logo {
        width: 52px;
        height: 52px;
        border-width: 2px;
    }
    .brand-title {
        font-size: 1.125rem;
    }
    .navbar .nav-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.95rem;
    }
    .notifications-menu {
        width: 92vw;
    }
}

/* Auth block: ensure it stacks on small screens */
@media (max-width: 768px) {
    /* make nav list first, auth block below */
    .navbar-collapse.show {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .navbar-collapse .navbar-nav {
        width: 100% !important;
    }
    .navbar-collapse .navbar-nav .nav-item {
        width: 100%;
    }
    .auth-block {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100%;
    }
    .auth-block > * {
        width: 100% !important;
        max-width: 100% !important;
    }
    .auth-block .text-nowrap {
        white-space: normal !important;
    }

    /* Strong override: ensure auth block children stack vertically */
    .auth-block {
        display: block !important;
    }
    .auth-block > div,
    .auth-block > a,
    .auth-block > span,
    .auth-block .dropdown {
        display: block !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
    .auth-block .dropdown .notifications-menu {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
    }
}

/* Les boutons d'alerte et de profil restent côte à côte sur téléphone. */
@media (max-width: 991.98px) {
    .navbar-brand-wrapper {
        width: 100%;
        flex: 1 1 100%;
    }

    .auth-block,
    .auth-block > .auth-actions {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
    }

    .auth-block > .auth-actions {
        gap: 0.35rem !important;
    }

    .auth-block .dropdown,
    .auth-block .user-menu {
        display: flex !important;
        width: auto !important;
        margin: 0 !important;
    }

    .auth-block > .auth-actions > .badge {
        width: auto !important;
        margin: 0 !important;
    }

    .auth-block .notifications-menu {
        width: min(320px, 90vw) !important;
        left: auto !important;
        right: 0 !important;
    }
}

.auth-block > .d-flex {
    gap: 0 !important;
}

.auth-block > .d-flex > .dropdown,
.auth-block > .d-flex > .user-menu {
    margin: 0 !important;
}

#notificationsDropdown {
    margin-right: 0 !important;
}

/* Actions de compte : deux commandes compactes, faciles à distinguer et à toucher. */
.auth-actions {
    gap: 0.5rem !important;
}

#notificationsDropdown,
.btn.user-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem !important;
    line-height: 1;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

#notificationsDropdown {
    color: #334155;
    background: #f8fafc;
    border-color: rgba(15, 23, 42, 0.12);
}

#notificationsDropdown:hover,
#notificationsDropdown:focus,
#notificationsDropdown:active {
    color: #ffffff !important;
    background: #0f766e !important;
    border-color: #0f766e !important;
    box-shadow: none !important;
    transform: translateY(-1px);
}

#notificationsDropdown:hover .fas,
#notificationsDropdown:focus .fas,
#notificationsDropdown:active .fas {
    color: #ffffff !important;
}

.btn.user-menu-button {
    color: #334155;
    background: #f8fafc;
}

.btn.user-menu-button:hover,
.btn.user-menu-button:focus,
.btn.user-menu-button:active {
    color: #ffffff !important;
    background: #0f766e !important;
    border-color: #0f766e !important;
    box-shadow: none !important;
    transform: translateY(-1px);
}

@media (max-width: 991.98px) {
    .auth-block > .auth-actions {
        gap: 0.5rem !important;
        justify-content: flex-start !important;
        padding-left: 0.5rem;
    }

    #notificationsDropdown,
    .btn.user-menu-button {
        width: 40px !important;
        min-width: 40px !important;
        height: 40px;
        transform: none;
    }

    /* Le menu profil reste entièrement dans l'écran, sous son icône. */
    .user-menu-dropdown {
        /* Les icônes sont à gauche sur mobile : le menu doit donc s'ouvrir à droite. */
        right: auto !important;
        left: 0 !important;
        width: min(220px, calc(100vw - 2rem));
        min-width: 0;
        max-width: calc(100vw - 2rem);
    }

    .user-menu-dropdown .dropdown-item,
    .user-menu-dropdown .dropdown-item-text {
        overflow-wrap: anywhere;
    }
}

/* Smaller photo preview for licence page */
#photo-preview-container {
    width: 110px;
    height: 110px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.licence-photo-small {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Required field indicator */
.required-label::after {
    content: " *";
    color: #d9534f;
    font-weight: 700;
    margin-left: 4px;
}

.optional-label::after {
    content: " (facultatif)";
    color: #6c757d;
    font-weight: 600;
    margin-left: 6px;
    font-size: 0.9em;
}

.notification-list {
    max-height: 260px;
    overflow-y: auto;
}

.notification-item {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background: rgba(15, 118, 110, 0.06);
    font-weight: 600;
}

.notification-item .notification-time {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.dropdown-menu {
    z-index: 3000 !important;
}

.notification-list {
    z-index: 3000;
}

/* Responsive improvements */
*, *::before, *::after {
    box-sizing: border-box;
}

img, svg {
    max-width: 100%;
    height: auto;
}

.table {
    min-width: auto;
}

@media (max-width: 992px) {
    .navbar-brand {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .navbar-brand img {
        width: 70px !important;
        height: 70px !important;
    }
    .navbar-brand span {
        font-size: 1.5rem !important;
    }
    .navbar .nav-link {
        padding: 0.5rem 0.75rem;
    }
    .card,
    .form-card {
        padding: 1.5rem;
    }
    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 0.92rem;
    }
}

@media (max-width: 768px) {
    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    .navbar {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    .navbar-collapse {
        background: #ffffff;
        padding: 1rem;
        border-radius: 16px;
        box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
    }
    .navbar-brand {
        width: 100%;
    }
    #account-prompt-panel .d-flex,
    .row.g-3,
    .row.g-4 {
        flex-wrap: wrap;
    }
    #account-prompt-panel .d-flex > *,
    .row.g-3 > [class*='col-'],
    .row.g-4 > [class*='col-'] {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .input-group {
        flex-direction: column;
    }
    .input-group .input-group-text,
    .input-group .form-control {
        width: 100%;
    }
    .d-grid {
        width: 100%;
    }
    .btn {
        width: 100%;
    }
    .table-responsive {
        padding: 0.75rem;
    }
    .table {
        font-size: 0.92rem;
    }
    .notification-list {
        max-height: 220px;
    }
}
