html {
    height: 100%;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%; /* Assure que body couvre toute la hauteur */
    position: relative; /* Pour positionner ::before */
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('icon.png');
    background-size: 100% auto; /* Adapte à la largeur, hauteur auto */
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.15;
    z-index: -1;
}

header {
    background: linear-gradient(to right, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
    color: white;
    width: 100%;
    text-align: center;
    padding: 2px 0; /* Bandeau fin */
    position: relative; /* Pour positionner les boutons */
}

header h2 {
    margin: 0;
    font-size: 2.5em; /* Taille ajustée pour h2 */
}

#sort-menu-btn {
    position: absolute;
    top: 2px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    display: none; /* Caché par défaut, affiché si ≥ 2 tuiles */
}

#sort-menu-btn:hover {
    opacity: 0.7;
}

.sort-menu {
    position: absolute;
    top: 100%;
    right: 10px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    padding: 5px 0;
}

.sort-option {
    padding: 5px 15px;
    cursor: pointer;
    font-size: 1em;
    color: black; /* Correction : texte en noir pour lisibilité */
}

.sort-option:hover {
    background-color: #f0f0f0;
}

.sort-option.disabled {
    color: gray;
    cursor: not-allowed;
    background-color: #f8f9fa;
}

.sort-option.disabled:hover {
    background-color: #f8f9fa;
}

.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 10px;
    width: 100%;
    max-width: 800px;
}

.tile {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    user-select: none;
    position: relative;
}

.tile h2 {
    margin: 0;
    font-size: 0.6em; /* Réduction de moitié */
    font-weight: normal; /* Trigramme en normal */
    color: #666; /* Trigramme en gris */
}

.tile p {
    margin: 5px 0 0;
    color: #000; /* Nom de la gare en noir */
    font-weight: bold; /* Nom de la gare en gras */
}

.add-tile {
    background: linear-gradient(to right, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
    color: white;
    font-size: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-btn, .delete-btn {
    position: absolute;
    top: 5px;
    font-size: 0.8em;
    padding: 2px 5px;
    border: none;
    cursor: pointer;
}

.edit-btn {
    right: 30px;
    background-color: #ffc107;
    color: white;
}

.delete-btn {
    right: 5px;
    background-color: #dc3545;
    color: white;
}

dialog {
    border: none;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    max-width: 90%;
    width: 400px;
}

dialog h2 {
    margin-top: 0;
}

dialog input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

dialog ul {
    list-style: none;
    padding: 0;
    margin: 0 0 10px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

dialog li {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
}

dialog li:last-child {
    border-bottom: none;
}

dialog li:hover {
    background-color: #f0f0f0;
}

dialog button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px;
    width: 100%;
    cursor: pointer;
    border-radius: 4px;
}

dialog button:hover {
    background-color: #0056b3;
}

#tableau-section {
    width: 100%;
    max-width: 800px;
    margin: 10px auto;
    text-align: center;
}

#close-tableau {
    background: linear-gradient(to right, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 10px;
}

#close-tableau:hover {
    background: linear-gradient(to left, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
}

#tableau-iframe {
    width: 100%;
    height: 600px; /* Ajustable selon tes besoins */
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* Classe pour réduire la grid des tuiles */
.tiles-grid.reduced {
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.search-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* Pour wrap si écran trop petit */
}

.search-container input {
    flex: 1;
    min-width: 200px; /* Empêche rétrécissement excessif */
}

#geo-btn {
    background: linear-gradient(to right, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
    color: white;
    border: none;
    padding: 2px 5px;
    margin-left: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
}

#geo-btn:hover {
    background: linear-gradient(to left, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
}

#close-modal {
    background: linear-gradient(to right, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
    color: white;
    border: none;
    padding: 10px;
    width: 100%;
    cursor: pointer;
    border-radius: 4px;
}

#close-modal:hover {
    background: linear-gradient(to left, #7d206f, #b01678, #c21758, #da1d33, #eb1925);
}

dialog li.disabled {
    color: gray;
    cursor: not-allowed;
    background-color: #f8f9fa; /* Fond léger pour distinction */
}

dialog li.disabled:hover {
    background-color: #f8f9fa; /* Pas de hover effect */
}

footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    text-align: center;
    font-size: 0.8em;
    font-style: italic;
    color: #666;
    padding: 5px 0;
    background-color: #f4f4f4;
}

footer a {
    color: #007bff;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}