/* === RESET & BASE === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1e1e3a;
  color: #ffffff;
  font-size: 14px;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #1e1e3a; }
::-webkit-scrollbar-thumb { background: #484880; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #5858a0; }

/* === LAYOUT === */
.app-container {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

/* === TOPBAR === */
.topbar {
  grid-column: 1 / -1;
  background: #1a1a32;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  border-bottom: 1px solid #383868;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-logo {
  font-size: 18px;
  font-weight: 700;
  color: #4ade80;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-name {
  font-size: 13px;
  opacity: 0.9;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); }

/* === SIDEBAR === */
.sidebar {
  background: #1a1a32;
  border-right: 1px solid #383868;
  padding: 16px 0;
  overflow-y: auto;
}
.nav-items {
  display: flex;
  flex-direction: column;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  color: #34d399;
  text-decoration: none;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: #282850;
  color: #4ade80;
}
.nav-item.active {
  color: #4ade80;
  background: #282850;
  border-left-color: #534AB7;
  font-weight: 500;
}
.nav-item.hidden { display: none; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1.0; }

/* === MAIN CONTENT === */
.main-content {
  padding: 24px;
  overflow-y: auto;
}
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #ffffff;
}

/* === PAGE HEADER === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-header h2 {
  font-size: 22px;
  color: #ffffff;
}

/* === CARDS / STATS === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #282850;
  border: 1px solid #383868;
  border-radius: 12px;
  padding: 20px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
}
.stat-label {
  font-size: 13px;
  color: #ffffff;
  margin-top: 4px;
}

/* === TABLES === */
.table-container {
  background: #282850;
  border: 1px solid #383868;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  background: #303060;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.5px;
}
td {
  padding: 12px 16px;
  border-top: 1px solid #383868;
  font-size: 13px;
  color: #ffffff;
}
tr:hover td { background: #303060; }

/* === PAYS GROUP HEADER === */
.pays-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #303060;
  font-weight: 600;
  font-size: 14px;
  color: #534AB7;
  border-top: 2px solid #383868;
}
.pays-header:first-child { border-top: none; }

/* === DRAPEAUX CSS === */
.flag {
  display: inline-block;
  width: 24px;
  height: 16px;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.flag-FR {
  background: linear-gradient(90deg, #002395 33.3%, #fff 33.3%, #fff 66.6%, #ED2939 66.6%);
}
.flag-BE {
  background: linear-gradient(90deg, #000 33.3%, #FAE042 33.3%, #FAE042 66.6%, #ED2939 66.6%);
}
.flag-CH {
  background: #D52B1E;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.flag-CH::after {
  content: '+';
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.flag-LU {
  background: linear-gradient(180deg, #ED2939 33.3%, #fff 33.3%, #fff 66.6%, #00A1DE 66.6%);
}

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-disponible { background: #0d3320; color: #34d399; }
.badge-assigné, .badge-assigne { background: #1e2a4a; color: #60a5fa; }
.badge-suspendu { background: #3b2f10; color: #fbbf24; }
.badge-actif { background: #0d3320; color: #34d399; }
.badge-inactif { background: #3b1111; color: #f87171; }
.badge-superadmin { background: #534AB7; color: #fff; }
.badge-partner { background: #2a2650; color: #818cf8; }
.badge-viewer { background: #303060; color: #b0b0cc; }
.badge-starter { background: #303060; color: #b0b0cc; }
.badge-pro { background: #1e2a4a; color: #60a5fa; }
.badge-business { background: #3a1f50; color: #c084fc; }
.badge-enterprise { background: #534AB7; color: #fff; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #484880;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  color: #ffffff;
}
.btn:hover { background: #303060; }
.btn-primary { background: #534AB7; color: #fff; border-color: #534AB7; }
.btn-primary:hover { background: #4339a0; border-color: #4339a0; }
.btn-secondary { background: #303060; color: #534AB7; border-color: #484880; }
.btn-secondary:hover { background: #484880; }
.btn-danger { background: #3b1111; color: #f87171; border-color: #5a1a1a; }
.btn-danger:hover { background: #4a1515; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* === FORMS === */
.form-card {
  background: #282850;
  border: 1px solid #383868;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  max-width: 600px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: #303060;
  border: 2px solid #484880;
  border-radius: 8px;
  font-size: 14px;
  color: #ffffff;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #534AB7;
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #b0b0cc;
}
.form-group select option {
  background: #303060;
  color: #ffffff;
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* === SEARCH BAR === */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.search-bar input {
  flex: 1;
  padding: 10px 16px;
  background: #303060;
  border: 2px solid #484880;
  border-radius: 8px;
  font-size: 14px;
  color: #ffffff;
  outline: none;
}
.search-bar input::placeholder { color: #b0b0cc; }
.search-bar input:focus { border-color: #534AB7; }

/* === FILTERS === */
.filters-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filters-row select,
.filters-row input {
  padding: 8px 12px;
  background: #303060;
  border: 2px solid #484880;
  border-radius: 8px;
  font-size: 13px;
  color: #ffffff;
  outline: none;
}
.filters-row select option {
  background: #303060;
  color: #ffffff;
}

/* === PERMISSIONS GRID === */
.perm-grid {
  display: grid;
  grid-template-columns: 140px repeat(3, 60px);
  gap: 4px;
  font-size: 12px;
}
.perm-grid .perm-header {
  font-weight: 600;
  text-transform: uppercase;
  color: #ffffff;
  padding: 4px;
}
.perm-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === PLACEHOLDER === */
.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #ffffff;
}
.placeholder-page .placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.placeholder-page p {
  font-size: 16px;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: #282850;
  border: 1px solid #383868;
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.modal h3 {
  margin-bottom: 20px;
  color: #ffffff;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #303060;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 2000;
  animation: fadeIn 0.2s, fadeOut 0.3s 2.7s;
}
.toast-success { background: #0d3320; color: #34d399; }
.toast-error { background: #3b1111; color: #f87171; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* === LOG ENTRIES === */
.log-entry:hover { background: #303060; }

/* === LOGIN PAGE === */
.login-page {
  background: #1e1e3a;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #282850;
  border: 1px solid #383868;
  border-radius: 16px;
  padding: 40px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-card h2 {
  color: #ffffff;
}
.login-card input {
  background: #303060;
  border: 2px solid #484880;
  color: #ffffff;
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  font-size: 14px;
  outline: none;
}
.login-card input::placeholder { color: #b0b0cc; }
.login-card input:focus { border-color: #534AB7; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
  }
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: -260px;
    width: 260px;
    height: calc(100vh - 56px);
    z-index: 99;
    transition: left 0.25s;
    box-shadow: 2px 0 8px rgba(0,0,0,0.3);
  }
  .sidebar.open { left: 0; }
  .main-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
