/* =========================================
   WORLDFARM - STYLE CSS PRINCIPAL
   Version: 12.2
   ========================================= */

:root {
    --ui-zoom: 1;
}

/* Styles généraux */
html,
body {
    font-family: 'Fredoka', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* On remplace le 'Press Start 2P' par un style plus "Ranch" */
h1, .game-logo {
    font-family: 'Luckiest Guy', cursive;
    letter-spacing: 2px;
    color: #f39c12; /* Un bel orange/jaune terreux */
}

/* On rend les boutons et titres de menus plus lisibles */
h2, h3, .font-bold, button {
    font-family: 'Fredoka', sans-serif !important;
    font-weight: 700;
    text-transform: none !important; /* On arrête les majuscules forcées */
}

/* Pour ton journal ou les descriptions (Optionnel) */
#tab-content-journal {
    font-family: 'Patrick Hand', cursive;
    font-size: 1.1rem;
}
/* Application du zoom UI global */
.modal-content-wrapper,
#control-panel,
#chat-container,
#game-hud-bar,
#intro-overlay,
.leaflet-control-container,
#shop-container,
#market-container {
    zoom: var(--ui-zoom);
}

/* Intro Overlay */
#intro-overlay {
    position: fixed;
    inset: 0;
    background-color: #000;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease-out;
}

#intro-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* L'Overlay (Fond noir derrière le tchat) */
#chat-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#chat-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Empêche la fenêtre de tchat d'interférer si elle est chargée */
#chat-overlay:not(.open) {
    pointer-events: none;
    opacity: 0;
    z-index: -1;
}

/* La fenêtre principale du Tchat */
#chat-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#chat-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* 2. LA FENÊTRE PRINCIPALE */
#chat-container {
    width: 900px !important;       /* Largeur confortable */
    height: 80vh !important;       /* 80% de la hauteur écran */
    max-width: 95vw !important;
    max-height: 90vh !important;
    background-color: #f3f4f6;     /* Fond gris clair global */
    border-radius: 20px;           /* Coins bien arrondis */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); /* Grosse ombre */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255,255,255,0.8);
}

#chat-overlay.open #chat-container {
    transform: scale(1);
}

/* 3. L'EN-TÊTE (HEADER) */
#chat-container > div:first-child { /* Cible la div du haut */
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 4px 15px -5px rgba(0, 0, 0, 0.05);
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 4. LA MISE EN PAGE (COLONNES) */
.chat-layout {
    display: flex;
    height: 100%; /* Prend tout l'espace restant */
    overflow: hidden; /* Empêche le débordement global */
    background-color: #f3f4f6;
}

/* Barre latérale (Salons) */
.chat-sidebar {
    width: 240px;
    background-color: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 10px;
}

.chat-room-btn {
    width: 100%;
    text-align: left;
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.chat-room-btn:hover {
    background-color: #f9fafb;
    color: #374151;
}

.chat-room-btn.active {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #dbeafe;
}

/* Zone principale (Messages + Input) */
.chat-main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Important pour le scroll */
    position: relative;
}

/* 5. LISTE DES MESSAGES */
#chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px; /* Espace entre les messages */
    scroll-behavior: smooth;
}

/* Styles des messages (Bulles) */
.chat-message-item {
    display: flex;
    align-items: flex-end; /* Aligner l'avatar en bas */
    gap: 10px;
    max-width: 85%;
    
}

/* Messages des AUTRES (Gauche) */
.chat-message-item:not(.own-message):not(.system-message) {
    align-self: flex-start;
}

.chat-message-item:not(.own-message):not(.system-message) .message-bubble {
    background-color: white;
    color: #374151;
    border-radius: 18px 18px 18px 4px; /* Coin bas-gauche pointu */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #f3f4f6;
}

/* Mes messages (Droite) */
.chat-message-item.own-message {
    align-self: flex-end;
    flex-direction: row-reverse; /* Avatar à droite */
}

.chat-message-item.own-message .message-bubble {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-radius: 18px 18px 4px 18px; /* Coin bas-droit pointu */
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.message-bubble {
    padding: 10px 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

/* Avatars */
.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 2px solid white;
}

/* Pseudo et Heure */
.chat-pseudo-label {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 4px;
    margin-left: 4px;
    display: block;
}

.chat-time {
    font-size: 0.65rem;
    display: block;
    text-align: right;
    margin-top: 4px;
    opacity: 0.7;
}

/* 6. ZONE DE SAISIE */
.chat-input-area {
    background-color: white;
    padding: 15px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#chat-input {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
    padding: 12px 20px;
    border-radius: 30px !important; /* Bien rond */
}

#chat-input:focus {
    background-color: white;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* 7. VERSION MOBILE */
@media (max-width: 768px) {
    #chat-container {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
    }

    .chat-layout {
        flex-direction: column; /* Empile sidebar et main */
    }

    .chat-sidebar {
        width: 100%;
        flex-direction: row; /* Onglets horizontaux */
        height: auto;
        padding: 5px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .chat-room-btn {
        margin-bottom: 0;
        margin-right: 5px;
        white-space: nowrap;
        width: auto;
    }

}

/* Animation */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Boutons DM (Sidebar) */
.chat-dm-btn {
    background-color: white;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat-dm-btn:hover {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

/* RESPONSIVE CHAT (Mobile) */
@media (max-width: 768px) {
    /* 1. Le conteneur principal */
    #chat-container {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        background: #ffffff !important;
        z-index: 999999 !important;
        
        /* On enlève le !important sur le display pour permettre au JS de le modifier */
        display: flex; 
        flex-direction: column;
        overflow: hidden !important; 
    }

    /* 2. RÈGLE CRITIQUE : Si la classe 'hidden' est là, on force la disparition */
    #chat-container.hidden {
        display: none !important;
    }

    /* 3. Le bouton fermer (Fixe et au-dessus de tout) */
    #chat-close-btn {
        position: fixed !important; 
        top: 15px !important;
        right: 15px !important;
        z-index: 1000000 !important;
        
        display: flex !important;
        width: 40px !important;
        height: 40px !important;
        background-color: #ef4444 !important; 
        color: white !important;
        border-radius: 50% !important;
        align-items: center;
        justify-content: center;
        cursor: pointer !important;
    }

    /* 4. Gestion du scroll des messages */
    #chat-container > div:nth-child(3) {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        padding-bottom: 20px !important;
    }

    /* 5. Les éléments qui ne doivent pas bouger */
    #chat-container > div:first-child,
    #chat-container > div:nth-child(2), 
    #chat-container > div:last-child {
        flex: 0 0 auto !important;
    }
}

