/* ══════════════════════════════════════════════════════════════════
   Sahel Farm Platform — Design "Terres de l'Harmattan"
   Inspiré de SahelSchool — optimisé 3G Bamako
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --primary:        #0A5C3A;
  --primary-light:  #B8EDD4;
  --primary-dark:   #073D27;
  --secondary:      #C47D16;
  --secondary-light:#FEF0CC;
  --danger:         #C0392B;
  --danger-light:   #FDECEA;
  --bg-main:        #F4EFE6;
  --bg-card:        #FDFAF5;
  --sidebar-bg:     #091F13;
  --sidebar-active: #E8943A;
  --text-main:      #1A1410;
  --text-muted:     #6B5E50;
  --border:         #E0D5C5;
  --radius-sm:      10px;
  --radius-md:      14px;
  --radius-lg:      20px;
  --shadow:    0 2px 8px rgba(10,31,19,.07), 0 1px 3px rgba(10,31,19,.04);
  --shadow-lg: 0 16px 48px rgba(10,31,19,.12), 0 6px 16px rgba(10,31,19,.07);
  --transition: all .3s cubic-bezier(.23,1,.32,1);
  --font-display: 'Georgia', 'Times New Roman', serif;
  --font-body:    'DM Sans', 'Segoe UI', sans-serif;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--text-main);
  background:
    radial-gradient(ellipse 70% 50% at 85% 0%, rgba(10,92,58,.06), transparent 60%),
    radial-gradient(ellipse 50% 40% at 10% 100%, rgba(196,125,22,.05), transparent 55%),
    var(--bg-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { font-family: var(--font-display); color: var(--text-main); letter-spacing: -.02em; }

/* ══ LOGIN ══════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(196,125,22,.22), transparent 50%),
    radial-gradient(ellipse 60% 60% at 85% 90%, rgba(10,92,58,.2), transparent 55%),
    linear-gradient(160deg, #071a0e 0%, #091f13 40%, #070d09 100%);
}

.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--secondary);
}

.login-kicker {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; color: var(--secondary);
  margin-bottom: .625rem; display: block;
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.9rem; font-weight: 900;
  color: var(--text-main); margin-bottom: .25rem;
}

.login-sub { font-size: .85rem; color: var(--text-muted); margin-bottom: 2rem; display: block; }

/* ══ APP SHELL ══════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

/* ══ SIDEBAR ════════════════════════════════════════════════════════ */
.sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 1.5rem 1rem;
  display: flex; flex-direction: column; gap: 1rem;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(127,184,150,.3); border-radius: 999px; }

.sidebar-brand .brand-kicker {
  font-size: .68rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--sidebar-active); margin-bottom: .5rem;
}

.sidebar-brand h1 { font-size: 1.35rem; font-weight: 900; color: #EDE8DE; margin-bottom: .2rem; }
.sidebar-brand p  { font-size: .75rem; color: rgba(127,184,150,.65); }

.sidebar-session {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-md);
  padding: .875rem 1rem;
}

.session-label {
  font-size: .64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: rgba(127,184,150,.55); margin-bottom: .5rem; display: block;
}

.session-name { font-size: .875rem; font-weight: 700; color: #EDE8DE; display: block; margin-bottom: .35rem; }

.session-role {
  display: inline-block; padding: .2rem .65rem; border-radius: 999px;
  background: rgba(232,148,58,.15); border: 1px solid rgba(232,148,58,.25);
  font-size: .64rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--sidebar-active);
}

.nav-section-label {
  font-size: .63rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .13em; color: rgba(127,184,150,.5);
  padding: 0 .5rem; margin: .5rem 0 .25rem;
  display: flex; align-items: center; gap: .5rem;
}

.nav-section-label::before {
  content:''; width: 5px; height: 5px; border-radius: 50%;
  background: rgba(232,148,58,.5); flex-shrink: 0;
}

.nav-item {
  display: flex; align-items: center; gap: .75rem;
  width: 100%; padding: .7rem 1rem;
  border-radius: var(--radius-md); border: none;
  background: transparent; color: #7FB896;
  font-family: var(--font-body); font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,.07); color: #EDE8DE; }

.nav-item.active {
  background: linear-gradient(135deg, rgba(232,148,58,.2), rgba(196,125,22,.13));
  border-left: 3px solid var(--sidebar-active);
  color: #FFF3DE; padding-left: calc(1rem - 3px);
}

.nav-glyph {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; background: rgba(255,255,255,.07); font-size: .875rem;
}

.nav-item.active .nav-glyph { background: rgba(232,148,58,.22); }

