/* ============================================================
   AGRIMMOPRES — Design System Global
   Police : DM Sans (corps) + Fraunces (titres display)
   Thème  : Vert forêt profond + or chaud + ivoire
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Fraunces:opsz,wght@9..144,600;9..144,700;9..144,800&display=swap');

/* ─── Variables ──────────────────────────────────────────── */
:root {
  --primary:       #037051;
  --primary-dark:  #025a40;
  --primary-light: #e6f4ef;
  --primary-glow:  rgba(3,112,81,.15);

  --accent:        #c8873f;
  --accent-light:  #fdf3e9;

  --bg:            #f4f6f5;
  --surface:       #ffffff;
  --surface-2:     #f9fafb;

  --text:          #1a2520;
  --text-muted:    #6b7a74;
  --text-light:    #9eada7;

  --border:        #dde4e0;
  --border-strong: #c5d0cb;

  --danger:        #e03e3e;
  --warning:       #d4850a;
  --success:       #037051;
  --info:          #1b74b8;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --sidebar-w:     260px;
  --header-h:      62px;

  --transition:    all .22s cubic-bezier(.4,0,.2,1);
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Header / Navbar ────────────────────────────────────── */
.header-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 1200;
  padding: 0 20px;
  display: flex;
  align-items: center;
}

.header-bar .navbar-brand {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary) !important;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -.3px;
}

.header-bar .navbar-brand img {
  height: 32px;
  width: 32px;
  object-fit: contain;
}

/* User menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--text) !important;
  font-weight: 500;
  transition: var(--transition);
}
.user-menu:hover { background: var(--bg); }
.user-menu img {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 210px;
  animation: dropIn .18s ease;
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .875rem;
  color: var(--text);
  transition: var(--transition);
}
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }
.dropdown-item.text-danger:hover { background: #fdf0f0; color: var(--danger); }

/* Toggle sidebar button */
.toggle-btn {
  position: fixed;
  top: 13px;
  left: 16px;
  z-index: 1300;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
  line-height: 1;
}
.toggle-btn:hover { background: var(--bg); color: var(--primary); }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--primary-dark);
  color: #fff;
  overflow-y: auto;
  padding: 20px 14px 30px;
  z-index: 1100;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(255,255,255,.06);
}

.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 12px;
}
.sidebar-header h4 {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,.9);
  margin: 0 0 2px;
}
.sidebar-header p {
  font-size: .8rem;
  color: rgba(255,255,255,.55);
  margin: 0;
}
.sidebar-header strong { color: rgba(255,255,255,.8); }

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.72);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.sidebar .nav-link i { font-size: 1rem; opacity: .85; flex-shrink: 0; }

/* Submenu */
.sidebar .submenu {
  padding-left: 10px;
  margin-top: 2px;
}
.sidebar .submenu a {
  font-size: .83rem;
  color: rgba(255,255,255,.6);
  padding: 7px 12px;
  gap: 8px;
}
.sidebar .submenu a:hover { color: #fff; background: rgba(255,255,255,.08); }

.sidebar-section-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 14px 12px 4px;
}

/* ─── Content area ───────────────────────────────────────── */
.content-area {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 28px 30px;
  min-height: calc(100vh - var(--header-h));
  transition: margin-left .3s cubic-bezier(.4,0,.2,1), width .3s cubic-bezier(.4,0,.2,1);
}
.content-area.full {
  margin-left: 0;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}
.card-header.bg-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
  color: #fff !important;
  border-bottom: none;
}
.card-body { padding: 20px; }