.chat-badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    color: white;
    margin-left: 6px;
    vertical-align: middle;
}

.chat-badge-admin { background-color: #EF4444; }
.chat-badge-moderator { background-color: #3B82F6; }

.chat-timestamp {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-right: 8px;
    float: left;
    line-height: 1.6;
}

.chat-link {
    color: #2563eb;
    text-decoration: underline;
    font-weight: 600;
}

.chat-link:hover { color: #1d4ed8; }

.chat-mention-me {
    background-color: #fef08a;
    color: #a16207;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
}
.chat-message-item.own-message .chat-mention-me {
    background-color: #fef9c3;
    color: #a16207;
}

.chat-mention-other {
    font-weight: 700;
    padding: 1px 2px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.05);
}

#chat-close-btn {
    font-size: 1.8rem;
    line-height: 1;
    font-weight: bold;
}

.chat-delete-btn {
    font-weight: bold;
    color: #ef4444;
    background-color: transparent;
    border: none;
    padding: 0 5px;
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
    float: right;
}

.chat-message-item:hover .chat-delete-btn { opacity: 1; }

.chat-room-btn {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s ease-in-out;
    border-bottom: 3px solid transparent;
}

.chat-room-btn:not(.active) {
    background-color: #e5e7eb;
    color: #6b7280;
}

.chat-room-btn:not(.active):hover {
    background-color: #d1d5db;
}

.chat-room-btn.active {
    background-color: #ffffff;
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.chat-dm-btn {
    background-color: #8b5cf6;
    color: white;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.chat-dm-btn:hover { background-color: #7c3aed; }

/* HUD BAR */
#game-hud-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    background-color: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(4px);
    z-index: 3000 !important; /* Au-dessus */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#game-hud-bar > div > div {
    display: flex;
    align-items: center;
    white-space: nowrap;
    font-size: 0.9rem;
    gap: 8px;
}

.hud-group-left-and-center {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 20px;
    flex-grow: 1;
    flex-shrink: 1;
    overflow: hidden;
}

#game-hud-bar span,
#game-hud-bar div {
    color: white !important;
}

#game-hud-bar i[class*="text-"] {
    color: inherit !important;
}

.hud-indicator {
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding-left: 15px !important;
}

.hud-indicator > span.font-bold {
    color: #bdc3c7 !important;
    font-size: 0.8rem;
}

.hud-indicator > div {
    color: white !important;
    font-weight: bold;
    font-size: 1rem;
}

.hud-group-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 15px;
}

#season-display #season-icon {
    color: inherit !important;
}

#next-day-countdown {
    font-weight: bold;
    font-size: 1.1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding-left: 15px !important;
}

#game-hud-bar #radio-agri-display {
    display: none !important;
    flex-grow: 1;
    text-align: center;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 10px;
    border-radius: 4px;
    margin-left: 10px;
    border-left: none;
    gap: 4px;
}

#radio-agri-display i {
    color: white !important;
}

/* MEDIA QUERIES HUD */
@media (max-width: 1600px) {
    #game-hud-bar {
        font-size: 0.8rem !important;
        padding: 0 5px !important;
    }

    #game-hud-bar i {
        font-size: 1rem !important;
        margin-right: 4px !important;
    }

    .hud-group-left-and-center {
        gap: 8px !important;
        padding: 0 !important;
    }

    .hud-indicator {
        padding-left: 8px !important;
    }

    .hud-indicator > span.font-bold {
        display: none !important;
    }

    /* Icônes de remplacement pour mobile */
    .hud-indicator:has(> #money-display)::before { content: '💰'; margin-right: 3px; }
    .hud-indicator:has(> #total-hectares-display)::before { content: '🗺️'; margin-right: 3px; }
    .hud-indicator:has(> div > #water-display)::before { content: '💧'; margin-right: 3px; }
    .hud-indicator:has(> div > #energy-display)::before { content: '⚡'; margin-right: 3px; }

    .hud-indicator > div,
    .hud-indicator > div > div {
        font-size: 0.85rem !important;
        font-weight: 600;
    }
}

@media (max-width: 1366px) {
    #wind-display,
    #weather-forecast-display {
        display: none !important;
    }

    #season-text {
        font-size: 0.75rem !important;
        max-width: 120px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    #next-day-countdown {
        font-size: 0.75rem !important;
        padding-left: 8px !important;
    }
}

@media (max-width: 768px) {
    #weather-display,
    #weather-forecast-display,
    #temperature-display,
    #wind-display,
    #season-display,
    #next-day-countdown,
    #radio-agri-display,
    .hud-indicator:has(#total-hectares-display),
    .hud-indicator:has(#water-display),
    .hud-indicator:has(#energy-display) {
        display: none !important;
    }

    .hud-group-left-and-center {
        justify-content: flex-start !important;
        padding-left: 10px !important;
        width: auto !important;
    }

    #money-display {
        font-size: 1.1rem !important;
    }

    #toggle-panel-btn {
        padding: 8px 12px !important;
        min-width: 44px;
        display: flex;
        justify-content: center;
    }

    #toggle-panel-btn span {
        display: none;
    }

    #toggle-panel-btn i {
        font-size: 1.4rem !important;
        margin: 0 !important;
    }

    #mobile-dashboard-stats {
        display: block !important;
    }
}

@media (min-width: 769px) {
    #mobile-dashboard-stats {
        display: none !important;
    }
}

