/* Styles de base */
body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header avec gradient */
.gradient-header {
  background: linear-gradient(135deg, #496559 0%, #2c3e50 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Logo styles */
.flex.items-center.space-x-4 img {
  transition: transform 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.flex.items-center.space-x-4 img:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
              0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
              0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Styles pour les selects */
select[multiple] {
  background-image: none !important;
}

select:not([multiple]) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23666666'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Footer toujours en bas */
footer {
  margin-top: auto;
}

/* Système d'onglets */
.tab-btn {
  position: relative;
  transition: all 0.3s ease;
}

.tab-btn.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: white;
}

.tab-content {
  display: none !important;
  animation: fadeIn 0.4s ease-in-out;
}

.tab-content.active {
  display: block !important;
}

/* Analyse Tab */
#analyse-tab {
  display: none !important;
}

#analyse-tab.active {
  display: block !important;
}

#analyse-tab .grid {
  gap: 1.5rem;
}

#analyse-tab .card {
  padding: 1.5rem;
  border: 1px solid #e5e7eb;
}

#analyse-tab h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1f2937;
}

#analyse-tab h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
}

#analyse-tab select {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#analyse-tab select:focus {
  border-color: #496559;
  box-shadow: 0 0 0 3px rgba(73, 101, 89, 0.2);
  outline: none;
}

/* Simulation Tab */
#simulation-tab {
  display: none !important;
}

#simulation-tab.active {
  display: block !important;
}

#simulation-tab .grid {
  gap: 1.5rem;
}

#simulation-tab .card {
  padding: 1.5rem;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  overflow: hidden;
}

#simulation-tab h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
}

#simulation-tab h4 {
  font-size: 0.9rem;
  font-weight: 500;
  color: #4b5563;
}

#simulation-tab select,
#simulation-tab input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#simulation-tab select:focus,
#simulation-tab input:focus {
  border-color: #496559;
  box-shadow: 0 0 0 3px rgba(73, 101, 89, 0.2);
  outline: none;
}

#simulation-tab label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
}

#simulation-tab #addCommuneButton,
#simulation-tab #removeCommuneButton {
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#simulation-tab #addCommuneButton:hover,
#simulation-tab #removeCommuneButton:hover {
  transform: translateY(-1px);
}

#simulation-tab #selectedCommunes {
  min-height: 100px;
  font-size: 0.95rem;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  background-color: #496559;
  color: white;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  background-color: #2c3e50;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(0);
}

#chartContainer {
  height: 500px;
  min-height: 300px;
  max-height: 600px;
  width: 100%;
  position: relative;
  transition: height 0.3s ease-in-out;
}

/* Map Tab */
#map-tab {
  display: none !important;
}

#map-tab.active {
  display: block !important;
}

#map-container {
  height: 500px;
  min-height: 300px;
  max-height: 600px;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

/* Map controls and markers */
.leaflet-marker-icon {
  transition: transform 0.2s ease;
}

.leaflet-marker-icon:hover {
  transform: scale(1.15);
  z-index: 1000 !important;
}

.leaflet-control {
  border-radius: 6px !important;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
}

.leaflet-control img {
  max-width: 30px;
  max-height: 30px;
}

.leaflet-control-zoom {
  margin-top: 10px !important;
  border-radius: 8px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background-color: white !important;
  color: #496559 !important;
  transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
  background-color: #f3f4f6 !important;
  color: #2c3e50 !important;
}

/* Chart legends and icons */
.chart-legend img,
.chart-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 5px;
  border-radius: 3px;
}

/* Button icons */
.btn i,
.btn img {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
  font-size: 16px;
}

