:root {
    --echelle-zoom: 1;
}

body {
    margin: 0;
    padding: 20px;
    box-sizing: border-box; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #333;
    min-height: 100vh;
    overflow-x: hidden;
}

#fond-ecran {
    position: fixed;
    top: -50px; left: -50px; right: -50px; bottom: -50px;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-color: #333;
    transform: translate3d(var(--parallax-x, 0px), var(--parallax-y, 0px), 0);
    will-change: transform;
    pointer-events: none;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.caché { display: none !important; }

#top-left-bar {
    position: absolute; top: 20px; left: 20px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 10px; z-index: 50;
}

.btn-rond-top {
    width: 50px; height: 50px; border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8); border: none;
    font-size: 24px; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s; display: flex; align-items: center; justify-content: center;
}

#top-right-bar {
    position: absolute; top: 20px; right: 20px;
    display: flex; align-items: center; gap: 15px; z-index: 50;
}

#affichage-user {
    color: rgba(255, 255, 255, 0.8); font-size: 14px; font-style: italic;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

#btn-mode, #btn-logout {
    width: 50px; height: 50px; border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8); border: none;
    font-size: 24px; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s; display: flex; align-items: center; justify-content: center;
}

#btn-admin {
    background-color: #d32f2f; color: white; border: none; border-radius: 15px;
    padding: 10px 15px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

#titre-container { 
    display: flex; justify-content: center; align-items: center; gap: 15px; 
    margin-bottom: 20px; min-height: 40px; 
}
h1 { color: white; text-shadow: 2px 2px 4px rgba(0,0,0,0.7); margin: 0; cursor: pointer; transition: color 0.3s, opacity 0.3s; }
#titre-input {
    font-size: 32px; font-weight: bold; text-align: center; color: white;
    background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 8px;
    padding: 5px 15px; text-shadow: 2px 2px 4px rgba(0,0,0,0.7); outline: none;
}

body:not(.mode-edition) #titre-container.titre-masque { display: none !important; }
body.mode-edition #titre-container.titre-masque h1 { opacity: 0.4; text-decoration: line-through; }

#zone-widgets {
    display: flex; justify-content: center; align-items: center; gap: 20px;
    max-width: 1600px; 
    margin: 0 auto 30px auto;
}

.widget-box {
    background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 15px;
    height: 55px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); color: white; overflow: hidden;
}

#widget-horloge {
    font-size: 28px; font-weight: bold; padding: 0 25px; letter-spacing: 2px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

#widget-search {
    flex-grow: 1; max-width: 450px; padding: 0 5px 0 20px; justify-content: space-between;
}
#widget-search input {
    background: transparent; border: none; color: white; font-size: 18px;
    width: 100%; outline: none; font-family: inherit;
}
#widget-search input::placeholder { color: rgba(255, 255, 255, 0.7); }
#widget-search button {
    background: transparent; border: none; color: white; font-size: 20px;
    cursor: pointer; padding: 10px; transition: transform 0.2s;
}

#widget-notes {
    width: 220px;
    background: #fff9b1;
    color: #333;
    padding: 0;
    border: none;
    border-radius: 5px 15px 15px 15px;
}
#widget-notes textarea {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: transparent;
    border: none;
    resize: none;
    padding: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: #333;
    outline: none;
}
#widget-notes textarea::placeholder { color: #888; }

.widget-masque {
    display: none !important;
}

