/* Variables CSS pour le thème */
:root {
    --icon-color: #6B7280;
    --icon-hover-color: #4F46E5;
    --bg-primary: rgba(255, 255, 255, 0.8);
    --bg-secondary: rgba(255, 255, 255, 0.1);
    --bg-tertiary: rgba(255, 255, 255, 0.3);
    --bg-hover: rgba(255, 255, 255, 1);
    --border-color: #E5E7EB;
    --border-hover-color: #4F46E5;
    --text-color: #374151;
    --text-secondary: #6B7280;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover-color: rgba(0, 0, 0, 0.15);
    --focus-ring-color: rgba(79, 70, 229, 0.1);
    --focus-ring-color-strong: rgba(79, 70, 229, 0.2);
}

/* Dark mode */
body.dark-mode {
    --icon-color: #E5E7EB;
    --icon-hover-color: #818CF8;
    --bg-primary: rgba(0, 0, 0, 0.7);
    --bg-secondary: rgba(0, 0, 0, 0.3);
    --bg-tertiary: rgba(0, 0, 0, 0.5);
    --bg-hover: rgba(0, 0, 0, 0.8);
    --border-color: rgba(255, 255, 255, 0.2);
    --border-hover-color: #818CF8;
    --text-color: #F3F4F6;
    --text-secondary: #D1D5DB;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover-color: rgba(0, 0, 0, 0.5);
    --focus-ring-color: rgba(129, 140, 248, 0.2);
    --focus-ring-color-strong: rgba(129, 140, 248, 0.3);
}

/* Styles généraux */
body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    font-family: Arial, sans-serif;
    transition: background-color 0.3s ease;
}

/* Header et navigation */
header {
    flex-shrink: 0;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ddd;
    padding: 0.25rem 0.5rem;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tab-buttons {
    display: flex;
}

.tab-button {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    margin-right: 0.25rem;
    font-size: 0.8rem;
    color: #333;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

.tab-button:hover {
    background-color: #e0e0e0;
}

.tab-button.active {
    background-color: #ddd;
    font-weight: bold;
}

.user-controls {
    display: flex;
    align-items: center;
}

#login-button {
    background-color: #4a90e2;
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-right: 0.5rem;
}

#login-button:hover {
    background-color: #357abd;
}

#profile-button {
    width: 1.5rem;
    height: 1.5rem;
    background-color: #ddd;
    border-radius: 50%;
    cursor: pointer;
}

/* Main content */
main {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

#carte-content, #items-content, #dataviz-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
}

/* Carte */
#map {
    height: 100%;
    width: 100%;
}

#loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scalebar */
.maplibregl-ctrl-scale {
    background-color: rgba(255, 255, 255, 0.4);
    color: #000;
}

/* Dark mode pour la scalebar */
body.dark-mode .maplibregl-ctrl-scale {
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
}

/* Légende */
#legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    background: rgba(255, 255, 255, 0.4);
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    max-width: 250px;
    max-height: 70vh;
    overflow-y: auto;
    transition: all 0.3s ease-out;  /* changé pour inclure tous les effets */
}

#legend:hover {
    background: rgba(255, 255, 255, 1);
 }

#legend.collapsed {
    max-height: 40px;
    overflow: hidden;
}

.legend-item {
    margin-bottom: 5px;
    font-size: 0.9em;
}

.legend-color {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    border-radius: 50%;
    vertical-align: middle;
}

#legend-toggle {
    cursor: pointer;
    font-weight: bold;
    margin-bottom: 10px;
}

/* Contrôles de couche */
#layer-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    background: white;
    padding: 10px;
    border-radius: 3px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    display: none;
}

#layer-controls div {
    margin-bottom: 5px;
}

#nichoirs-type-selector {
    font-size: 14px;
    padding: 2px;
    margin-left: 5px;
}

#basemap-select {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 1000;
    background: var(--bg-secondary);
    backdrop-filter: blur(3px);
    border-radius: 12px;
    padding: 6px 6px;
    box-shadow: 0 4px 20px var(--shadow-color);
    border: 1px solid var(--border-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

#basemap-select:hover {
    box-shadow: 0 6px 30px var(--shadow-hover-color);
}

#basemap-select::before {
    content: '';
    width: 18px;
    height: 18px;
    background-size: contain;
    background-repeat: no-repeat;
    transition: all 0.2s ease;
    /* L'icône sera gérée dynamiquement en fonction du thème */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6'/%3E%3Cline x1='8' y1='2' x2='8' y2='18'/%3E%3Cline x1='16' y1='6' x2='16' y2='22'/%3E%3C/svg%3E");
}

/* Icône carte en dark mode */
body.dark-mode #basemap-select::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23E5E7EB' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6'/%3E%3Cline x1='8' y1='2' x2='8' y2='18'/%3E%3Cline x1='16' y1='6' x2='16' y2='22'/%3E%3C/svg%3E");
}

#basemap-select:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6'/%3E%3Cline x1='8' y1='2' x2='8' y2='18'/%3E%3Cline x1='16' y1='6' x2='16' y2='22'/%3E%3C/svg%3E");
}

/* Icône carte hover en dark mode */
body.dark-mode #basemap-select:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23818CF8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6'/%3E%3Cline x1='8' y1='2' x2='8' y2='18'/%3E%3Cline x1='16' y1='6' x2='16' y2='22'/%3E%3C/svg%3E");
}

#basemap-selector {
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    backdrop-filter: blur(2px);
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    min-width: 80px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 25px;
}

#basemap-selector:hover {
    border-color: var(--border-hover-color);
    box-shadow: 0 0 0 3px var(--focus-ring-color);
}