/* Stat cards (dashboard) */
.stat-card {
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: .12;
  background: currentColor;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-icon {
  font-size: 1.6rem;
  opacity: .8;
  margin-bottom: 12px;
  display: block;
}
.stat-card .stat-value {
  font-family: 'Fraunces', serif;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card .stat-label {
  font-size: .8rem;
  font-weight: 500;
  opacity: .75;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-card .stat-sub {
  font-size: .78rem;
  margin-top: 8px;
  opacity: .7;
}

/* Card color variants */
.stat-card.green  { background: linear-gradient(135deg, #037051, #025a40); color: #fff; }
.stat-card.amber  { background: linear-gradient(135deg, #c8873f, #a96828); color: #fff; }
.stat-card.blue   { background: linear-gradient(135deg, #1b74b8, #155e95); color: #fff; }
.stat-card.red    { background: linear-gradient(135deg, #e03e3e, #b82e2e); color: #fff; }
.stat-card.teal   { background: linear-gradient(135deg, #0d9488, #0a7568); color: #fff; }
.stat-card.violet { background: linear-gradient(135deg, #7c3aed, #6027cc); color: #fff; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: .875rem;
  letter-spacing: .01em;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--primary-dark); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c43232; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b87009; color: #fff; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-outline-primary {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 11px 24px; font-size: 1rem; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-control,
.form-select {
  font-family: 'DM Sans', sans-serif;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
  box-shadow: none;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}
.form-control::placeholder { color: var(--text-light); }

.form-label {
  font-size: .825rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: .01em;
}

.form-control-lg { padding: 12px 16px; font-size: .975rem; }
.input-group .form-control { border-radius: var(--radius-sm); }

/* ─── Tables ─────────────────────────────────────────────── */
.table-responsive { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

.table {
  margin: 0;
  font-size: .875rem;
  border-collapse: collapse;
}
.table thead th {
  background: var(--primary-dark);
  color: rgba(255,255,255,.9);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 12px 16px;
  border: none;
  white-space: nowrap;
}
.table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--primary-light); }
.table tbody td {
  padding: 11px 16px;
  vertical-align: middle;
  color: var(--text);
}
.table-striped tbody tr:nth-of-type(even) { background: var(--surface-2); }
.table-striped tbody tr:nth-of-type(even):hover { background: var(--primary-light); }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: .72rem;
  padding: 4px 10px;
  border-radius: 99px;
  letter-spacing: .02em;
}
.badge.bg-success, .badge.bg-primary { background: var(--primary) !important; }
.badge.bg-danger  { background: var(--danger)  !important; }
.badge.bg-warning { background: var(--warning) !important; color: #fff !important; }
.badge.bg-info    { background: var(--info)    !important; }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-badge.disponible { background: #e6f4ef; color: var(--primary); }
.status-badge.vendu      { background: #fdf0f0; color: var(--danger); }
.status-badge.loue       { background: #fdf3e9; color: var(--accent); }
.status-badge.accepte    { background: #e6f4ef; color: var(--primary); }
.status-badge.refuse     { background: #fdf0f0; color: var(--danger); }
.status-badge.en_attente { background: #fdf8e6; color: var(--warning); }
.status-badge.paye       { background: #e6f4ef; color: var(--primary); }
.status-badge.impaye     { background: #fdf0f0; color: var(--danger); }
.status-badge.partiel    { background: #fdf3e9; color: var(--accent); }

/* ─── Modals ─────────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 16px 24px;
}
.modal-title { font-family: 'Fraunces', serif; font-size: 1.05rem; font-weight: 700; }
.btn-close { filter: invert(1) brightness(2); opacity: .8; }
.modal-body { padding: 24px; }
.modal-footer {
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ─── Alerts / Flash messages ────────────────────────────── */
.alert {
  border-radius: var(--radius);
  border: none;
  padding: 12px 18px;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: #e6f4ef; color: #025a40; }
.alert-danger   { background: #fdf0f0; color: #c43232; }
.alert-warning  { background: #fdf8e6; color: var(--warning); }
.alert-info     { background: #e8f2fb; color: var(--info); }

/* Flash animated */
#flash-message .alert {
  animation: slideIn .3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Pagination ─────────────────────────────────────────── */
.pagination { gap: 4px; }
.page-link {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  font-size: .85rem;
  transition: var(--transition);
}
.page-link:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ─── Page headers ───────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  color: var(--text);
}
.page-header h2 span { color: var(--primary); }

.breadcrumb {
  font-size: .8rem;
  color: var(--text-light);
  margin: 0;
}
.breadcrumb-item + .breadcrumb-item::before { color: var(--border-strong); }

/* ─── Login page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
}
.login-side {
  background: linear-gradient(145deg, var(--primary-dark) 0%, #013d2c 60%, #01291d 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}
.login-side::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-side-content { position: relative; z-index: 1; text-align: center; color: #fff; }
.login-side-logo {
  width: 90px; height: 90px;
  border-radius: 20px;
  object-fit: cover;
  margin-bottom: 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.login-side h1 {
  font-family: 'Fraunces', serif;
  font-size: 2.4rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px;
  letter-spacing: -.5px;
}
.login-side p {
  color: rgba(255,255,255,.65);
  font-size: .95rem;
  max-width: 320px;
  line-height: 1.65;
}
.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 50px;
  background: var(--surface);
}
.login-form-box {
  width: 100%;
  max-width: 400px;
}
.login-form-box h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.login-form-box .subtitle {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 32px;
}
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 1rem;
  pointer-events: none;
}
.input-icon-wrap .form-control { padding-left: 40px; }

@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-form-side { padding: 40px 24px; }
}

/* ─── Dashboard home stats ───────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.benefice-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-lg);
}
.benefice-card .label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .7;
  margin-bottom: 8px;
}
.benefice-card .amount {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.benefice-card .icon-bg {
  width: 60px; height: 60px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* ─── Print ──────────────────────────────────────────────── */
@media print {
  .sidebar, .toggle-btn, .header-bar, .no-print { display: none !important; }
  .content-area { margin: 0 !important; padding: 0 !important; }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; }
}

/* ─── Utilities ──────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.text-accent  { color: var(--accent)  !important; }
.bg-primary   { background: var(--primary) !important; }
.divider      { border-top: 1px solid var(--border); margin: 16px 0; }
.fw-semibold  { font-weight: 600; }

/* Collapsible submenu chevron */
.nav-link[data-bs-toggle="collapse"]::after {
  content: '\F282';
  font-family: 'bootstrap-icons';
  font-size: .75rem;
  margin-left: auto;
  transition: transform .25s ease;
  opacity: .6;
}
.nav-link[data-bs-toggle="collapse"].collapsed::after { transform: rotate(-90deg); }

/* ─── Overlay mobile ─────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1040;
}
#sidebar-overlay.active { display: block; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 992px) {
  /* Sur mobile la sidebar est cachée par défaut et passe par-dessus */
  .sidebar {
    transform: translateX(-100%);
    top: 0;
    height: 100vh;
  }
  .sidebar.open { transform: translateX(0); }

  /* Le contenu prend toute la largeur */
  .content-area {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 16px 12px;
  }
}
@media (max-width: 576px) {
  .content-area { padding: 16px 12px; }
  .page-header h2 { font-size: 1.2rem; }
  .stat-card .stat-value { font-size: 1.4rem; }
}

@media (max-width: 992px) {
  .sidebar.collapsed {
    transform: translateX(-100%) !important;
  }

  .sidebar.open {
    transform: translateX(0) !important;
  }
}