.barre-onglets {
    display: flex; justify-content: center; align-items: flex-end; gap: 10px; 
    max-width: 1600px;
    margin: 0 auto 40px auto; border-bottom: 2px solid rgba(255, 255, 255, 0.3); padding-bottom: 10px;
}
.onglet {
    position: relative; background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 15px; padding: 10px 20px;
    color: white; cursor: pointer; font-weight: bold; text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    transition: background 0.2s, transform 0.2s, font-size 0.2s; 
    outline: none;
}
.onglet.actif { 
    background: rgba(0, 123, 255, 0.6); 
    border-color: rgba(0, 123, 255, 0.8); 
    transform: translateY(-4px); 
    font-size: 1.15em; 
}
.onglet-special { background: #28a745; color: white; border: none; border-radius: 15px; padding: 10px 15px; cursor: pointer; }

/* Par défaut (tactile inclus), on affiche les boutons d'action des onglets en mode édition */
body.mode-edition .btn-action-onglet { display: flex; }
body.mode-edition .btn-deplacer-onglet { display: flex; }

.btn-action-onglet {
    display: none; position: absolute; top: -8px; 
    color: white; border: none; border-radius: 50%;
    width: 22px; height: 22px; font-size: 11px; cursor: pointer; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3); z-index: 10; padding: 0;
}
.btn-supprimer-onglet { right: -5px; background-color: #dc3545; }
.btn-renommer-onglet { right: 20px; background-color: #ff9800; }
.btn-dupliquer-onglet { right: 45px; background-color: #28a745; }

.btn-deplacer-onglet {
    display: none; position: absolute; top: 50%; transform: translateY(-50%);
    background-color: #17a2b8; color: white; border: none; border-radius: 50%;
    width: 22px; height: 22px; font-size: 10px; cursor: pointer; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3); z-index: 10; padding: 0;
}
.btn-deplacer-onglet.gauche { left: -10px; }
.btn-deplacer-onglet.droite { right: -10px; }

#info-url-directe {
    display: none; text-align: center; margin: -20px auto 30px auto;
    color: rgba(255, 255, 255, 0.8); font-size: 13px; background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px; border-radius: 8px; width: max-content; max-width: 90%;
    cursor: pointer; transition: background 0.2s, color 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
body.mode-edition #info-url-directe { display: block; }

#grille-raccourcis {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: calc(15px * var(--echelle-zoom));
    width: 100%;
    max-width: calc(1600px * var(--echelle-zoom));
    margin: 0 auto;
}

.cellule {
    aspect-ratio: 1; 
    position: relative; border-radius: 15px;
    border: 2px dashed transparent; transition: border-color 0.2s, background 0.2s;
}
body.mode-edition .cellule { border-color: rgba(255, 255, 255, 0.2); }
body.mode-edition .cellule.drag-survol { border-color: white; background: rgba(255, 255, 255, 0.2); }

.tuile {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; box-sizing: border-box;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(12px) saturate(150%); 
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-decoration: none; color: white; 
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2), inset 0 0 10px rgba(255, 255, 255, 0.15);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform;
    isolation: isolate;
}

.tuile::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        300px circle at var(--mouse-x, 0) var(--mouse-y, 0), 
        rgba(255, 255, 255, 0.25), 
        transparent 40%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
    pointer-events: none;
    will-change: background;
}

#grille-raccourcis:hover .tuile::after {
    opacity: 1;
}

.tuile::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    /* On place ici les couleurs et ombres du mode hover */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.1) 100%);
    box-shadow: 0 15px 35px 0 rgba(0, 0, 0, 0.3), inset 0 0 15px rgba(255, 255, 255, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
    pointer-events: none;
    will-change: opacity;
}

.tuile.type-groupe { border-width: 3px; border-style: solid; cursor: pointer; }

.mini-icones-container {
    display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 4px;
    width: calc(64px * var(--echelle-zoom)); height: calc(64px * var(--echelle-zoom)); margin-bottom: calc(10px * var(--echelle-zoom));
}
.mini-icones-container img { 
    width: 100%; height: 100%; border-radius: 4px; object-fit: contain; margin: 0; padding: 0; box-sizing: border-box;
}
.mini-emoji {
    width: 100%; height: 100%; border-radius: 4px; display: flex;
    align-items: center; justify-content: center; font-size: calc(20px * var(--echelle-zoom)); margin: 0; padding: 0; box-sizing: border-box;
}

.tuile > img {
    width: calc(64px * var(--echelle-zoom)); height: calc(64px * var(--echelle-zoom));
    margin-bottom: calc(5px * var(--echelle-zoom)); border-radius: 8px; 
    pointer-events: none; object-fit: contain;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.4));
}
.tuile-emoji {
    width: calc(64px * var(--echelle-zoom)); height: calc(64px * var(--echelle-zoom));
    margin-bottom: calc(5px * var(--echelle-zoom)); border-radius: 8px; pointer-events: none;
    display: flex; align-items: center; justify-content: center; font-size: calc(48px * var(--echelle-zoom));
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.4));
}