/* Animation de transition */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Notification */
.notification {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  color: white;
  z-index: 1000;
  transform: translateY(0);
  transition: transform 0.4s ease-in-out, opacity 0.4s ease-in-out;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.notification.info {
  background-color: #496559;
}

.notification.error {
  background-color: #e74c3c;
}

.notification.hide {
  transform: translateY(-100%);
  opacity: 0;
}

/* Loader */
.loader {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 4px solid #496559;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Adaptation mobile */
@media (max-width: 768px) {
  header nav ul {
    flex-direction: column;
    align-items: flex-end;
  }
  
  .tab-btn {
    display: block;
    width: 100%;
    text-align: left;
  }
  
  #simulation-tab .grid,
  #analyse-tab .grid {
    gap: 1rem;
    flex-direction: column;
  }
  
  #simulation-tab select,
  #simulation-tab input,
  #analyse-tab select {
    font-size: 1rem;
  }
  
  #simulation-tab #addCommuneButton,
  #simulation-tab #removeCommuneButton {
    padding: 0.75rem;
  }
  
  .chart-controls {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn {
    width: 100%;
    padding: 0.75rem;
  }
  
  #chartContainer,
  #map-container {
    height: 400px;
    min-height: 250px;
    max-height: 500px;
  }
  
  .flex.items-center.space-x-4 img {
    height: 36px;
  }
  
  footer .w-32.h-20 {
    width: 80px;
    height: 50px;
  }
}

/* Adaptation pour petits écrans */
@media (max-width: 480px) {
  #chartContainer,
  #map-container {
    height: 300px;
    min-height: 200px;
  }
}

/* Partners section */
footer .w-32.h-20 {
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

footer .w-32.h-20:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2);
}

footer .w-32.h-20 img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

footer .w-32.h-20:hover img {
  transform: scale(1.1);
}

/* Mobile menu icon */
#mobile-menu-btn i {
  font-size: 1.25rem;
  transition: transform 0.3s ease;
}

#mobile-menu-btn:hover i {
  transform: rotate(90deg);
}

/* Dropdown icons and indicators */
select {
  background-size: 16px !important;
}

/* Image thumbnails in charts */
.thumbnail-image {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.thumbnail-image:hover {
  transform: scale(1.2);
  border-color: #496559;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Culture icons in charts and tables */
.culture-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 50%;
  background-color: #f3f4f6;
  padding: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.culture-icon:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.culture-icon.arachide { background-color: rgba(52, 152, 219, 0.2); }
.culture-icon.igname { background-color: rgba(46, 204, 113, 0.2); }
.culture-icon.niebe { background-color: rgba(231, 76, 60, 0.2); }
.culture-icon.manioc { background-color: rgba(241, 196, 15, 0.2); }
.culture-icon.mais { background-color: rgba(155, 89, 182, 0.2); }
.culture-icon.riz { background-color: rgba(26, 188, 156, 0.2); }
.culture-icon.sorgho { background-color: rgba(230, 126, 34, 0.2); }
.culture-icon.soja { background-color: rgba(44, 62, 80, 0.2); }

/* Image tooltips */
.img-tooltip {
  position: relative;
  display: inline-block;
}

.img-tooltip:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0,0,0,0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
}

.img-tooltip:hover::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0,0,0,0.8) transparent transparent transparent;
}

/* Download and export buttons */
#exportChartBtn {
  position: relative;
}

#exportChartBtn::before {
  content: "\f019";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  margin-right: 8px;
}

/* Loading and placeholder images */
.loading-placeholder {
  background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty state images */
.empty-state-img {
  width: 80px;
  height: 80px;
  opacity: 0.4;
  margin: 0 auto 16px auto;
  display: block;
}

/* Map legend images */
.map-legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.map-legend-item img {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 1px solid #d1d5db;
}

/* Collapsible panel animation */
#filtersContent {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

#filtersContent.collapsed {
  max-height: 0;
}

/* Toggle buttons */
#toggleFilters, 
#toggleChartControls,
#downloadChart {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

#toggleFilters:hover, 
#toggleChartControls:hover,
#downloadChart:hover {
  background-color: #f3f4f6;
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#toggleFilters i,
#toggleChartControls i,
#downloadChart i {
  transition: transform 0.3s ease;
}

#toggleFilters.collapsed i {
  transform: rotate(180deg);
}

/* Communes list */
#selectedCommunesList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#selectedCommunesList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  transition: background-color 0.2s ease;
}

#selectedCommunesList li:hover {
  background-color: #f9fafb;
}

#selectedCommunesList .remove-commune {
  color: #ef4444;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.2s ease;
}

#selectedCommunesList .remove-commune:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Chart controls panel */
#chartControlsPanel {
  transition: all 0.3s ease;
}

