:root {
  --violet: #6D28D9;
  --violet-dark: #4C1D95;
  --violet-light: #EDE7FA;
  --violet-soft: #F5F2FC;
  --white: #FFFFFF;
  --text: #2B2438;
  --text-muted: #7A7189;
  --border: #E7E1F5;
  --green: #16A34A;
  --red: #DC2626;
  --orange: #D97706;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(109, 40, 217, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--violet-soft);
  color: var(--text);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  background: linear-gradient(180deg, var(--violet-dark), var(--violet));
  color: var(--white);
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  transform: translateX(0);
  transition: transform .25s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 22px 20px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar .brand span { font-weight: 400; opacity: .85; font-size: .85rem; display:block; }

.sidebar nav { padding: 14px 0; flex: 1; overflow-y: auto; }
.sidebar-user {
  padding: 16px 22px;
  border-top: 1px solid rgba(255,255,255,.15);
}
.sidebar-user-name { color: var(--white); font-weight: 700; font-size: .9rem; }
.sidebar-user-role { color: rgba(255,255,255,.7); font-size: .75rem; margin-bottom: 8px; }
.sidebar-logout { display: inline-block; color: rgba(255,255,255,.85); font-size: .82rem; margin-top: 4px; }
.sidebar-logout:hover { color: var(--white); text-decoration: underline; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  font-size: .95rem;
  color: rgba(255,255,255,.85);
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.sidebar nav a.active {
  background: rgba(255,255,255,.14);
  border-left-color: var(--white);
  color: var(--white);
  font-weight: 600;
}
.sidebar .icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 35;
}

/* ---------- Main content ---------- */
.main {
  margin-left: 250px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 1.25rem; margin: 0; color: var(--violet-dark); }
.menu-toggle {
  display: none;
  background: var(--violet);
  color: var(--white);
  border: none;
  border-radius: 8px;
  width: 38px; height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ---------- Notifications ---------- */
.notif-wrap { margin-left: auto; position: relative; }
.notif-bell {
  position: relative;
  background: var(--violet-soft);
  border: 1.5px solid var(--violet-light);
  border-radius: 10px;
  width: 42px; height: 42px;
  font-size: 1.15rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.notif-bell:hover { background: var(--violet-light); }
.notif-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--red);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--white);
}
.notif-dropdown {
  display: none;
  position: absolute;
  top: 52px; right: 0;
  width: 320px;
  max-width: 88vw;
  max-height: 420px;
  overflow-y: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(76, 29, 149, .22);
  border: 1px solid var(--border);
  z-index: 60;
}
.notif-dropdown.open { display: block; }
.notif-header {
  padding: 14px 16px 10px;
  font-weight: 700;
  color: var(--violet-dark);
  border-bottom: 1px solid var(--border);
}
.notif-section-title {
  padding: 10px 16px 4px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 700;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 16px;
  font-size: .84rem;
  color: var(--text);
}
.notif-item:hover { background: var(--violet-soft); }
.notif-dot { width: 8px; height: 8px; border-radius: 999px; margin-top: 5px; flex-shrink: 0; }
.notif-dot-orange { background: var(--orange); }
.notif-dot-red { background: var(--red); }
.notif-more {
  display: block;
  text-align: center;
  padding: 10px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--violet);
  border-top: 1px solid var(--border);
}
.notif-more:hover { background: var(--violet-soft); }
.notif-empty { padding: 18px 16px; color: var(--text-muted); font-size: .85rem; text-align: center; }

.prets-liste { display: flex; flex-direction: column; gap: 10px; }
.pret-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 10px;
  padding: 12px 14px;
}
.pret-info { font-size: .9rem; }

.rappel-envoi-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #FFFBEB, #FEF3C7);
  border: 1.5px solid #F59E0B;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  color: #92400E;
  font-size: .88rem;
  animation: pulseAttente 2.2s ease-in-out infinite;
}
.rappel-envoi-banner:hover { background: #FEF3C7; }
.rappel-envoi-icon { font-size: 1.2rem; }

.content { padding: 24px; flex: 1; }

/* ---------- Cards / KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border-top: 4px solid var(--violet);
}
.kpi-card .kpi-value { font-size: 1.9rem; font-weight: 800; color: var(--violet-dark); }
.kpi-card .kpi-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.kpi-card.green { border-top-color: var(--green); }
.kpi-card.orange { border-top-color: var(--orange); }
.kpi-card.red { border-top-color: var(--red); }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}
.card h2 {
  font-size: 1.05rem;
  margin: 0 0 16px;
  color: var(--violet-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
/* Empêche un mot trop long (sans espace) de déborder de sa case et de chevaucher la colonne
   suivante — notamment pour les messages/réponses de longueur variable (archive, requêtes...). */
table td { word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; }
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { color: var(--violet-dark); font-weight: 700; background: var(--violet-soft); }
tr:hover td { background: var(--violet-soft); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-actif { background: #DCFCE7; color: var(--green); }
.badge-expire { background: #FEE2E2; color: var(--red); }
.badge-suspendu { background: #FEE2E2; color: var(--red); }
.badge-renouvele { background: var(--violet-light); color: var(--violet-dark); }
.badge-attente { background: #FEF3C7; color: var(--orange); }
.badge-pulse { animation: pulseAttente 1.8s ease-in-out infinite; }
@keyframes pulseAttente {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, .35); }
  50% { box-shadow: 0 0 0 6px rgba(217, 119, 6, 0); }
}

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--violet);
  color: var(--white);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
}
.btn:hover { background: var(--violet-dark); }
.btn.btn-outline { background: var(--white); color: var(--violet); border: 1.5px solid var(--violet); }
.btn.btn-danger { background: var(--red); }
.btn.btn-sm { padding: 6px 10px; font-size: .8rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: .92rem;
  background: var(--white);
  color: var(--text);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--violet); }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input { flex: 1; min-width: 200px; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--border); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem; }
.alert-success { background: #DCFCE7; color: #166534; }
.alert-error { background: #FEE2E2; color: #991B1B; }

.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.domaine-title {
  margin: 22px 0 10px;
  color: var(--violet-dark);
  font-size: 1rem;
  border-bottom: 2px solid var(--violet-light);
  padding-bottom: 6px;
}
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.service-card { background: var(--violet-soft); border-radius: 12px; padding: 14px; border: 1px solid var(--violet-light); }
.service-card h3 { margin: 0 0 8px; font-size: .95rem; color: var(--violet-dark); }
.service-card .prices { font-size: .8rem; color: var(--text-muted); line-height: 1.6; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items:center; justify-content:center; }
  .content { padding: 16px; }
  table { font-size: .82rem; }
}