.nav-glyph svg {
  width: 15px; height: 15px;
  stroke: currentColor; stroke-width: 2;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

.nav-text { font-weight: 600; font-size: .875rem; }

.btn-logout {
  display: flex; align-items: center; gap: .625rem;
  width: 100%; padding: .625rem 1rem;
  border-radius: var(--radius-md); border: none;
  background: rgba(255,255,255,.05); color: rgba(127,184,150,.6);
  font-family: var(--font-body); font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); text-align: left; margin-top: auto;
}

.btn-logout:hover { background: rgba(192,57,43,.15); color: #f8a8a0; }

/* ══ MAIN PANEL ═════════════════════════════════════════════════════ */
.main-panel { flex: 1; min-width: 0; padding: 2rem 2.5rem; }

.view-header { margin-bottom: 1.75rem; }

.view-header-inner {
  display: flex; justify-content: space-between;
  align-items: center; gap: 1rem; flex-wrap: wrap;
}

.view-title {
  font-family: var(--font-display);
  font-size: 1.75rem; font-weight: 900; margin-bottom: .3rem;
}

.view-subtitle { font-size: .875rem; color: var(--text-muted); }

/* Hero */
.hero-banner {
  background: linear-gradient(140deg, #0E7048 0%, #0A5C3A 40%, #073D27 100%);
  color: #fff; border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1.5rem; flex-wrap: wrap;
  box-shadow: 0 10px 36px rgba(10,92,58,.3), 0 4px 12px rgba(10,92,58,.18);
  margin-bottom: 1.75rem;
}

.hero-banner h2 { font-size: 1.7rem; font-weight: 900; color: #fff; margin-bottom: .4rem; }
.hero-kicker { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; color: rgba(255,255,255,.6); margin-bottom: .4rem; display: block; }

/* Cards */
.card-aura {
  background: var(--bg-card);
  border-radius: var(--radius-lg); padding: 1.5rem;
  border: 1px solid var(--border); border-top: 3px solid var(--primary);
  box-shadow: var(--shadow); transition: var(--transition);
}

.card-aura:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.card-header {
  display: flex; justify-content: space-between;
  align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}

.card-header h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 900; }
.card-header p  { font-size: .82rem; color: var(--text-muted); margin-top: .2rem; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  box-shadow: var(--shadow); transition: var(--transition);
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); margin-bottom: .625rem; display: block; }
.kpi-value { font-family: var(--font-display); font-size: 2rem; font-weight: 900; color: var(--primary-dark); line-height: 1; display: block; margin-bottom: .375rem; }
.kpi-sub   { font-size: .75rem; color: var(--text-muted); }

/* Buttons */
.btn-gradient, .btn-primary, .btn-outline, .btn-danger {
  font-family: var(--font-body); font-weight: 600;
  border: none; cursor: pointer; transition: var(--transition);
  display: inline-flex; align-items: center; gap: .5rem;
  text-decoration: none;
}

.btn-gradient {
  background: linear-gradient(140deg, #0E7048, #0A5C3A); color: #fff;
  padding: .625rem 1.25rem; border-radius: var(--radius-md); font-size: .875rem;
  box-shadow: 0 6px 20px rgba(10,92,58,.3);
}
.btn-gradient:hover { background: linear-gradient(140deg, #0A5C3A, #073D27); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(10,92,58,.4); }
.btn-gradient:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  background: var(--primary); color: #fff;
  padding: .625rem 1.25rem; border-radius: var(--radius-md); font-size: .875rem;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-outline {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-main); padding: .625rem 1.25rem;
  border-radius: var(--radius-md); font-size: .875rem;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(10,92,58,.05); }

.btn-danger {
  background: var(--danger); color: #fff;
  padding: .625rem 1.25rem; border-radius: var(--radius-md); font-size: .875rem;
}
.btn-danger:hover { background: #a93226; transform: translateY(-1px); }

.btn-sm { padding: .375rem .875rem !important; font-size: .78rem !important; }

.btn-icon {
  width: 32px; height: 32px; padding: 0;
  border-radius: var(--radius-sm); background: transparent;
  border: 1px solid var(--border); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition);
}
.btn-icon:hover { background: var(--bg-main); color: var(--primary); border-color: var(--primary); }
.btn-icon-danger { color: var(--danger); border-color: rgba(192,57,43,.25); }
.btn-icon-danger:hover { background: var(--danger-light); border-color: var(--danger); }
.btn-icon svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.actions-row { display: flex; gap: .625rem; align-items: center; flex-wrap: wrap; }

/* Forms */
.form-stack  { display: flex; flex-direction: column; gap: 1rem; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group  { display: flex; flex-direction: column; gap: .5rem; }

.form-group label, .form-label {
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-main);
}

.form-control {
  width: 100%; padding: .75rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-card); font-family: var(--font-body);
  font-size: .875rem; color: var(--text-main); transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10,92,58,.1); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table { width: 100%; border-collapse: collapse; min-width: 500px; }

.data-table th {
  padding: .875rem 1rem; background: var(--bg-main);
  font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-muted);
  border-bottom: 2px solid var(--border); white-space: nowrap;
}

.data-table td {
  padding: .875rem 1rem; border-bottom: 1px solid var(--border);
  font-size: .875rem; color: var(--text-main); vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(10,92,58,.025); }

.cell-stack  { display: flex; flex-direction: column; gap: 3px; }
.cell-sub    { font-size: .75rem; color: var(--text-muted); }
.cell-mono   { font-family: ui-monospace, monospace; font-size: .78rem; color: var(--text-muted); }
.fw-semibold { font-weight: 600; }
.fw-bold     { font-weight: 700; }

.identity-cell { display: flex; align-items: center; gap: .75rem; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(10,92,58,.1); border: 2px solid rgba(10,92,58,.15);
  color: var(--primary-dark); display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; flex-shrink: 0;
}

/* Badges */
.status-badge {
  padding: .25rem .75rem; border-radius: 999px;
  font-size: .66rem; font-weight: 700;
  display: inline-flex; align-items: center; gap: .35rem;
  white-space: nowrap;
}

.status-badge::before {
  content:''; width: 5px; height: 5px;
  border-radius: 50%; background: currentColor; flex-shrink: 0;
}

.status-success { background: var(--primary-light);   color: var(--primary-dark); }
.status-warning { background: var(--secondary-light); color: #92580E; }
.status-danger  { background: var(--danger-light);    color: var(--danger); }
.status-info    { background: #EAF0F5;                color: #3D5466; }
.status-muted   { background: #EDEDEA;                color: var(--text-muted); }

/* Sector pills */
.sector-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.sector-pill {
  padding: .2rem .625rem; border-radius: 999px;
  font-size: .66rem; font-weight: 700;
  background: var(--primary-light); color: var(--primary-dark);
  border: 1px solid rgba(10,92,58,.15);
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7,13,9,.45); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }

.modal-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border); border-top: 3px solid var(--primary);
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(.97);
  transition: transform .22s cubic-bezier(.23,1,.32,1);
  overflow: hidden;
}
.modal-overlay.visible .modal-card { transform: none; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}
.modal-header h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 900; }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: .75rem;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  background: var(--bg-main);
}