#basemap-selector:focus {
    border-color: var(--border-hover-color);
    box-shadow: 0 0 0 3px var(--focus-ring-color-strong);
}

#basemap-selector option {
    padding: 8px 12px;
    font-weight: 500;
}

/* Animation d'apparition pour le basemap selector */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#basemap-select {
    animation: slideInLeft 0.4s ease-out;
}

/* Responsive pour le basemap selector */
@media (max-width: 768px) {
    #basemap-select {
        top: 5px;
        padding: 6px 6px;
    }
    
    #basemap-select::before {
        width: 16px;
        height: 16px;
    }
    
    #basemap-selector {
        font-size: 13px;
        padding: 2px 8px;
        padding-right: 28px;
        min-width: 70px;
    }
}

/* Popup */
.maplibregl-popup {
    max-width: 300px !important;
}

.maplibregl-popup-content {
    padding: 0 !important;
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.popup-content {
    font-family: Arial, sans-serif;
    max-width: 300px;
}

.popup-title {
    color: white;
    padding: 10px;
    margin: 0;
    font-size: 16px;
}

.parcelle-title {
    background-color: red;
}

.cluster-title {
    background-color: #3498db;
}



.popup-info {
    padding: 10px;
}

.popup-info p {
    margin: 5px 0;
    font-size: 14px;
}

.species-count {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.species-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    display: inline-block;
}

.species-name {
    flex-grow: 1;
}

.species-number {
    font-weight: bold;
}

.occupied-indicator {
    margin-left: 8px;
    font-size: 12px;
    color: #FFD700;
    font-weight: bold;
    animation: starPulse 2s ease-in-out infinite alternate;
}

@keyframes starPulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.popup-comments {
    background-color: #f0f0f0;
    padding: 10px;
    margin-top: 10px;
}

.popup-comments h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
}

.popup-comments p {
    margin: 0;
    font-size: 13px;
    font-style: italic;
}

.maplibregl-popup-tip {
    display: none;
}

/* Contenu des items */
#items-content {
    padding: 20px;
    background-color: white;
}

#items-content.hidden {
    display: none;
}

#items-content table {
    border-collapse: collapse;
    width: 100%;
}

#items-content th, #items-content td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

#items-content tr:nth-child(even) {
    background-color: #f2f2f2;
}

#items-content th {
    padding-top: 12px;
    padding-bottom: 12px;
    background-color: #4a5568;
    color: white;
}

.pagination {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Contenu Dataviz */
#dataviz-content {
    padding: 20px;
    height: 100%;
    box-sizing: border-box;
    background-color: white;
}

#dataviz-content.hidden {
    display: none;
}

.charts-container {
    display: flex;
    height: calc(100% - 40px);
    gap: 20px;
}

.chart-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chart-title {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    color: #333;
    text-align: center;
}

.chart-wrapper iframe {
    flex-grow: 1;
    width: 100%;
    border: none;
}

/* Media Queries */
@media (max-width: 768px) {
    .charts-container {
        flex-direction: column;
        height: auto;
    }

    .chart-wrapper {
        height: 450px;
        margin-bottom: 20px;
    }

    #legend {
        max-width: 150px;
        font-size: 0.8em;
    }

    .legend-color {
        width: 12px;
        height: 12px;
    }
}


.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    padding: 2px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.legend-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}


.legend-icon-container {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-icon-container svg {
    width: 24px;
    height: 24px;
}

.legend-label {
    font-size: 0.9em;
    color: #333;
}



/* Style pour l'icône des crédits */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib {
    padding: 0;
    background: none;
    margin: 0;
}

.maplibregl-ctrl-attrib.maplibregl-compact {
    min-width: 24px;
    min-height: 24px;
    padding: 0;
    margin: 0 5px 5px 0;
}

.maplibregl-ctrl-attrib .maplibregl-ctrl-attrib-button {
    width: 24px !important;
    height: 24px !important;
    background-color: white !important;
    border-radius: 50% !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.maplibregl-ctrl-attrib.maplibregl-compact-show {
    padding: 2px 8px;
    border-radius: 3px;
    background: rgba(255,255,255,0.9);
    margin-right: 10px;
}

/* Style du contrôle 3D terrain */
.maplibregl-ctrl-terrain {
    background: rgba(255, 255, 255, 1) !important;
    border-radius: 4px !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s ease !important;
}

.maplibregl-ctrl-terrain .maplibregl-ctrl-terrain-button {
    background: rgba(255, 255, 255, 1) !important;
    color: #6B7280 !important;
    border: none !important;
    transition: all 0.3s ease !important;
}

.maplibregl-ctrl-terrain .maplibregl-ctrl-terrain-button:hover {
    background: rgba(255, 255, 255, 0.8) !important;
    color: #4F46E5 !important;
}

/* Le contrôle terrain reste toujours avec fond blanc, même en dark mode */




/* Style pour le bouton de fermeture personnalisé des popups */
.popup-close-button {
    position: fixed;
    width: 20px;
    height: 20px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.popup-close-button:hover {
    background: #f5f5f5;
    border-color: #999;
    transform: scale(1.1);
}

.popup-close-button svg {
    width: 12px;
    height: 12px;
    stroke: #666;
    stroke-width: 2;
}

.popup-close-button:hover svg {
    stroke: #333;
}

/* POURTEMPORAIREMENT MASQUER LE HEADER */

header {
    display: none !important;
}
/* Ajuster le conteneur principal pour compenser l'absence du header */ 
[role="main"] {
    top: 0 !important;
}
