/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.5;
}

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

/* === Login Page === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--gray-100);
}

.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.login-subtitle {
  color: var(--gray-500);
  margin-bottom: 1.5rem;
}

/* === App Layout === */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: 240px;
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
  font-size: 1.25rem;
  letter-spacing: 0.05em;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.sidebar nav {
  flex: 1;
  padding: 0.5rem 0;
}

.sidebar nav ul { list-style: none; }

.sidebar nav a {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--gray-300);
  font-size: 0.875rem;
  transition: background 0.15s;
}

.sidebar nav a:hover {
  background: rgba(255,255,255,0.08);
  color: white;
  text-decoration: none;
}

.sidebar nav a.active {
  background: rgba(255,255,255,0.12);
  color: white;
  border-left: 3px solid var(--primary);
  padding-left: calc(1.25rem - 3px);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
}

.user-link { color: white; display: block; font-weight: 500; }
.user-role { color: var(--gray-500); display: block; margin-bottom: 0.5rem; font-size: 0.7rem; text-transform: uppercase; }
.btn-logout { color: var(--gray-500); font-size: 0.75rem; }
.btn-logout:hover { color: var(--danger); }

/* === Content === */
.content {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
}

.topbar {
  background: white;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}

.topbar h1 {
  font-size: 1.125rem;
  font-weight: 600;
}

.page-content {
  padding: 1.5rem;
}

/* === Dashboard === */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--gray-500);
  font-size: 0.8rem;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* === Tables === */
.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th, .table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.table th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--gray-500);
}

.table td { font-size: 0.875rem; }
.table td.empty { text-align: center; color: var(--gray-500); padding: 2rem; }

/* === Forms === */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  color: var(--gray-700);
}

input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="url"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--gray-100);
  color: var(--gray-500);
}

textarea { resize: vertical; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0 1rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: white; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); text-decoration: none; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; text-decoration: none; color: white; }
.btn-full { width: 100%; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-president { background: #dbeafe; color: #1e40af; }
.badge-secretaire { background: #f3e8ff; color: #6b21a8; }
.badge-tresorier { background: #fef3c7; color: #92400e; }
.badge-membre { background: var(--gray-100); color: var(--gray-700); }
.badge-actif { background: #dcfce7; color: #166534; }
.badge-inactif { background: #fee2e2; color: #991b1b; }
.badge-brouillon { background: var(--gray-100); color: var(--gray-700); }
.badge-planifie { background: #fef3c7; color: #92400e; }
.badge-envoye { background: #dcfce7; color: #166534; }
.badge-archive { background: var(--gray-200); color: var(--gray-500); }
.badge-erreur { background: #fee2e2; color: #991b1b; }
.badge-ouverte { background: #fef3c7; color: #92400e; }
.badge-payee { background: #dcfce7; color: #166534; }
.badge-annulee { background: var(--gray-200); color: var(--gray-500); }
.badge-planifie { background: #dbeafe; color: #1e40af; }
.badge-inscriptions { background: #fef3c7; color: #92400e; }
.badge-termine { background: var(--gray-200); color: var(--gray-500); }
.badge-annule { background: #fee2e2; color: #991b1b; }
.badge-confirme { background: #dcfce7; color: #166534; }
.badge-decline { background: #fee2e2; color: #991b1b; }
.badge-en_attente { background: #fef3c7; color: #92400e; }
.badge-enattente { background: #fef3c7; color: #92400e; }

/* === Events === */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.event-card {
  display: block;
  background: white;
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
  color: var(--gray-900);
}

.event-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  text-decoration: none;
}

.event-card h3 { font-size: 1rem; margin: 0.5rem 0 0.25rem; }

.event-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.event-date { font-size: 0.8rem; color: var(--primary); font-weight: 500; }

.event-stats {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

.event-stat { color: var(--gray-500); }
.stat-confirme { color: #166534; }
.stat-decline { color: #991b1b; }
.stat-attente { color: #92400e; }

.event-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.btn-group { display: flex; gap: 0.5rem; }

.event-gen-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gray-200);
}

.event-gen-check { padding-top: 1.75rem; }
.event-gen-check input { width: 18px; height: 18px; }

/* === Alerts === */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert ul { margin-left: 1.25rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* === Toolbar === */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
}

.filters {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filters input, .filters select {
  width: auto;
  min-width: 150px;
}

/* === Sections === */
.section {
  margin-top: 1.5rem;
}

.section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--gray-700);
}

/* === Misc === */
.inline { display: inline; }
.inline-form { display: inline-flex; gap: 0.5rem; align-items: center; }
.text-muted { color: var(--gray-500); font-size: 0.8rem; }
code { background: var(--gray-100); padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.8rem; }
.pagination { display: flex; gap: 0.25rem; margin-top: 1rem; }

.error-page {
  text-align: center;
  padding: 4rem 2rem;
}

.error-page h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.error-page p { color: var(--gray-500); margin-bottom: 1.5rem; }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h2 { font-size: 1rem; }
  .sidebar-subtitle, .sidebar-footer .user-link, .sidebar-footer .user-role { display: none; }
  .sidebar nav a { padding: 0.6rem; text-align: center; font-size: 0.7rem; }
  .content { margin-left: 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}
