html, body {
    height: 100%;
    margin: 5px;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scroll while allowing vertical */
    overflow-y: auto; /* Allow vertical scrolling when needed */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: calc(100% - 10px); /* Account for the 5px margin top and bottom */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    padding-bottom: 120px; /* Add space for the footer */
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

h2 {
    text-align: center;
    color: #3498db;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
}

.file-input-container {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

input[type="file"] {
    display: none;
}

.custom-file-input {
    background-color: #3498db;
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-right: 15px;
}

.custom-file-input:hover {
    background-color: #2980b9;
}

#file-name {
    font-style: italic;
    color: #7f8c8d;
}

.button {
    justify-content: center;
    background-color: #2ecc71;
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: block;
    margin: 20px auto;
}

.button:hover {
    background-color: #27ae60;
}

.button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.track-info {
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#track-details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

#track-details p {
    margin: 5px 0;
}

.info-item {
    border-left: 3px solid #3498db;
    padding-left: 10px;
    margin-bottom: 10px;
}

.info-label {
    font-weight: bold;
    color: #7f8c8d;
}

.header, .track-selector, .button-container, .footer {
    flex-shrink: 0;
}

.header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
    text-align: center;
}

#logo-rocs {
    max-height: 100px;
    margin: 0 auto;
    display: block;
}

.footer-logo {
    text-align: center;
    margin: 20px 0;
}

.footer-logo-img {
    max-width: 200px;
    height: auto;
}

#logo-ffs-occitanie {
    max-width: 200px;
    height: auto;
    display: block;
    margin: 0 auto;
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
}

.footer {
    padding: 5px 0;
    text-align: center;
    background-color: #f5f5f5;
    width: 100%;
    position: absolute; /* Position at the bottom */
    bottom: 0;
    left: 0;
    height: 100px; /* Fixed height for footer */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.track-selector {
    margin-bottom: 20px;
    text-align: center;
}

.track-dropdown {
    width: 80%;
    max-width: 500px;
    padding: 10px 15px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.track-dropdown:focus {
    outline: none;
    border-color: #3498db;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
}

#call-marshal {
    background-color: #28a745;
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#call-marshal i {
    margin-right: 8px;
}

#download-gpx {
    background-color: blue;
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#technical-rules {
    background-color: #e67e22;
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#download-pdf {
    background-color: blueviolet;
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Masquer le bouton PDF quand il n'y a pas de fichier PDF */
#download-pdf.no-pdf {
    display: none;
}

#link-dc {
    background-color: #1e90ff; /* DodgerBlue */
    color: white;
    text-decoration: none;
    padding: 7px 10px; /* Ajusté pour correspondre aux autres boutons */
    border-radius: 4px;
    display: inline-flex;
    align-items: center; /* Centrage vertical des éléments */
    justify-content: center;
    cursor: pointer;
    min-width: 50px; /* Largeur minimale réduite */
    max-width: 60px; /* Largeur maximale légèrement augmentée */
    position: relative; /* Pour le positionnement absolu de l'icône */
}

/* Ajout du style pour l'icône DC */
#link-dc i {
    display: none; /* Masquer l'icône Font Awesome */
}

#link-dc::before {
    content: "";
    display: inline-block;
    width: 12px; /* Taille optimale */
    height: 12px; /* Taille optimale */
    background-image: url('../img/dc-favicon.ico');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-right: 3px;
    position: relative; /* Améliore le positionnement */
    top: 0; /* Aligné avec le texte */
    vertical-align: middle; /* Assure un alignement vertical correct */
}

/* Masquer le bouton DC quand il n'y a pas de lien */
#link-dc.no-link {
    display: none;
}

#send-sms {
    background-color: green;
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#speleo-secours {
    background-color: #FF0000; /* Rouge vif */
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Styles pour les boutons compacts */
.compact-button {
    padding: 7px 10px !important;
    font-size: 14px !important;
    margin: 5px !important;
    min-width: 70px;
}

/* Ajustements pour les petits écrans */
@media (max-width: 480px) {
    .button-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 3px;
    }
    
    .compact-button {
        padding: 6px 8px !important;
        font-size: 12px !important;
        margin: 3px !important;
        min-width: 60px;
    }
    
    .compact-button i {
        margin-right: 2px !important;
    }
}

/* Pour les écrans très petits */
@media (max-width: 350px) {
    .button-container {
        flex-direction: column;
        align-items: center;
    }
    
    .compact-button {
        width: 80%;
        margin: 3px 0 !important;
    }
}

/* Styles du footer pour les appareils non-Android */
body:not(.android-device) .footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

/* S'assurer que le contenu n'est pas caché sous le footer sur les appareils non-Android */
body:not(.android-device) .container {
    padding-bottom: 110px; /* Ajouter du padding supplémentaire */
}

/* Additional mobile-specific fixes */
@media (max-width: 768px) {
    body {
        min-height: -webkit-fill-available; /* iOS Safari specific fix */
    }
    
    .container {
        padding-bottom: 80px; /* Smaller padding on mobile */
    }
    
    body:not(.android-device) .container {
        padding-bottom: 90px; /* Ajuster pour les petits écrans non-Android */
    }
    
    .footer {
        height: 70px; /* Smaller footer on mobile */
    }
    
    .flex-break {
        flex-basis: 100%;
        height: 0;
    }
}

/* On larger screens, don't break the flow */
@media (min-width: 769px) {
    .flex-break {
        flex-basis: auto;
        height: auto;
    }
}

.hidden {
    display: none;
}

/* Styles pour la popin d'alerte */
.alert-popup-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.alert-popup {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    max-width: 80%;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.alert-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    margin: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    z-index: 2100; /* Assurer que la croix est toujours visible */
}

.alert-popup-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    margin-right: 40px; /* Espace pour éviter que le texte ne se superpose avec la croix */
    color: #d9534f; /* Couleur rouge pour attirer l'attention */
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.alert-popup-content {
    margin-top: 10px;
    font-size: 16px;
    line-height: 1.5;
}