#chartControlsPanel.visible {
  display: block;
}

/* Smaller buttons */
.btn-sm {
  padding: 0.5rem 0.75rem;
  background-color: #496559;
  color: white;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-sm:hover {
  background-color: #2c3e50;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-sm:active {
  transform: translateY(0);
}

.btn-sm i {
  font-size: 0.85rem;
  margin-right: 4px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  #simulation-tab .flex {
    flex-direction: column;
  }
  
  #simulation-tab .lg\:w-1\/4,
  #simulation-tab .lg\:w-3\/4 {
    width: 100%;
  }
}

@media (max-width: 640px) {
  #filtersContent {
    max-height: 600px;
  }
  
  #simulation-tab .card {
    padding: 1rem;
  }
}

/* Enhanced commune search */
#communeSearch {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

#addCommuneButton {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Commune list item styling */
#selectedCommunesList li {
  font-size: 0.9rem;
  border-radius: 4px;
  margin: 2px 0;
}

/* Transition for chart container */
#chartContainer {
  transition: height 0.3s ease-in-out;
}

/* Card header styling */
#simulation-tab .card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2c3e50;
}

/* Empty state transition */
#empty-chart-state {
  transition: opacity 0.3s ease;
}

/* Interactive filter labels */
#simulation-tab label {
  cursor: pointer;
  transition: color 0.2s ease;
}

#simulation-tab label:hover {
  color: #496559;
}

/* Add subtle hover to select boxes */
#simulation-tab select:hover {
  border-color: #9ca3af;
}

/* Active select state */
#simulation-tab select:focus {
  border-color: #496559;
  box-shadow: 0 0 0 2px rgba(73, 101, 89, 0.2);
}

/* Highlight animation for help */
@keyframes highlight-pulse {
  0% { box-shadow: 0 0 0 0 rgba(73, 101, 89, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(73, 101, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(73, 101, 89, 0); }
}

.highlight-section {
  animation: highlight-pulse 1.5s ease-out;
  border: 1px solid #496559;
  background-color: rgba(73, 101, 89, 0.05);
}

/* Improve empty state button */
#empty-chart-state button {
  transition: all 0.3s ease;
}

#empty-chart-state button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Gestion du plein écran pour le graphique */
#filtersPanel, #chartPanel {
  transition: all 0.3s ease-in-out;
}

#filtersPanel {
  flex-shrink: 0;
}

#filtersPanel.hidden-filters {
  width: 0;
  max-width: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  opacity: 0;
}

#chartPanel.full-width {
  width: 100%;
}

@media (min-width: 1024px) {
  .flex.flex-col.lg\:flex-row > #filtersPanel {
    width: 25%;
    max-width: 25%;
  }
  
  .flex.flex-col.lg\:flex-row > #chartPanel {
    width: 75%;
  }
  
  .flex.flex-col.lg\:flex-row > #chartPanel.full-width {
    width: 100%;
  }
}

/* Style pour le conteneur principal en mode adaptatif */
.flex.flex-col.lg\:flex-row {
  display: flex;
  width: 100%;
}

/* Style pour le bouton de toggle des filtres */
#toggleFilterPanel {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
}

#toggleFilterPanel:hover {
  background-color: #f3f4f6;
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#toggleFilterPanel i {
  font-size: 0.9rem;
  transition: transform 0.3s ease;
}

#toggleFilterPanel:hover i {
  transform: scale(1.1);
}

/* Gestion des layouts avec/sans filtres */
#simulationLayout {
  display: flex;
  flex-direction: column;
  width: 100%;
  transition: all 0.3s ease-in-out;
}

@media (min-width: 1024px) {
  #simulationLayout {
    flex-direction: row;
  }
  
  #simulationLayout #filtersPanel {
    width: 25%;
    max-width: 25%;
    transition: all 0.3s ease-in-out;
  }
  
  #simulationLayout #chartPanel {
    width: 75%;
    transition: all 0.3s ease-in-out;
  }
  
  #simulationLayout.filters-hidden #chartPanel {
    width: 100% !important;
  }
  
  #simulationLayout.filters-hidden #filtersPanel {
    width: 0 !important;
    max-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
  }
}