/* Bouton Menu */
#toggle-panel-btn {
    background-color: rgba(59, 130, 246, 0.8);
    color: white !important;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 8px;
}

#toggle-panel-btn:hover {
    background-color: rgba(59, 130, 246, 1);
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#toggle-panel-btn i {
    color: white !important;
    margin-left: 0 !important;
}

/* Control Panel (Le grand menu) */
.control-panel {
    position: fixed;
    top: 50px;
    right: 0;
    width: 100vw;
    height: calc(100vh - 50px);
    z-index: 9000 !important; /* Devant la bannière */
    background-color: rgba(255, 255, 255, 0.98);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    padding-bottom: 100px;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

.control-panel.open {
    transform: translateX(0);
}

@media (min-width: 768px) {
    .control-panel {
        top: 110px;
        right: 20px;
        left: auto;
        width: 700px;
        height: auto;
        max-height: calc(100vh - 130px);
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        padding-bottom: 15px;
    }

    .control-panel:not(.open) {
        transform: translateX(calc(100% + 20px));
    }

    .fixed-bottom-panel-buttons {
        position: static;
        padding: 0;
        box-shadow: none;
        border-top: none;
        z-index: auto;
        width: auto;
    }

    .tab-button span {
        display: inline;
    }
}

/* Modales */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 11000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.modal-content-wrapper {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: zoomIn 0.3s ease-out;
}

@media (min-width: 1280px) {
    .modal-content-wrapper.modal-admin-width {
        max-width: 1400px;
    }
    .modal-content-wrapper.modal-large-width {
        max-width: 1200px;
        height: 1000px;
    }
}

.modal-close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 2.5rem;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    z-index: 3010;
}

.modal-close-btn:hover {
    color: #1f2937;
}

.modal-body-container {
    padding: 1.5rem;
    overflow-y: auto;
    padding-bottom: 80px;
}

@media (min-width: 768px) {
    .modal-body-container {
        padding-bottom: 1.5rem;
    }
}

/* Popups DM */
#dm-popup-container {
    position: fixed;
    bottom: 50px;
    left: 90px;
    z-index: 2501;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dm-notification-popup {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    width: 280px;
    cursor: pointer;
    border: 2px solid #3b82f6;
    animation: fadeInUp 0.5s ease-out;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.dm-notification-popup:hover {
    transform: scale(1.02);
}

.dm-notification-popup-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
    margin-right: 10px;
}

.dm-notification-popup-content {
    overflow: hidden;
    flex-grow: 1;
}

.dm-notification-popup-content strong {
    display: block;
    color: #1f2937;
    font-weight: 700;
}

.dm-notification-popup-content p {
    color: #4b5563;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-notification-popup-close {
    font-size: 1.5rem;
    color: #9ca3af;
    margin-left: 10px;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0 5px;
    line-height: 1;
}

.dm-notification-popup-close:hover {
    color: #1f2937;
}

/* Notifications Toast */
#toast-container {
    z-index: 12000 !important;
}

#toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3e50;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s, bottom 0.5s;
}

#toast-notification.show {
    opacity: 1;
    visibility: visible;
    bottom: 80px !important;
}

/* Event Banner */
.event-banner {
    position: fixed;
    top: -100px;
    left: 0;
    width: 100%;
    background: linear-gradient(45deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    padding: 10px 5rem;
    text-align: center;
    z-index: 2900 !important;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: top 0.5s ease-in-out;
    box-sizing: border-box;
}

.event-banner.show {
    top: 50px;
}

/* Map & Leaflet */
#map {
    height: 100vh;
    width: 100%;
    cursor: default;
}

#map-overlay {
    position: fixed;
    inset: 0;
    z-index: 998;
    pointer-events: none;
    transition: background-color 1.5s ease-in-out;
}

.leaflet-control-container {
    z-index: 2002 !important;
}

.leaflet-top {
    top: 90px;
    transition: top 0.5s ease-in-out;
}

body:has(.event-banner.show) .leaflet-top {
    top: 160px;
}

#info-panel {
    background-color: rgba(44, 62, 80, 0.95);
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    font-size: 1.1rem;
    text-align: center;
    transition: top 0.5s ease-in-out;
}

.info-panel {
    top: 70px !important;
}

body:has(.event-banner.show) .info-panel {
    top: 120px !important;
}

#custom-draw-actions {
    z-index: 4001 !important; /* Devant le panneau d'info pour être sûr */
    position: fixed !important; /* S'assurer qu'il reste à l'écran */
}
.event-banner, #catastrophe-banner {
    z-index: 3999 !important; /* Doit être sous 4000 */
}
#custom-draw-actions a {
    font-size: 1.4em;
    line-height: 1.4;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Auth Overlay */
#auth-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    z-index: 2000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#auth-overlay.hidden {
    display: none;
    pointer-events: none;
}

#background-container {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

.auth-bg-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: opacity 2.5s ease-in-out;
    animation: ken-burns 25s ease-out alternate infinite;
}

#auth-overlay h1 {
    font-size: 4rem;
    line-height: 1;
    margin-top: 0;
    padding-top: 8vh;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    #auth-overlay h1 {
        font-size: 3rem;
        padding-top: 5vh;
    }
}

#auth-overlay > .relative.flex-grow {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    min-height: auto;
    padding-top: 20px;
    padding-bottom: 20px;
}

/* Cookie Banner */
#cookie-consent-banner.hidden {
    display: none;
}

/* Icons & Markers */
.tractor-icon, .location-icon, .user-location-icon, 
.harvester-icon, .feller-buncher-icon, .forage-harvester-icon,
.location-icon-farm, .location-icon-coop, .location-icon-bank,
.location-icon-sawmill, .chicken-coop-icon, .stable-icon, .hive-icon,
.location-icon-solar, .location-icon-wind, .location-icon-farmshop, .location-icon-firestation {
    text-shadow: 0px 0px 3px rgba(0, 0, 0, 0.5);
}