/* Feedback */
.feedback { min-height: 20px; margin-top: .75rem; font-size: .875rem; }

.feedback-error {
  padding: .75rem 1rem; border-radius: var(--radius-md);
  background: var(--danger-light); border: 1px solid rgba(192,57,43,.2);
  color: var(--danger); font-weight: 600;
}

.feedback-success {
  padding: .75rem 1rem; border-radius: var(--radius-md);
  background: var(--primary-light); border: 1px solid rgba(10,92,58,.2);
  color: var(--primary-dark); font-weight: 600;
}

/* Skeleton */
.skeleton { border-radius: var(--radius-sm); animation: sfp-pulse 1.5s ease-in-out infinite; }
@keyframes sfp-pulse { 0%,100%{ background:#e2d9cc; } 50%{ background:#ede6dc; } }

/* Animations */
.stagger-item { opacity:0; transform:translateY(14px); animation: sfp-fadeUp .5s cubic-bezier(.16,1,.3,1) forwards; }
@keyframes sfp-fadeUp { to { opacity:1; transform:none; } }
.delay-1{animation-delay:.06s} .delay-2{animation-delay:.12s} .delay-3{animation-delay:.18s} .delay-4{animation-delay:.24s}

/* Section label */
.section-label {
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: .875rem; display: block;
}

/* Empty state */
.empty-state { text-align:center; padding:3rem 1.5rem; color:var(--text-muted); }
.empty-state p { font-size:.875rem; margin-top:.5rem; }

/* Utils */
.hidden     { display:none !important; }
.mt-16      { margin-top:1rem; }
.mt-20      { margin-top:1.25rem; }
.text-muted { color:var(--text-muted); }
.text-danger{ color:var(--danger); }

/* Responsive */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width:100%; height:auto; position:static; flex-direction:row; flex-wrap:wrap; gap:.75rem; padding:1rem; }
  .sidebar-brand, .sidebar-session { flex:1 1 180px; }
  nav { width:100%; display:flex; flex-wrap:wrap; gap:.25rem; }
  .nav-item { width:auto; flex:0 0 auto; }
  .main-panel { padding:1.25rem; }
  .form-row { grid-template-columns:1fr; }
}

@media (max-width: 600px) {
  .hero-banner { flex-direction:column; align-items:flex-start; }
  .hero-banner h2 { font-size:1.4rem; }
  .kpi-grid { grid-template-columns:1fr 1fr; }
  .view-header-inner { flex-direction:column; align-items:flex-start; }
  .modal-card { max-width:100%; border-radius:var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items:flex-end; padding:0; }
}
