/* === STYLES RESPONSIVES POUR LA PISCINE - VERSION UNIFIÉE === */

/* === CONFIGURATION DE BASE PISCINE === */
.pool {
    position: relative;
    background: linear-gradient(to right, #06b6d4 0%, #0891b2 100%);
    border-radius: 10px;
    border: 3px solid #164e63;
    width: 100% !important;
    max-width: 100% !important;
    /* Hauteur définie par JavaScript selon le nombre de nageurs */
    overflow: visible !important;
}

.pool-container {
    margin: 30px 0;
    padding: 20px;
    background: linear-gradient(135deg, #0ea5e9, #0891b2);
    border-radius: 15px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    height: auto !important;
}

/* === AJUSTEMENTS RESPONSIVES UNIFIÉS === */

/* Desktop */
@media (min-width: 769px) {
    .pool {
        max-width: calc(100vw - 80px) !important;
    }
}

/* Tablette */
@media (max-width: 992px) and (min-width: 769px) {
    .pool-container {
        padding: 18px;
        margin: 25px 0;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .pool-container {
        padding: 15px 10px;
        margin: 25px -5px;
        /* Suppression de toutes les limitations de hauteur */
        max-height: none !important;
        min-height: auto !important;
        overflow-y: auto;
        height: auto !important;
    }
    
    .pool {
        /* Suppression de toutes les contraintes de hauteur */
        min-height: auto !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }
}

/* Mobile très petit */
@media (max-width: 480px) {
    .pool-container {
        margin: 20px -10px;
        padding: 15px 8px;
        border-radius: 8px;
    }
    
    .pool {
        border-width: 2px;
    }
}

/* Mode paysage mobile - optimisations spéciales */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .pool-container {
        padding: 8px;
        margin: 8px 0;
        border-radius: 8px;
    }
    
    /* Optimisations contrôles en mode paysage */
    .controls-section {
        margin-bottom: 5px !important;
    }
    
    .controls-section .row {
        margin-bottom: 5px !important;
    }
    
    .form-control-responsive {
        font-size: 11px !important;
        padding: 4px 6px !important;
        min-height: 30px !important;
    }
    
    .btn-responsive {
        font-size: 11px !important;
        padding: 4px 8px !important;
        min-height: 30px !important;
    }
    
    .controls-section .col-lg-2 {
        padding-left: 2px !important;
        padding-right: 2px !important;
        margin-bottom: 3px !important;
    }
    
    h1 {
        font-size: 1.3rem !important;
        margin-bottom: 8px !important;
    }
    
    .alert {
        padding: 5px 8px !important;
        font-size: 11px !important;
        margin-bottom: 5px !important;
    }
}

/* === ÉLÉMENTS DE LA PISCINE === */

.lane {
    position: absolute;
    width: 100%;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.3);
    box-sizing: border-box;
    max-height: none !important;
}

.swimmer {
    position: absolute;
    border-radius: 50%;
    border: 3px solid white;
    background-size: cover;
    background-position: center;
    transition: left 3s linear;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    box-shadow: 0 0 15px rgba(255,255,255,0.5);
    box-sizing: border-box;
    max-height: none !important;
}

/* Adaptations mobile pour nageurs */
@media (max-width: 768px) {
    .swimmer {
        border-width: 2px !important;
    }
}

@media (max-width: 480px) {
    .swimmer {
        border-width: 2px !important;
        font-size: 7px !important;
    }
}

.finish-line {
    position: absolute;
    right: 10px;
    top: 0;
    width: 3px;
    background: repeating-linear-gradient(
        to bottom,
        #ff0000 0px,
        #ff0000 10px,
        #ffffff 10px,
        #ffffff 20px
    );
}

@media (max-width: 768px) {
    .finish-line {
        right: 5px;
        width: 2px !important;
    }
}

/* === BARRES DE SCROLL === */

.pool-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.7) transparent;
}

.pool-container::-webkit-scrollbar {
    width: 6px;
}

.pool-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.pool-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 3px;
}

.pool-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* === INDICATEUR DE SCROLL MOBILE === */

@media (max-width: 768px) {
    .pool-container::after {
        content: "⇕";
        position: absolute;
        bottom: 8px;
        right: 8px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 8px;
        border-radius: 15px;
        font-size: 12px;
        opacity: 0.8;
        pointer-events: none;
        z-index: 100;
        font-weight: bold;
    }
}

/* === OPTIMISATIONS PERFORMANCE === */