.tractor-icon { color: #e74c3c; font-size: 24px; }
.harvester-icon { color: #f39c12; font-size: 24px; }
.feller-buncher-icon { color: #228B22; font-size: 24px; }
.forage-harvester-icon { color: #03f869; font-size: 24px; }
.location-icon-farm { color: #2ecc71; font-size: 28px; }
.location-icon-coop { color: #3498db; font-size: 24px; }
.location-icon-bank { color: #9b59b6; font-size: 24px; }
.location-icon-sawmill { color: #8B4513; font-size: 24px; }
.user-location-icon { color: #8e44ad; font-size: 22px; }
.chicken-coop-icon { color: #d35400; font-size: 24px; }
.stable-icon { color: #8B4513; font-size: 24px; }
.hive-icon { color: #f39c12; font-size: 24px; }
.location-icon-solar { color: #FFD700; font-size: 24px; }
.location-icon-wind { color: #00BFFF; font-size: 24px; }
.location-icon-farmshop { color: #2ecc71; font-size: 24px; }
.location-icon-firestation { color: #e74c3c; font-size: 24px; }

.crop-emoji-icon {
    font-size: 28px;
    text-align: center;
    line-height: 1;
    text-shadow: 0 0 4px white, 0 0 4px white;
    transform: translateY(25px);
}

/* Alertes Cartes (Field Alerts) */
.field-alert-container {
    display: flex;
    align-items: center;
    pointer-events: none;
    transform: translateY(-45px);     
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

.field-alert-icon-wrapper {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    border: 2px solid white;
    font-size: 20px;
    z-index: 2;
}

.field-alert-text {
    background-color: rgba(255, 255, 255, 0.95);
    color: #333;
    font-weight: bold;
    /* MODIFICATION 1 : Padding normal */
    padding: 5px 10px; 
    border-radius: 20px;
    /* MODIFICATION 2 : Marge positive pour créer un écart */
    margin-left: 8px; 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    z-index: 1;
    border: 2px solid white;
}

/* Variantes Alertes */
.field-alert-harvest .field-alert-icon-wrapper, .field-alert-harvest .field-alert-text { border-color: #2ecc71; }
.field-alert-harvest .field-alert-icon-wrapper { color: #2ecc71; }

.field-alert-weed .field-alert-icon-wrapper, .field-alert-weed .field-alert-text { border-color: #f39c12; }
.field-alert-weed .field-alert-icon-wrapper { color: #f39c12; }

.field-alert-pest .field-alert-icon-wrapper, .field-alert-pest .field-alert-text { border-color: #e74c3c; }
.field-alert-pest .field-alert-icon-wrapper { color: #e74c3c; }

.forest-alert-cut .field-alert-icon-wrapper, .forest-alert-cut .field-alert-text { border-color: #A0522D; }
.forest-alert-cut .field-alert-icon-wrapper { color: #A0522D; }

.forest-alert-harvest .field-alert-icon-wrapper, .forest-alert-harvest .field-alert-text { border-color: #8e44ad; }
.forest-alert-harvest .field-alert-icon-wrapper { color: #8e44ad; }

.animal-alert-sick .field-alert-icon-wrapper, .animal-alert-sick .field-alert-text { border-color: #e74c3c; }
.animal-alert-sick .field-alert-icon-wrapper { color: #e74c3c; }

.field-alert-disease .field-alert-icon-wrapper, .field-alert-disease .field-alert-text { border-color: #8e44ad; }
.field-alert-disease .field-alert-icon-wrapper { color: #8e44ad; }

.animal-alert-hungry .field-alert-icon-wrapper, .animal-alert-hungry .field-alert-text { border-color: #f39c12; }
.animal-alert-hungry .field-alert-icon-wrapper { color: #f39c12; }

.building-alert-strike .field-alert-icon-wrapper, .building-alert-strike .field-alert-text { border-color: #ef4444; color: #ef4444; }
.building-alert-strike .field-alert-icon-wrapper { animation: blink 1s infinite; background-color: #fee2e2; }

.field-alert-mole .field-alert-icon-wrapper, .field-alert-mole .field-alert-text { border-color: #795548; color: #5D4037; }
.field-alert-mole .field-alert-icon-wrapper { color: #795548; }
.field-alert-straw .field-alert-icon-wrapper, 
.field-alert-straw .field-alert-text { 
    /* Bordure jaune foncé / orangé pour rappeler la paille */
    border-color: #e67e22; 
}

.field-alert-straw .field-alert-icon-wrapper { 
    /* Couleur de l'icône (botte de paille) */
    color: #e67e22; 
}

.field-alert-straw .field-alert-text { 
    /* Couleur du texte (%) - on met un peu plus foncé pour que ce soit lisible */
    color: #d35400; 
    border-color: #e67e22;
}
/* Tooltips Carte */
.field-label-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: white !important;
    font-weight: 900;
    font-size: 1rem;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.leaflet-popup-content-wrapper {
    width: 320px;
    border-radius: 10px !important;
}

.leaflet-popup-content {
    margin: 15px 20px !important;
    width: auto !important;
}

/* Tendance argent/eau/énergie */
#money-trend-arrow,
#water-trend-arrow,
#energy-trend-arrow {
    font-size: 1.1rem;
    opacity: 0;
    transition: opacity 0.3s ease-out, color 0.3s ease-out;
    width: 1.2rem;
    text-align: center;
}

#money-trend-arrow.trend-arrow-up,
#water-trend-arrow.trend-arrow-up,
#energy-trend-arrow.trend-arrow-up {
    color: #2ecc71 !important;
    opacity: 1;
}

#money-trend-arrow.trend-arrow-down,
#water-trend-arrow.trend-arrow-down,
#energy-trend-arrow.trend-arrow-down {
    color: #e74c3c !important;
    opacity: 1;
}

/* Animations Utilitaires */
@keyframes ken-burns {
    0% { transform: scale(1.05) translate(0, 0); }
    100% { transform: scale(1.15) translate(-2%, 2%); }
}
.animate-ken-burns { animation: ken-burns 25s ease-out alternate infinite; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fadeInUp { opacity: 0; animation: fadeInUp 0.8s ease-out forwards; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes bounceInDown {
  0% { opacity: 0; transform: translateY(-200px); }
  60% { opacity: 1; transform: translateY(30px); }
  80% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}
.animate-bounceInDown { animation: bounceInDown 0.5s ease-out forwards; }

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}
.blink { animation: blink 1s infinite; }

/* Animations Météo */
@keyframes weather-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}
@keyframes weather-spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes weather-shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-3px) rotate(-2deg); }
    75% { transform: translateX(3px) rotate(2deg); }
    100% { transform: translateX(0); }
}
.weather-anim-float { animation: weather-float 4s ease-in-out infinite; display: inline-block; }
.weather-anim-spin { animation: weather-spin-slow 12s linear infinite; display: inline-block; transform-origin: center; }
.weather-anim-shake { animation: weather-shake 0.5s ease-in-out infinite; display: inline-block; }

#weather-display:hover {
    background-color: rgba(255,255,255,0.1);
    border-radius: 5px;
}

/* Éclair */
.lightning-flash {
    position: fixed;
    inset: 0;
    background-image: url('images/eclair.gif');
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center center;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    animation: flash-bolt 0.4s ease-out;
}
@keyframes flash-bolt {
    0% { opacity: 0; }
    10% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Accordéon */
.accordion-header {
    background-color: #e5e7eb;
    color: #1f2937;
    cursor: pointer;
    padding: 12px 18px;
    width: 100%;
    text-align: left;
    border: none;
    outline: none;
    transition: background-color 0.3s ease;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-header:hover,
.accordion-header.active {
    background-color: #d1d5db;
}

.accordion-icon {
    transition: transform 0.3s ease;
}

.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: white;
    border-radius: 0 0 8px 8px;
}

/* Tuto Popup */
#tutorial-step-popup {
    animation: fadeInUp 0.5s ease-out;
}
#tutorial-step-popup.hidden { display: none; }

#tutorial-popup-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#tutorial-popup-content {
    background-color: #f9fafb;
    padding: 2rem;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    height: 90vh;
    position: relative;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

#tutorial-popup-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.5rem;
    color: #6b7280;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

#tutorial-popup-close-btn:hover {
    color: #111827;
}

/* Discord Icon */
#discord-link-icon {
    position: fixed;
    bottom: 100px !important; /* 100px du bas pour être au-dessus du tchat */
    left: 20px !important;    /* Aligné à gauche */
    width: 50px;
    height: 50px;
    background-color: #5865F2; /* Bleu officiel Discord */
    color: white;
    border-radius: 50%;
    display: flex;            /* Centre l'icône */
    align-items: center;
    justify-content: center;
    font-size: 24px;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(88, 101, 242, 0.4); /* Ombre bleue */
    border: 2px solid white;
    z-index: 2500;            /* Au-dessus de la carte */
    transition: transform 0.2s ease;
}
#discord-link-icon:hover { transform: scale(1.1); }
#discord-link-icon.hidden {
    display: none !important;
}
#player-email { display: none !important; }

.ui-locked { opacity: 0.7; pointer-events: none; }

/* Mobile Warning */
@media (max-width: 768px) {
    #pre-draw-controls { top: 110px !important; }
    body:has(.event-banner.show) #pre-draw-controls { top: 190px !important; }
}

/* Boutons action */
.buy-button, .plant-button, .cultivate-button, .plough-button, 
.fertilize-button, .spray-button, .plant-tree-button, .cut-forest-button, .action-button {
    background-color: #2ecc71;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    margin-top: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover, .buy-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.sell-button { background-color: #e74c3c; }
.plant-button { background-color: #3498db; }
.cultivate-button { background-color: #8e44ad; }
.plough-button { background-color: #d35400; }
.fertilize-button { background-color: #27ae60; }
.spray-button { background-color: #c0392b; }
.plant-tree-button { background-color: #228B22; }
.cut-forest-button { background-color: #A0522D; }

/* Leaflet Draw */
.leaflet-draw-toolbar a {
    background-color: white !important;
    color: black !important;
}
.leaflet-draw-toolbar { display: flex !important; gap: 8px; }
.leaflet-draw-actions {
    position: absolute !important;
    top: 35px !important;
    left: 0 !important;
    display: flex !important;
    gap: 8px !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}
.leaflet-draw-actions a {
    display: block;
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    width: auto !important;
    height: 44px !important;
    line-height: 40px !important;
    font-size: 0.9rem !important;
    border-radius: 8px !important;
    border: 2px solid #ccc !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 0 15px !important;
    text-align: center;
}
.leaflet-draw-actions li:last-child a {
    background-color: #f44336 !important;
    color: white !important;
    border-color: #d32f2f !important;
}

/* Responsive Mobile (Shop/Market) */
@media (max-width: 768px) {
    .modal-content-wrapper,
    .modal-content-wrapper.modal-large-width {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 0 auto !important;
        left: 2.5vw !important;
        right: auto !important;
        overflow-x: hidden !important;
        border-radius: 12px !important;
    }

    #shop-container > div > div:first-child,
    #market-container > div > div:first-child {
        width: 100% !important;
        height: 60px !important;
        min-height: 60px !important;
        flex: 0 0 auto !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        align-items: center !important;
        background-color: white !important;
        border-bottom: 1px solid #e5e7eb !important;
        padding: 0 10px !important;
        gap: 10px !important;
        scrollbar-width: none;
    }

    #shop-container > div > div:first-child::-webkit-scrollbar,
    #market-container > div > div:first-child::-webkit-scrollbar {
        display: none;
    }

    #shop-container > div > div:first-child button,
    #market-container > div > div:first-child button {
        width: auto !important;
        margin: 0 5px !important;
        padding: 6px 12px !important;
        border-radius: 20px !important;
        font-size: 0.8rem !important;
        flex-shrink: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        border: 1px solid transparent !important;
    }

    #shop-container > div > div:first-child button.bg-white,
    #market-container > div > div:first-child button.bg-white {
        background-color: #eff6ff !important;
        color: #2563eb !important;
        border: 1px solid #bfdbfe !important;
        font-weight: 800 !important;
    }

    #shop-container > div,
    #market-container > div {
        display: flex !important;
        flex-direction: column !important;
        height: 80vh !important;
        background-color: #f3f4f6 !important;
        border: none !important;
    }

    #shop-container > div > div:last-child,
    #market-container > div > div:last-child {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        padding: 8px !important;
        padding-bottom: 100px !important;
        padding-top: 15px !important;
        z-index: 10 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #shop-container .grid,
    #market-container .grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    #shop-container .bg-white.p-3.rounded-lg,
    #market-container .bg-white.p-4.rounded-xl {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 10px !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        min-height: auto !important;
    }

    #market-container .flex.justify-between.items-start.mb-3,
    #shop-container .flex.justify-between.items-start.mb-3 {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        margin-bottom: 5px !important;
        width: 100% !important;
    }

    #market-container .font-bold.text-gray-800,
    #shop-container .font-bold.text-gray-800 {
        font-size: 0.95rem !important;
        white-space: normal !important;
        line-height: 1.2;
        margin-left: 10px !important;
        flex-grow: 1 !important;
    }

    #market-container .flex.justify-between.items-center.border-t,
    #shop-container .flex.justify-between.items-center.border-t {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding-top: 8px !important;
        margin-top: 5px !important;
        border-top: 1px solid #eee !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
    }

    #market-container .font-extrabold.text-gray-800.text-xl,
    #shop-container .font-extrabold.text-gray-800 {
        font-size: 1.1rem !important;
    }

    #market-container button,
    #shop-container button {
        width: auto !important;
        padding: 6px 12px !important;
        font-size: 0.85rem !important;
        min-width: 80px;
    }

    #shop-container h3,
    #market-container h3 {
        width: 100% !important;
        text-align: left !important;
        margin-top: 20px !important;
        margin-bottom: 10px !important;
        clear: both !important;
    }
}

/* =========================================
   STYLE BOUTON TCHAT (CORRIGÉ & UNIQUE)
   ========================================= */

#chat-toggle-btn {
    position: fixed;
    bottom: 40px !important; /* Position fixe unique */
    left: 20px !important;
    z-index: 2500;
    
    /* Taille et Forme */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    
    /* Couleurs et Style Moderne */
    background: linear-gradient(135deg, #3b82f6, #2563eb); /* Dégradé bleu */
    color: white;
    border: none;
    
    /* Effet flottant (Ombre + bordure transparente) */
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.2);
    
    /* Centrage de l'icône */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    
    /* Animation fluide */
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

/* Effet au survol de la souris */
#chat-toggle-btn:hover {
    transform: scale(1.1) rotate(-10deg);
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    box-shadow: 0 12px 25px rgba(37, 99, 235, 0.6), 0 0 0 6px rgba(255, 255, 255, 0.3);
}

/* État caché (géré par JS) */
#chat-toggle-btn.hidden {
    display: none !important;
}

/* Style du badge de notification (pastille rouge) */
#chat-toggle-btn #chat-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #ef4444;
    color: white;
    border: 2px solid white;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: pulse-red 2s infinite; /* Animation pulsante */
}

/* Animation de la pastille rouge */
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
#chat-input[type="search"]::-webkit-search-decoration,
#chat-input[type="search"]::-webkit-search-cancel-button,
#chat-input[type="search"]::-webkit-search-results-button,
#chat-input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.modal-content-wrapper,
div[id$="-modal"] > div.bg-white {
    max-height: 85vh !important; /* Limite la hauteur à 85% de l'écran */
    display: flex !important;
    flex-direction: column !important;
    margin: auto !important;
}

/* 2. Force le défilement (scroll) sur le contenu si c'est trop grand */
.modal-content-wrapper > .modal-body-container,
div[id$="-modal"] > div.bg-white > div.p-6,
div[id$="-modal"] > div.bg-white > div.overflow-y-auto {
    overflow-y: auto !important;
    flex-grow: 1 !important;
    min-height: 0 !important; /* Indispensable pour que le scroll flexbox marche */
}

/* 3. Spécial PC Portables (Écrans avec peu de hauteur) */
@media (max-height: 850px) {
    .modal-content-wrapper,
    div[id$="-modal"] > div.bg-white {
        max-height: 80vh !important; /* Réduit encore la hauteur max */
    }
    
    /* Réduit les marges intérieures (padding) pour gagner de la place */
    div[id$="-modal"] .p-6,
    .modal-content-wrapper .p-6 {
        padding: 1rem !important; 
    }
    
    /* Réduit la taille de l'en-tête coloré */
    div[id$="-modal"] .p-4 {
        padding: 0.5rem 1rem !important;
    }
    
    /* Réduit la taille du titre */
    div[id$="-modal"] h2 {
        font-size: 1.1rem !important;
    }
}
.admin-layout {
    display: flex;
    height: 100%;
    background-color: #f3f4f6;
    overflow: hidden;
}

.admin-sidebar {
    width: 220px;
    background-color: #1e293b; /* Bleu nuit foncé */
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    flex-shrink: 0;
}

.admin-sidebar-title {
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #60a5fa;
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 1px solid #334155;
    padding-bottom: 1rem;
}

.admin-nav-btn {
    text-align: left;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    color: #cbd5e1;
    transition: all 0.2s;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}

.admin-nav-btn:hover {
    background-color: #334155;
    color: white;
    transform: translateX(5px);
}

.admin-nav-btn.active {
    background-color: #2563eb; /* Bleu vif */
    color: white;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
}

.admin-content {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    position: relative;
}

.admin-section {
    display: none; /* Caché par défaut */
    animation: fadeIn 0.3s ease-out;
}

.admin-section.active {
    display: block; /* Affiché si actif */
}

.admin-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
}

.admin-card h3 {
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f3f4f6;
}
.modal-content-wrapper.modal-admin-width {
    width: 95vw !important;       /* Largeur : 95% de l'écran */
    max-width: 1800px !important; /* Limite maximale très large */
    height: 90vh !important;      /* Hauteur : 90% de l'écran */
    max-height: 90vh !important;
}

/* S'assure que le contenu interne remplit bien tout l'espace */
/* =================================================
   CORRECTIF FINAL : LARGEUR FENÊTRE ADMIN (PC)
   ================================================= */

/* On cible les écrans d'ordinateurs (plus larges que 769px) */
@media (min-width: 769px) {

    /* On cible spécifiquement la fenêtre Admin */
    .modal-content-wrapper.modal-admin-width {
        width: 98vw !important;         /* Élargi à 98% de l'écran */
        max-width: none !important;     /* Supprime la limite maximale */
        height: 95vh !important;        /* Hauteur : 95% de l'écran */
        max-height: 95vh !important;
        
        /* Centrage forcé */
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Étend le layout interne pour remplir la grande fenêtre */
    .modal-content-wrapper.modal-admin-width .admin-layout {
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: row !important; /* Force la sidebar à gauche et contenu à droite */
    }

    /* La zone de contenu à droite prend toute la place restante */
    .modal-content-wrapper.modal-admin-width .admin-content {
        flex-grow: 1 !important;
        width: 100% !important;
        overflow-y: auto !important;
    }
}
.hud-indicator, 
#money-display, 
#water-display, 
#energy-display {
    cursor: pointer !important;
    transition: all 0.2s ease;
    border-radius: 4px;
}

/* Effet de survol pour l'Argent */
.hud-indicator:has(#money-display):hover,
#money-display:hover {
    background-color: rgba(46, 204, 113, 0.2); /* Vert transparent */
    text-shadow: 0 0 8px rgba(46, 204, 113, 0.8);
}

/* Effet de survol pour l'Eau */
.hud-indicator:has(#water-display):hover,
#water-display:hover {
    background-color: rgba(52, 152, 219, 0.2); /* Bleu transparent */
    text-shadow: 0 0 8px rgba(52, 152, 219, 0.8);
}

/* Effet de survol pour l'Énergie */
.hud-indicator:has(#energy-display):hover,
#energy-display:hover {
    background-color: rgba(241, 196, 15, 0.2); /* Jaune transparent */
    text-shadow: 0 0 8px rgba(241, 196, 15, 0.8);
}
.custom-vehicle-icon {
    border-radius: 50%;       /* Rend l'image ronde */
    border: 2px solid white;  /* Bordure blanche */
    box-shadow: 0 3px 6px rgba(0,0,0,0.4); /* Petite ombre portée */
    background-color: white;
    object-fit: cover;        /* Assure que l'image remplit bien le rond */
}
@media (max-width: 768px) {
    /* On passe d'un affichage côte-à-côte à un affichage empilé (Haut/Bas) */
    .admin-layout {
        flex-direction: column !important;
    }

    /* La barre latérale prend toute la largeur et devient horizontale */
    .admin-sidebar {
        width: 100% !important;
        height: auto !important;
        flex-direction: row !important; /* Boutons alignés horizontalement */
        overflow-x: auto !important;    /* Permet de scroller horizontalement si trop de boutons */
        padding: 10px !important;
        flex-shrink: 0 !important;
        border-bottom: 1px solid #334155; /* Bordure en bas au lieu de droite */
    }

    /* On cache le gros titre "ADMIN" pour gagner de la place */
    .admin-sidebar-title {
        display: none !important;
    }

    /* Ajustement des boutons du menu */
    .admin-nav-btn {
        margin-bottom: 0 !important;
        margin-right: 10px !important;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important; /* Empêche le texte de passer à la ligne */
        flex-shrink: 0 !important;
    }

    /* Le contenu prend toute la largeur */
    .admin-content {
        width: 100% !important;
        padding: 15px !important;
        overflow-y: auto !important;
    }
    
    /* Ajustement des grilles à l'intérieur du contenu */
    .admin-content .grid {
        grid-template-columns: 1fr !important; /* 1 seule colonne */
    }
    
    /* Ajustement de la hauteur de la fenêtre modale sur mobile */
    .modal-content-wrapper.modal-admin-width {
        height: 90vh !important;
        max-height: 90vh !important;
    }
}
@keyframes progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}
.animate-stripes {
    background-image: linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);
    background-size: 1rem 1rem;
    animation: progress-stripes 1s linear infinite;
}
#intro-start-screen {
    /* 1. IMPORTANT : On force un fond noir uni derrière. */
    /* Comme l'image va être dézoomée, il faut que les bandes sur les côtés soient noires. */
    background-color: #000000 !important;

    /* L'image avec son filtre sombre */
    background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.7)), url('../logoWF.jpg');

    /* 2. C'EST ICI LE CHANGEMENT : 'contain' au lieu de 'cover' */
    /* Cela oblige le navigateur à afficher l'image ENTIÈRE sans la couper */
    background-size: contain;

    /* L'image est centrée au milieu de l'écran */
    background-position: center;
    /* On ne veut pas qu'elle se répète comme du carrelage */
    background-repeat: no-repeat;
}
.player-card-admin {
    background-color: #fef2f2 !important; /* Fond rouge très pâle */
    border-color: #fca5a5 !important;     /* Bordure rouge clair */
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.15) !important;
}

.player-card-mod {
    background-color: #eff6ff !important; /* Fond bleu très pâle */
    border-color: #93c5fd !important;     /* Bordure bleu clair */
}

/* Animation douce pour l'indicateur HUD */
@keyframes pulse-staff {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
#staff-indicator-desktop {
    display: none !important;
}
@media (max-width: 768px) {
    /* On force le conteneur du titre à laisser de la place à droite */
    #chat-container > div:first-child {
        padding-right: 60px !important;
        position: relative !important;
    } 
    /* On agrandit l'icône à l'intérieur */
    #chat-close-btn i {
        font-size: 20px !important;
        pointer-events: none; /* Le clic traverse l'icône pour aller au bouton */
    }
    .swal2-container {
    z-index: 200000 !important; /* Doit être supérieur à 100000 (intro-overlay) */
}

/* Optionnel : Assure que le texte dans la popup est bien lisible */
.swal2-popup {
    font-size: 1rem !important;
}
@media (max-width: 768px) {
    
    /* 1. On force la barre du bas à passer au-dessus des messages */
    #chat-container > div:last-child {
        position: relative !important;
        z-index: 2000000 !important; /* Très haut */
        pointer-events: auto !important; /* Force la détection du clic */
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1); /* Petite ombre pour séparer visuellement */
    }

    /* 2. On s'assure que l'input et le bouton sont bien sélectionnables */
    #chat-container input,
    #chat-container button {
        pointer-events: auto !important;
        touch-action: manipulation !important; /* Améliore la réactivité tactile */
        user-select: text !important;
        -webkit-user-select: text !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* 3. Petit fix pour que le texte écrit soit lisible (couleur noire) */
    #chat-container input[type="text"] {
        color: #000 !important; 
        background-color: #fff !important;
        z-index: 2000001 !important;
    }
}
@media (max-width: 768px) {
    #chat-close-btn {
        /* 1. On le rend visible de force */
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;

        /* 2. Positionnement FIXE par rapport à l'écran (et non à la fenêtre de tchat) */
        position: fixed !important;
        top: 10px !important;
        right: 10px !important;
        
        /* 3. Z-INDEX MAXIMUM (Au-dessus des onglets, du tchat, de tout) */
        z-index: 2147483647 !important; 

        /* 4. Apparence (Rond rouge) */
        width: 40px !important;
        height: 40px !important;
        background-color: #ef4444 !important; /* Rouge vif */
        border: 2px solid white !important;
        border-radius: 50% !important;
        box-shadow: 0 0 10px rgba(0,0,0,0.5) !important;

        /* 5. Centrage du texte/icône */
        align-items: center !important;
        justify-content: center !important;
        
        /* 6. On s'assure qu'il reçoit les clics */
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    /* On force la couleur de l'icône à l'intérieur en blanc */
    #chat-close-btn i {
        color: white !important;
        font-size: 1.2rem !important;
        display: block !important;
        line-height: 1 !important;
    }
}
.driver-active .driver-overlay,
.driver-active-element,
.driver-popover {
    z-index: 2147483647 !important; /* Maximum possible en CSS */
}

/* Style de la bulle pour qu'elle soit jolie */
.driver-popover {
    background-color: #f0fdf4 !important; /* Vert clair */
    border: 2px solid #16a34a !important; /* Bordure verte */
    color: #000 !important;
    border-radius: 12px !important;
    font-family: 'Segoe UI', sans-serif !important;
    max-width: 300px !important;
}

.driver-popover-title {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: #15803d !important; /* Vert foncé */
    margin-bottom: 5px !important;
}

.driver-popover-description {
    font-size: 14px !important;
    line-height: 1.5 !important;
}

/* Bouton Suivant */
.driver-popover-next-btn {
    background-color: #16a34a !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 6px 14px !important;
    text-shadow: none !important;
    border: none !important;
}

/* Désactiver l'interaction avec le jeu pendant le tuto */
.driver-active body {
    overflow: hidden !important;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.custom-city-marker {
    background: transparent !important;
    border: none !important;
    width: 40px !important;
    height: 40px !important;
    overflow: visible !important;
}
@media (max-width: 768px) {
    /* Ajustement de la modale Marché */
    #market-container .bg-white {
        width: 95% !important;
        max-width: 95% !important;
        padding: 0.75rem !important; /* Réduit le padding global */
    }

    /* Force le tableau à scroller horizontalement si ça dépasse */
    #market-container table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap; /* Empêche les retours à la ligne qui cassent la hauteur */
    }

    /* Réduit la taille de la police et des boutons dans le tableau */
    #market-container table td,
    #market-container table th {
        padding: 4px 8px !important; /* Moins d'espace dans les cellules */
        font-size: 0.85rem !important; /* Texte plus petit */
    }

    /* Ajuste la taille des boutons d'action (Acheter/Vendre) */
    #market-container button {
        padding: 4px 8px !important;
        font-size: 0.75rem !important;
    }
    
    /* Cache l'image/icône de la ressource si on manque vraiment de place (optionnel) */
    /* #market-container table td img { display: none; } */
}
}
@keyframes shield-pulse {
    0% { 
        transform: translate(-50%, -50%) scale(0.2); 
        opacity: 0; 
    }
    30% { 
        transform: translate(-50%, -50%) scale(1.2); 
        opacity: 1; 
    }
    70% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 1; 
        filter: drop-shadow(0 0 40px rgba(59, 130, 246, 1));
    }
    100% { 
        transform: translate(-50%, -50%) scale(1.5); 
        opacity: 0; 
    }
}

.shield-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    pointer-events: none;
}

.shield-overlay i {
    font-size: 200px;
    color: #3b82f6; /* Bleu électrique */
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.6));
    animation: shield-pulse 2s ease-out forwards;
}

/* Style pour les boutons de sabotage dans la liste des joueurs */
.sabotage-btn {
    transition: all 0.2s ease-in-out;
}

.sabotage-btn:hover {
    transform: scale(1.1) rotate(10deg);
}

/* Style des cartes de sabotage dans la modale */
.sabotage-card {
    background: linear-gradient(to right, #ffffff, #fff5f5);
    border-left: 4px solid #ef4444;
}
.wanted-list-item {
    background: #fef2f2;
    border: 2px solid #fee2e2;
    transition: all 0.2s;
}
.wanted-list-item:nth-child(1) {
    border-color: #ef4444; /* Le N°1 est en rouge vif */
    background: #fff1f2;
}
.bounty-tag {
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
}
.wanted-btn-pulse {
    animation: danger-pulse 2s infinite;
}

@keyframes danger-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.crop-sprite {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); /* Ajoute une petite ombre pour le relief */
    transition: transform 0.3s ease;
}

.field-crop-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Animation quand la plante est prête à être récoltée */
.ready-to-harvest .crop-sprite {
    animation: plant-bounce 1s infinite;
}

@keyframes plant-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

