/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(to bottom right, #f8fafc, #dbeafe);
    overflow-y: auto; /* permet le scroll si nécessaire */
}

/* ============================================
   🟥 HEADER
   ============================================ */
.header {
    height: 12vh;
    min-height: 60px;
    background: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
    flex-shrink: 0;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.header-left p {
    font-size: 0.875rem;
    color: #6b7280;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Sélecteur de commune */
.commune-selector {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.commune-selector:hover {
    border-color: #3b82f6;
}

.commune-selector:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* Toggle Mode */
.mode-toggle {
    position: relative;
    width: 14rem;
    height: 2.5rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.3s;
}

.mode-toggle.analyse {
    background: linear-gradient(to right, #3b82f6, #06b6d4);
}

.mode-toggle.artistique {
    background: linear-gradient(to right, #9333ea, #ec4899);
}

.mode-toggle-slider {
    position: absolute;
    top: 0.125rem;
    height: 2.25rem;
    width: calc(50% - 0.25rem);
    background: white;
    border-radius: 9999px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: left 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-toggle.analyse .mode-toggle-slider {
    left: 0.125rem;
}

.mode-toggle.artistique .mode-toggle-slider {
    left: calc(50% + 0.125rem);
}

.mode-toggle-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-toggle.analyse .mode-toggle-content {
    color: #3b82f6;
}

.mode-toggle.artistique .mode-toggle-content {
    color: #9333ea;
}

.mode-icon {
    width: 14px;
    height: 14px;
}

.mode-text {
    font-size: 0.7rem;
    font-weight: 700;
}

.mode-labels {
    position: absolute;
    inset: 0;
    display: flex;
    font-size: 0.7rem;
}

.mode-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    transition: opacity 0.3s;
}

.mode-toggle.analyse .mode-label-left {
    opacity: 0;
}

.mode-toggle.artistique .mode-label-right {
    opacity: 0;
}

/* ============================================
   🟦 MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;               /* prend tout l'espace restant */
    display: flex;
    overflow: visible;     /* permet scroll vertical si nécessaire */
    position: relative;
    min-height: 400px;
}

/* Mode containers (analyse / artistique) */
.mode-container {
    position: absolute;
    inset: 0;
    display: flex;
    opacity: 0;
    transform: translateX(-100%);
    transition: all 0.5s;
    pointer-events: none;
}

.mode-container.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

.mode-artistique {
    background: linear-gradient(to bottom right, #581c87, #1e293b, #831843);
}

/* ============================================
   🟦 CARTE SECTION (45%)
   ============================================ */
.carte-section {
    width: 45%;
    background: linear-gradient(to bottom right, #dbeafe, #cffafe);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.carte-container {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title svg {
    color: #3b82f6;
}

.carte-svg-container {
    flex: 1;
    overflow: hidden;
}

.legende {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.legende-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: #4b5563;
}

.legende-color {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    border: 1.5px solid white;
}

/* ============================================
   🟩 GRAPHIQUES SECTION (55%)
   ============================================ */
.graphiques-section {
    width: 55%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    overflow: hidden;
}

.graphique-container {
    flex: 1;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.graphique-container canvas {
    flex: 1;
    min-height: 0;
}

/* ============================================
   MODE ARTISTIQUE
   ============================================ */
.artistique-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1.5rem;
}

.artistique-svg {
    width: 100%;
    max-width: 42rem;
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.annotation-text { fill: white; font-size: 0.75rem; font-weight: 600; }
.annotation-text-small { fill: #a5f3fc; font-size: 0.55rem; }

.artistique-info {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 0.75rem;
    padding: 1.5rem;
    max-width: 42rem;
    width: 100%;
}

.artistique-info h3 {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.artistique-info p {
    color: #d1d5db;
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.artistique-stats {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 0.75rem;
    text-align: center;
}

.stat-item { padding: 0.75rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.2rem; }
.stat-item:nth-child(1) .stat-value { color: #06b6d4; }
.stat-item:nth-child(2) .stat-value { color: #ec4899; }
.stat-item:nth-child(3) .stat-value { color: #a855f7; }
.stat-label { color: #d1d5db; font-size: 0.75rem; }

/* ============================================
   🟪 FOOTER ANALYSE
   ============================================ */
.footer-analyse {
    height: 15vh;
    min-height: 80px;
    background: #1f2937;
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.footer-left { flex: 1; }
.footer-left h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.footer-left h4 svg { color: #06b6d4; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2,1fr);
    gap: 0.25rem 1rem;
    font-size: 0.75rem;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-label-footer { color: #9ca3af; }
.stat-row strong { color: #06b6d4; }

.footer-right {
    flex: 1;
    background: rgba(59,130,246,0.2);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.footer-right p { font-size: 0.75rem; line-height: 1.4; }
.footer-right strong { color: #fbbf24; }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity:0; transform: translateY(10px);}
    to { opacity:1; transform: translateY(0);}
}

.fade-in { animation: fadeIn 0.5s ease-out; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    .carte-section, .graphiques-section {
        width: 100%;
    }
}