.swimmer {
    will-change: left;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.pool-container {
    transform: translateZ(0);
    contain: layout style paint;
}

/* === PODIUM AVEC EFFET ESCALIER POUR LES PHOTOS === */

.podium-container {
    margin: 30px 0;
    text-align: center;
    position: relative;
    padding-top: 40px;
}

.podium {
    display: flex !important;
    justify-content: center !important;
    align-items: flex-end !important;
    gap: 30px;
    margin: 20px auto;
    flex-direction: row !important;
    max-width: 800px;
}

/* ORDRE : Argent-Or-Bronze */
.podium-step.first { order: 2 !important; }
.podium-step.second { order: 1 !important; }
.podium-step.third { order: 3 !important; }

.podium-step {
    display: block !important;
    text-align: center;
    position: relative !important;
}

/* Container pour la photo - POSITIONNEMENT DIFFÉRENCIÉ SELON LA POSITION */
.podium-swimmer-container {
    position: relative !important;
    z-index: 10 !important;
    /* Chevauchement de base - sera ajusté par position */
    margin-bottom: -35px !important;
}

/* NOUVEAUTÉ : Positionnement différencié pour créer l'effet escalier */
.podium-step.first .podium-swimmer-container {
    /* OR : Photo au niveau le plus haut */
    margin-bottom: -25px !important;
    transform: translateY(0px);
}

.podium-step.second .podium-swimmer-container {
    /* ARGENT : Photo légèrement plus basse */
    margin-bottom: -35px !important;
    transform: translateY(15px);
}

.podium-step.third .podium-swimmer-container {
    /* BRONZE : Photo encore plus basse */
    margin-bottom: -40px !important;
    transform: translateY(25px);
}

/* Photo du nageur */
.podium-swimmer {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50% !important;
    background-size: cover !important;
    background-position: center !important;
    border: 3px solid !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    margin: 0 auto !important;
    position: relative !important;
    z-index: 15 !important;
}

.podium-step.first .podium-swimmer {
    border-color: #ffd700 !important;
    width: 90px !important;
    height: 90px !important;
    border-width: 4px !important;
}

.podium-step.second .podium-swimmer {
    border-color: #c0c0c0 !important;
}

.podium-step.third .podium-swimmer {
    border-color: #cd7f32 !important;
}

/* Boîte d'information - HAUTEURS DIFFÉRENCIÉES POUR CRÉER L'ESCALIER */
.podium-info {
    background: white !important;
    border: 3px solid !important;
    border-radius: 12px 12px 6px 6px !important;
    padding: 50px 20px 20px 20px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    min-width: 140px !important;
    text-align: center !important;
    position: relative !important;
    z-index: 5 !important;
}

/* NOUVEAUTÉ : Hauteurs et positions différenciées pour l'escalier */
.podium-step.first .podium-info {
    /* OR : La plus haute marche */
    border-color: #ffd700 !important;
    background: linear-gradient(to bottom, #ffd700, #ffed4e) !important;
    color: #8b5a00 !important;
    min-height: 160px !important;
    border-width: 4px !important;
    padding-top: 55px !important;
    margin-top: 0px !important;
}

.podium-step.second .podium-info {
    /* ARGENT : Marche intermédiaire */
    border-color: #c0c0c0 !important;
    background: linear-gradient(to bottom, #c0c0c0, #e5e7eb) !important;
    color: #374151 !important;
    min-height: 130px !important;
    margin-top: 20px !important;
}

.podium-step.third .podium-info {
    /* BRONZE : La plus basse marche */
    border-color: #cd7f32 !important;
    background: linear-gradient(to bottom, #cd7f32, #d97706) !important;
    color: #7c2d12 !important;
    min-height: 110px !important;
    margin-top: 35px !important;
}

.podium-medal {
    font-size: 28px !important;
    margin-bottom: 10px !important;
}

.podium-name {
    font-size: 14px !important;
    font-weight: bold !important;
    margin-bottom: 6px !important;
}

.podium-time {
    font-size: 13px !important;
    margin-bottom: 4px !important;
    font-weight: 600 !important;
}

.podium-speed {
    font-size: 11px !important;
    opacity: 0.9 !important;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .podium {
        gap: 20px !important;
    }
    
    .podium-swimmer-container {
        margin-bottom: -25px !important;
    }
    
    .podium-step.first .podium-swimmer-container {
        margin-bottom: -20px !important;
        transform: translateY(0px);
    }
    
    .podium-step.second .podium-swimmer-container {
        margin-bottom: -25px !important;
        transform: translateY(10px);
    }
    
    .podium-step.third .podium-swimmer-container {
        margin-bottom: -30px !important;
        transform: translateY(18px);
    }
    
    .podium-swimmer {
        width: 60px !important;
        height: 60px !important;
    }
    
    .podium-step.first .podium-swimmer {
        width: 70px !important;
        height: 70px !important;
    }
    
    .podium-info {
        min-width: 100px !important;
        padding: 40px 12px 15px 12px !important;
        font-size: 12px !important;
    }
    
    .podium-step.first .podium-info {
        min-height: 120px !important;
        padding-top: 45px !important;
        margin-top: 0px !important;
    }
    
    .podium-step.second .podium-info {
        min-height: 100px !important;
        margin-top: 15px !important;
    }
    
    .podium-step.third .podium-info {
        min-height: 85px !important;
        margin-top: 25px !important;
    }
}

@media (max-width: 480px) {
    .podium {
        gap: 15px !important;
    }
    
    .podium-swimmer-container {
        margin-bottom: -20px !important;
    }
    
    .podium-step.first .podium-swimmer-container {
        margin-bottom: -18px !important;
        transform: translateY(0px);
    }
    
    .podium-step.second .podium-swimmer-container {
        margin-bottom: -20px !important;
        transform: translateY(8px);
    }
    
    .podium-step.third .podium-swimmer-container {
        margin-bottom: -22px !important;
        transform: translateY(12px);
    }
    
    .podium-swimmer {
        width: 50px !important;
        height: 50px !important;
    }
    
    .podium-step.first .podium-swimmer {
        width: 60px !important;
        height: 60px !important;
    }
    
    .podium-info {
        min-width: 85px !important;
        padding: 35px 8px 12px 8px !important;
        font-size: 10px !important;
    }
    
    .podium-step.first .podium-info {
        padding-top: 40px !important;
        margin-top: 0px !important;
    }
    
    .podium-step.second .podium-info {
        margin-top: 12px !important;
    }
    
    .podium-step.third .podium-info {
        margin-top: 18px !important;
    }
}




/* === RÉSULTATS RESPONSIVES === */

/* === RÉSULTATS RESPONSIVES AVEC NOUVELLES COLONNES === */

.results-list {
    margin: 30px 0;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.result-item {
    display: grid;
    grid-template-columns: 50px 60px 1fr 80px 120px 100px 100px;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #e5e7eb;
    align-items: center;
}

@media (max-width: 768px) {
    .result-item {
        grid-template-columns: 40px 50px 1fr 70px 100px 80px 80px;
        gap: 10px;
        padding: 10px;
        font-size: 14px;
    }
}

@media (max-width: 640px) {
    .result-item {
        grid-template-columns: 35px 40px 1fr 60px 90px 70px;
        gap: 8px;
        padding: 8px;
        font-size: 13px;
    }
    
    /* Masquer la colonne vitesse sur les petits écrans */
    .result-item > div:last-child {
        display: none;
    }
}

@media (max-width: 540px) {
    .result-item {
        grid-template-columns: 30px 35px 1fr 50px 80px;
        gap: 5px;
        padding: 6px;
        font-size: 12px;
    }
    
    /* Masquer vitesse ET temps sur très petits écrans */
    .result-item > div:nth-last-child(-n+2) {
        display: none;
    }
}

@media (max-width: 480px) {
    .result-item {
        grid-template-columns: 25px 30px 1fr 45px;
        gap: 3px;
        padding: 5px;
        font-size: 11px;
    }
    
    /* Masquer vitesse, temps ET catégorie sur très petits écrans */
    .result-item > div:nth-last-child(-n+3) {
        display: none;
    }
}

.result-item:nth-child(even) {
    background: #f9fafb;
}

.result-item.header {
    background: #1e40af !important;
    color: white;
    font-weight: bold;
}

.result-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    font-size: 12px;
    transition: transform 0.2s ease;
}

.result-photo:hover {
    transform: scale(1.1);
    border-color: #3b82f6;
}

/* === CONTRÔLES RESPONSIVES === */

.controls-section .row {
    margin: 0 -5px;
}

.controls-section .col-md-3,
.controls-section .col-md-2,
.controls-section .col-md-1 {
    padding: 0 5px;
}

@media (max-width: 768px) {
    .controls-section .col-md-3,
    .controls-section .col-md-2,
    .controls-section .col-md-1 {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .controls-section .col-md-3,
    .controls-section .col-md-2,
    .controls-section .col-md-1 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 8px;
    }
}

/* Responsive buttons groupes */
.btn-group-responsive .btn {
    min-width: 80px;
}

@media (max-width: 576px) {
    .btn-group-responsive {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group-responsive .btn {
        border-radius: 0.25rem !important;
        margin: 2px 0;
        min-width: auto;
    }
}

.form-control-responsive {
    min-height: 38px;
}

.btn-responsive {
    min-height: 38px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 576px) {
    .btn-responsive {
        font-size: 14px;
        padding: 6px 12px;
    }
}

/* === ANIMATIONS === */

.swimmer.finished {
    animation: celebration 0.5s ease-in-out;
}

@keyframes celebration {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pool-container,
.podium-container,
.results-list {
    animation: fadeInUp 0.5s ease-out;
}

/* === MODE COURSE PLEIN ÉCRAN === */

.course-container,
.controls-section,
.pool-container,
#raceInfo {
    transition: all 0.3s ease-out;
}

.race-mode-active .controls-section {
    opacity: 0.3;
    transform: scale(0.95);
    pointer-events: none;
}

.race-mode-active .course-container h1 {
    opacity: 0.4;
    transform: scale(0.8);
    margin-bottom: 10px;
}

.race-mode-active #raceInfo {
    opacity: 0.7;
    font-size: 0.9em;
}

.pool-container.race-mode-expanded {
    max-height: 90vh !important;
    min-height: 70vh;
    transform: scale(1.02);
    z-index: 10;
    position: relative;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    border-radius: 8px;
    transition: all 0.4s ease-out;
}

@media (max-width: 768px) {
    .race-mode-active .controls-section {
        opacity: 0.2;
        transform: scale(0.9) translateY(-10px);
    }
    
    .pool-container.race-mode-expanded {
        max-height: 85vh !important;
        transform: scale(1.01);
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .pool-container.race-mode-expanded {
        max-height: 95vh !important;
        min-height: 80vh;
    }
    
    .race-mode-active .controls-section {
        opacity: 0.1;
        transform: scale(0.85) translateY(-15px);
    }
}

.swimmer {
    transition: left 3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.podium-container,
.results-list {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease-out;
}

.podium-container[style*="block"],
.results-list[style*="block"] {
    opacity: 1;
    transform: translateY(0);
}

/* === OPTIMISATIONS GÉNÉRALES === */

* {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.pool-container {
    will-change: transform;
    contain: layout style paint;
}

.btn {
    transition: all 0.2s ease;
}

.btn:disabled {
    transition: opacity 0.3s ease;
}

.swimmer,
.pool-container,
.controls-section {
    will-change: transform, opacity;
}

/* Optimisations pour beaucoup de nageurs */
@media (max-width: 768px) {
    .pool-extra-large .swimmer {
        border-width: 1px !important;
        box-shadow: 0 0 8px rgba(255,255,255,0.4) !important;
    }
    
    .pool-extra-large .lane {
        border-bottom-width: 1px !important;
    }
}



/* === ACCESSIBILITÉ === */

@media (prefers-reduced-motion: reduce) {
    .swimmer {
        transition: left 1s linear !important;
    }
}

/* === TRÈS PETITS SMARTPHONES EN PAYSAGE === */

@media screen and (max-height: 480px) and (orientation: landscape) {
    .pool-container {
        margin: 2px 0 !important;
        padding: 5px !important;
    }
    
    .course-container h1 {
        font-size: 1.2rem !important;
        margin-bottom: 5px !important;
    }
    
    .controls-section {
        margin-bottom: 3px !important;
    }
}

/* Bouton TOP DÉPART personnalisé */
.btn-start-race {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 50%, #ff6b35 100%);
    border: 3px solid #e55100;
    color: white;
    font-weight: bold;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    min-height: 70px;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.btn-start-race:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff8a65 0%, #ffb74d 50%, #ff8a65 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.6);
    border-color: #ff5722;
}

.btn-start-race:active:not(:disabled) {
    transform: translateY(0px);
    box-shadow: 0 2px 10px rgba(255, 107, 53, 0.4);
}

.btn-start-race:disabled {
    background: linear-gradient(135deg, #bdbdbd 0%, #9e9e9e 50%, #bdbdbd 100%);
    border-color: #757575;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.start-race-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.start-icon {
    font-size: 24px;
    margin-bottom: 2px;
    animation: swim 2s ease-in-out infinite;
}

.start-text {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 1px;
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.start-subtext {
    font-size: 10px;
    opacity: 0.9;
    font-weight: 600;
    margin-top: 1px;
}

/* Animation du nageur */
@keyframes swim {
    0%, 100% { transform: translateX(0px) rotate(0deg); }
    25% { transform: translateX(2px) rotate(-2deg); }
    50% { transform: translateX(0px) rotate(0deg); }
    75% { transform: translateX(-2px) rotate(2deg); }
}

/* Effet d'onde au clic */
.btn-start-race::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-start-race:active:not(:disabled)::before {
    width: 300px;
    height: 300px;
}

/* Responsive */
@media (max-width: 768px) {
    .btn-start-race {
        min-height: 60px;
    }
    
    .start-icon {
        font-size: 20px;
    }
    
    .start-text {
        font-size: 12px;
    }
    
    .start-subtext {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .btn-start-race {
        min-height: 55px;
    }
    
    .start-icon {
        font-size: 18px;
    }
    
    .start-text {
        font-size: 11px;
    }
    
    .start-subtext {
        font-size: 8px;
    }
}