.tuile span { 
    font-weight: bold; text-shadow: 1px 1px 2px rgba(0,0,0,0.8); pointer-events: none; 
    font-size: calc(1rem * var(--echelle-zoom)); text-align: center; padding: 0 5px; word-break: break-word;
    line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.btn-action-tuile {
    display: none; position: absolute; top: -10px; border: none; border-radius: 50%;
    width: 26px; height: 26px; font-size: 14px; cursor: pointer; align-items: center; justify-content: center;
    color: white; box-shadow: 0 2px 5px rgba(0,0,0,0.3); z-index: 10;
}
.btn-supprimer { right: -10px; background-color: #dc3545; }
.btn-editer { left: -10px; background-color: #007BFF; }
body.mode-edition .btn-action-tuile { display: flex; }

body.mode-edition .tuile { cursor: grab; }
body.mode-edition .tuile:active { cursor: grabbing; }
.tuile.en-deplacement { opacity: 0.4; transform: scale(0.95); z-index: 100; }

#btn-ouvrir-modal {
    position: fixed; bottom: 30px; right: 30px; width: 65px; height: 65px; border-radius: 50%;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: white; font-size: 28px; border: none; cursor: pointer; 
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.6); 
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}

.modal-superposition {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal-contenu { 
    background: white; padding: 30px; border-radius: 10px; 
    width: 700px; max-width: 95vw; max-height: 90vh; overflow-y: auto; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.5); 
}

.grille-formulaire { display: grid; grid-template-columns: 280px 1fr; gap: 30px; }
.pleine-largeur { grid-column: 1 / -1; }
.modal-contenu h2 { margin-top: 0; font-size: 20px; }
.modal-contenu input[type="text"], .modal-contenu input[type="url"], .modal-contenu input[type="password"], .select-style {
    width: 100%; padding: 10px; margin: 10px 0 15px 0; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box; font-size: 14px;
}
.choix-icone-groupe { display: flex; gap: 15px; margin-bottom: 10px; font-size: 14px; color: #333;}
.btn-groupe { display: flex; justify-content: space-between; margin-top: 20px;}
.btn { padding: 10px 15px; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; }
.btn-valider { background: #28a745; color: white; }
.btn-annuler { background: #dc3545; color: white; }

#grille-interne-groupe { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; }
.ligne-enfant-groupe { display: flex; align-items: center; justify-content: space-between; background: #f1f1f1; padding: 10px; border-radius: 8px; }
.ligne-enfant-groupe .visuel { width: 32px; height: 32px; border-radius: 4px; margin-right: 10px; background: white; display: flex; align-items: center; justify-content: center; font-size: 20px;}
.ligne-enfant-groupe img.visuel { object-fit: cover; }
.ligne-enfant-groupe .info { display: flex; align-items: center; flex-grow: 1; overflow: hidden; }
.ligne-enfant-groupe a { text-decoration: none; color: #333; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-sortir-groupe { background: #ff9800; color: white; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; }

.ligne-admin { display: flex; align-items: center; justify-content: space-between; background: #f9f9f9; padding: 15px; border: 1px solid #eee; border-radius: 8px; margin-bottom: 10px; }
.ligne-admin .actions { display: flex; gap: 10px; }
.btn-reset { background: #ff9800; color: white; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.btn-del { background: #dc3545; color: white; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; }

@media (max-width: 1400px) {
    .tuile > img, .tuile-emoji, .tuile-fallback, .mini-icones-container { width: calc(48px * var(--echelle-zoom)); height: calc(48px * var(--echelle-zoom)); margin-bottom: calc(4px * var(--echelle-zoom)); }
    .tuile-emoji { font-size: calc(36px * var(--echelle-zoom)); }
    .tuile-fallback { font-size: calc(26px * var(--echelle-zoom)); }
    .tuile span { font-size: calc(0.85rem * var(--echelle-zoom)); }
}

@media (max-width: 1100px) {
    .tuile > img, .tuile-emoji, .tuile-fallback, .mini-icones-container { width: calc(36px * var(--echelle-zoom)); height: calc(36px * var(--echelle-zoom)); margin-bottom: calc(2px * var(--echelle-zoom)); }
    .tuile-emoji { font-size: calc(28px * var(--echelle-zoom)); }
    .tuile-fallback { font-size: calc(20px * var(--echelle-zoom)); }
    .tuile span { font-size: calc(0.7rem * var(--echelle-zoom)); }
}

@media (max-width: 900px) {
    .tuile > img, .tuile-emoji, .tuile-fallback, .mini-icones-container { width: calc(28px * var(--echelle-zoom)); height: calc(28px * var(--echelle-zoom)); margin-bottom: 0; }
    .tuile-emoji { font-size: calc(22px * var(--echelle-zoom)); }
    .tuile-fallback { font-size: calc(16px * var(--echelle-zoom)); }
    .tuile span { font-size: calc(0.6rem * var(--echelle-zoom)); line-height: 1.1; }
}

@media (max-width: 768px) {
    #top-left-bar, #top-right-bar { position: relative; top: 0; left: 0; right: 0; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
    #titre-input { font-size: 24px; width: 80%; }
    #zone-widgets { flex-direction: column; gap: 10px; }
    #widget-search { width: 100%; box-sizing: border-box; }
    .barre-onglets { flex-wrap: wrap; }
    #grille-raccourcis { grid-template-columns: repeat(4, 1fr); gap: calc(10px * var(--echelle-zoom)); }
    .modal-contenu { max-width: 90% !important; padding: 20px; }
    .grille-formulaire { grid-template-columns: 1fr; gap: 0; }
    .tuile span { font-size: calc(0.8rem * var(--echelle-zoom)); }
	.mini-icones-container, .tuile > img, .tuile-emoji, .tuile-fallback { width: calc(48px * var(--echelle-zoom)); height: calc(48px * var(--echelle-zoom)); }
    .tuile-emoji { font-size: calc(36px * var(--echelle-zoom)); }
    .tuile-fallback { font-size: calc(26px * var(--echelle-zoom)); }
}

.tuile-fallback {
    width: calc(64px * var(--echelle-zoom)); height: calc(64px * var(--echelle-zoom));
    margin-bottom: calc(5px * var(--echelle-zoom)); border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: calc(34px * var(--echelle-zoom)); font-weight: bold; color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3); box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

/* =================================================== */
/* GESTION DES HOVERS UNIQUEMENT SUR LES APPAREILS COMPATIBLES */
/* =================================================== */
@media (hover: hover) {
    /* Sur desktop (souris), on masque les boutons d'action des onglets par défaut pour les révéler au hover */
    body.mode-edition .btn-action-onglet,
    body.mode-edition .btn-deplacer-onglet {
        display: none;
    }
    
    body.mode-edition .onglet:hover .btn-action-onglet,
    body.mode-edition .onglet:hover .btn-deplacer-onglet {
        display: flex;
    }

    /* Activation des effets cosmétiques seulement si la souris est disponible */
    .btn-rond-top:hover { transform: scale(1.1); }
    #btn-mode:hover, #btn-logout:hover { transform: scale(1.1); }
    #btn-admin:hover { transform: scale(1.05); background-color: #b71c1c; }
    body.mode-edition h1:hover { color: #ffd700; }
    #widget-search button:hover { transform: scale(1.2); }
    .onglet:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-2px); }
    .onglet.actif:hover { background: rgba(0, 123, 255, 0.8); }
    .btn-action-onglet:hover { transform: scale(1.15); }
    .btn-supprimer-onglet:hover { background-color: #c82333; }
    .btn-renommer-onglet:hover { background-color: #e68a00; }
    .btn-dupliquer-onglet:hover { background-color: #218838; }
    .btn-deplacer-onglet:hover { background-color: #138496; transform: translateY(-50%) scale(1.15); }
    #info-url-directe:hover { background: rgba(0, 0, 0, 0.6); color: #ffd700; }
    
	body:not(.mode-edition) .tuile:hover { 
		transform: translateY(-3px) scale(1.03); 
		/* La modification du gradient et de la shadow ont été retirées d'ici */
	}
	
	body:not(.mode-edition) .tuile:hover::before {
		opacity: 1; /* C'est le pseudo-élément qui s'allume en douceur, géré à 100% par le GPU */
	}
    
    .btn-supprimer:hover { background-color: #c82333; transform: scale(1.1); }
    .btn-editer:hover { background-color: #0056b3; transform: scale(1.1); }
    #btn-ouvrir-modal:hover { transform: scale(1.1); box-shadow: 0 0 25px rgba(0, 242, 254, 0.8); }
    .btn-sortir-groupe:hover { background: #e68a00; }
}