/* ============================================
   THÈME ERP AGRICOLE SÉNÉGAL - FREST
   ============================================ */

/* Variables CSS principales */
:root {
  /* Couleurs agriculture sénégalaise */
  --agri-primary: #28a745;
  --agri-secondary: #fd7e14;
  --agri-earth: #795548;
  --agri-sky: #17a2b8;
  --agri-gold: #ffc107;
  --agri-light: #f8f9fa;
  --agri-dark: #2d3748;

  /* Couleurs de contexte métier */
  --crop-active: #28a745;
  --crop-harvest: #ffc107;
  --crop-planned: #17a2b8;
  --stock-low: #dc3545;
  --stock-ok: #28a745;
  --weather-info: #17a2b8;
}

/* ============================================
   PERSONNALISATION BRAND & NAVIGATION
   ============================================ */

/* Brand ERP Agricole */
.app-brand-text {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

.text-agri-primary { color: var(--agri-primary) !important; }
.text-agri-secondary { color: var(--agri-secondary) !important; }

/* Menu headers avec émojis contextuels */
.menu-header .menu-header-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--agri-primary) !important;
  opacity: 0.8;
}

/* Icônes menu colorées par contexte */
.menu-link .tf-icons.text-success { color: var(--agri-primary) !important; }
.menu-link .tf-icons.text-warning { color: var(--agri-gold) !important; }
.menu-link .tf-icons.text-info { color: var(--agri-sky) !important; }
.menu-link .tf-icons.text-primary { color: #6f42c1 !important; }
.menu-link .tf-icons.text-secondary { color: var(--agri-earth) !important; }

/* ============================================
   CARTES ET COMPOSANTS AGRICOLES
   ============================================ */

/* Cartes avec thème agricole */
.agri-card {
  border-radius: 12px;
  box-shadow: 0 0.125rem 0.25rem rgba(40, 167, 69, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(40, 167, 69, 0.1);
  background: #ffffff;
}

.agri-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1.5rem rgba(40, 167, 69, 0.15);
  border-color: rgba(40, 167, 69, 0.2);
}

/* KPIs avec gradients agricoles */
.kpi-agriculture {
  background: linear-gradient(135deg, var(--agri-primary) 0%, #20c997 100%);
  border: none;
}

.kpi-finance {
  background: linear-gradient(135deg, var(--agri-gold) 0%, #ffcd39 100%);
  border: none;
}

.kpi-commerce {
  background: linear-gradient(135deg, var(--agri-secondary) 0%, #ff9800 100%);
  border: none;
}

.kpi-stocks {
  background: linear-gradient(135deg, var(--agri-sky) 0%, #00bcd4 100%);
  border: none;
}

/* Cartes KPI avec animations subtiles */
.kpi-agriculture,
.kpi-finance,
.kpi-commerce,
.kpi-stocks {
  position: relative;
  overflow: hidden;
  color: white;
}

.kpi-agriculture::before,
.kpi-finance::before,
.kpi-commerce::before,
.kpi-stocks::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s;
}

.kpi-agriculture:hover::before,
.kpi-finance:hover::before,
.kpi-commerce:hover::before,
.kpi-stocks:hover::before {
  left: 100%;
}

/* ============================================
   BADGES CONTEXTUELS AGRICOLES
   ============================================ */

/* Badges cycle de culture */
.badge-crop-active {
  background-color: var(--crop-active);
  color: white;
}

.badge-crop-harvest {
  background-color: var(--crop-harvest);
  color: #212529;
}

.badge-crop-planned {
  background-color: var(--crop-planned);
  color: white;
}

/* Badges stocks */
.badge-stock-low {
  background-color: var(--stock-low);
  color: white;
  animation: pulse-danger 2s infinite;
}

.badge-stock-ok {
  background-color: var(--stock-ok);
  color: white;
}

/* Badges météo et contexte */
.badge-weather {
  background-color: var(--weather-info);
  color: white;
}

.badge-harvest-ready {
  background-color: var(--agri-gold);
  color: #212529;
  font-weight: 600;
}

/* ============================================
   BOUTONS THÉMATIQUES
   ============================================ */

/* Bouton primaire agricole */
.btn-agri-primary {
  background: linear-gradient(135deg, var(--agri-primary), #20c997);
  border: none;
  color: white;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 0.125rem 0.25rem rgba(40, 167, 69, 0.3);
}

.btn-agri-primary:hover {
  background: linear-gradient(135deg, #218838, #1ea389);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 0.375rem 0.75rem rgba(40, 167, 69, 0.4);
}

/* Bouton secondaire agricole */
.btn-agri-secondary {
  background: linear-gradient(135deg, var(--agri-secondary), #ff9800);
  border: none;
  color: white;
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn-agri-secondary:hover {
  background: linear-gradient(135deg, #e8690b, #f57c00);
  color: white;
  transform: translateY(-1px);
}

/* ============================================
   ALERTES CONTEXTUELLES
   ============================================ */

/* Alerte météorologique */
.alert-weather {
  background: linear-gradient(135deg, rgba(23, 162, 184, 0.1), rgba(0, 188, 212, 0.05));
  border: 1px solid var(--agri-sky);
  border-left: 4px solid var(--agri-sky);
  color: #0c5460;
}

.alert-weather .alert-link {
  color: #0c5460;
  font-weight: 600;
}

/* Alerte récolte */
.alert-harvest {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 205, 57, 0.05));
  border: 1px solid var(--agri-gold);
  border-left: 4px solid var(--agri-gold);
  color: #856404;
}

.alert-harvest .alert-link {
  color: #856404;
  font-weight: 600;
}

/* Alerte croissance */
.alert-growth {
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.1), rgba(32, 201, 151, 0.05));
  border: 1px solid var(--agri-primary);
  border-left: 4px solid var(--agri-primary);
  color: #1e7e34;
}

/* ============================================
   PROGRESS BARS & INDICATEURS
   ============================================ */

/* Progress bars pour cycles de culture */
.progress-agriculture .progress-bar {
  background: linear-gradient(90deg, var(--agri-primary), #20c997);
  animation: progress-animation 2s ease-in-out;
}

.progress-harvest .progress-bar {
  background: linear-gradient(90deg, var(--agri-gold), #ffcd39);
}

.progress-growth .progress-bar {
  background: linear-gradient(90deg, var(--agri-sky), #00bcd4);
}

/* Indicateurs circulaires */
.circle-indicator {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  position: relative;
  overflow: hidden;
}

.circle-indicator.agriculture {
  background: linear-gradient(135deg, var(--agri-primary), #20c997);
}

.circle-indicator.finance {
  background: linear-gradient(135deg, var(--agri-gold), #ffcd39);
}

/* ============================================
   ANIMATIONS CONTEXTUELLES
   ============================================ */

/* Animation pulse pour alertes critiques */
@keyframes pulse-danger {
  0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Animation de croissance pour éléments agricoles */
@keyframes grow-plant {
  0% {
    transform: scale(0.8) translateY(10px);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.02) translateY(-2px);
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.plant-animation {
  animation: grow-plant 0.8s ease-out;
  transform-origin: bottom center;
}

/* Animation pour progress bars */
@keyframes progress-animation {
  0% { width: 0%; }
  100% { width: var(--progress-width, 100%); }
}

/* Hover effects pour cartes interactives */
.hover-lift {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 1rem 3rem rgba(40, 167, 69, 0.175);
}

/* ============================================
   TABLEAUX THÉMATIQUES
   ============================================ */

/* En-têtes de tableau agricoles */
.table-agri thead th {
  background: linear-gradient(135deg, var(--agri-primary), #20c997);
  color: white;
  border: none;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
}

/* Lignes de tableau avec alternance */
.table-agri tbody tr:nth-child(even) {
  background-color: rgba(40, 167, 69, 0.03);
}

.table-agri tbody tr:hover {
  background-color: rgba(40, 167, 69, 0.08);
  transform: scale(1.01);
  transition: all 0.2s ease;
}

/* ============================================
   RESPONSIVE DESIGN RURAL
   ============================================ */

/* Optimisations pour connexions lentes */
@media (max-width: 768px) {
  .agri-card {
    margin-bottom: 1rem;
    box-shadow: 0 0.25rem 0.5rem rgba(40, 167, 69, 0.1);
  }

  .menu-header .menu-header-text {
    font-size: 10px;
  }

  .kpi-agriculture,
  .kpi-finance,
  .kpi-commerce,
  .kpi-stocks {
    margin-bottom: 0.75rem;
  }

  .btn-agri-primary,
  .btn-agri-secondary {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }

  .circle-indicator {
    width: 50px;
    height: 50px;
    font-size: 0.875rem;
  }
}

/* Tablettes */
@media (min-width: 768px) and (max-width: 992px) {
  .agri-card {
    min-height: 120px;
  }
}

/* ============================================
   UTILITAIRES CONTEXTUELS
   ============================================ */

/* Couleurs de texte thématiques */
.text-agriculture { color: var(--agri-primary) !important; }
.text-harvest { color: var(--agri-gold) !important; }
.text-weather { color: var(--agri-sky) !important; }
.text-earth { color: var(--agri-earth) !important; }

/* Arrière-plans thématiques */
.bg-agriculture { background-color: var(--agri-primary) !important; }
.bg-harvest { background-color: var(--agri-gold) !important; }
.bg-weather { background-color: var(--agri-sky) !important; }

/* Bordures thématiques */
.border-agriculture { border-color: var(--agri-primary) !important; }
.border-harvest { border-color: var(--agri-gold) !important; }
.border-weather { border-color: var(--agri-sky) !important; }

/* Classes d'état pour éléments dynamiques */
.status-active { color: var(--crop-active); }
.status-harvest { color: var(--crop-harvest); }
.status-planned { color: var(--crop-planned); }
.status-alert { color: var(--stock-low); }

/* ============================================
   DARK MODE (OPTIONNEL)
   ============================================ */

[data-bs-theme="dark"] {
  --agri-primary: #34d058;
  --agri-secondary: #fd7e14;
  --agri-light: #2d3748;
  --agri-dark: #f8f9fa;
}

[data-bs-theme="dark"] .agri-card {
  background-color: #2d3748;
  border-color: rgba(52, 208, 88, 0.2);
  color: #f8f9fa;
}

[data-bs-theme="dark"] .menu-header .menu-header-text {
  color: var(--agri-primary) !important;
}

/* ============================================
   OPTIMISATIONS PERFORMANCE
   ============================================ */

/* Optimisation GPU pour animations */
.agri-card,
.btn-agri-primary,
.btn-agri-secondary,
.hover-lift {
  will-change: transform;
  backface-visibility: hidden;
}

/* Préchargement des images de fond */
.kpi-agriculture,
.kpi-finance,
.kpi-commerce,
.kpi-stocks {
  background-attachment: local;
}

/* Smooth scrolling pour navigation */
html {
  scroll-behavior: smooth;
}

/* ============================================
   PRINT STYLES (RAPPORTS)
   ============================================ */

@media print {
  .agri-card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }

  .btn-agri-primary,
  .btn-agri-secondary {
    color: #000 !important;
    background: #fff !important;
    border: 1px solid #000 !important;
  }

  .kpi-agriculture,
  .kpi-finance,
  .kpi-commerce,
  .kpi-stocks {
    background: #f8f9fa !important;
    color: #000 !important;
  }
}
