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

:root {
  --navy: #0a3d62;
  --navy-mid: #1a5276;
  --navy-light: #2471a3;
  --gold: #1e8449;
  --gold-light: #27ae60;
  --gold-pale: #d5f5e3;
  --teal: #1abc9c;
  --teal-dark: #148f77;
  --red: #e74c3c;
  --orange: #f39c12;
  --purple: #9b59b6;
  --white: #f8f9fa;
  --gray-100: #eaf4fb;
  --gray-200: #d6eaf8;
  --gray-300: #aed6f1;
  --gray-400: #7fb3d3;
  --gray-500: #adb5bd;
  --gray-600: #6c8ebf;
  --text: #1a2a3a;
  --text-muted: #5d7a8a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(10,61,98,0.08);
  --shadow-lg: 0 8px 40px rgba(10,61,98,0.15);
  --transition: 0.25s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-100);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 80px;
  font-size: 15px;
}

/* ── APP HEADER ──────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, var(--navy-light) 100%);
  color: white;
  padding: 18px 20px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
}
.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #1e8449, #27ae60);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 12px rgba(30,132,73,0.4);
}
.app-logo-text { line-height: 1.2; }
.app-logo-title {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.app-logo-subtitle {
  font-size: 10px;
  color: #a8e6c3;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.9;
}
.header-actions { display: flex; gap: 8px; }
.header-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.header-btn:hover { background: rgba(255,255,255,0.2); }

/* ── PAGE CONTAINER ──────────────────────────────── */
.page-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px 20px;
}

/* ── SECTION HEADERS ─────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
}
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}
.section-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── TABS / BOTTOM NAV ───────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px 8px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  border: none;
  background: none;
  color: var(--gray-500);
  font-family: 'DM Sans', sans-serif;
}
.nav-item.active { color: var(--navy); }
.nav-item.active .nav-icon {
  background: #d5f5e3;
  color: #1e8449;
}
.nav-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 3px;
  transition: var(--transition);
}
.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ── CARDS ───────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 16px 18px; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: white;
  box-shadow: 0 2px 12px rgba(13,27,42,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(13,27,42,0.3); }
.btn-gold {
  background: linear-gradient(135deg, #1e8449, #27ae60);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(30,132,73,0.3);
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(30,132,73,0.4); }
.btn-success {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: white;
}
.btn-danger { background: linear-gradient(135deg, #c0392b, var(--red)); color: white; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--navy); color: var(--navy); background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ── BADGES ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-present { background: #d4edda; color: #155724; }
.badge-absent { background: #fde2e2; color: #8b1a1a; }
.badge-retard { background: #fff3cd; color: #7a5200; }
.badge-permission { background: #e8d9f5; color: #5c2d91; }
.badge-gold { background: var(--gold-pale); color: var(--gold); }
.badge-danger { background: #fde2e2; color: #8b1a1a; }
.badge-navy { background: #dde4f0; color: var(--navy); }

/* ── FORM ELEMENTS ───────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: white;
  transition: var(--transition);
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(13,27,42,0.08);
}
select.form-control { cursor: pointer; }

/* ── SEARCH BAR ──────────────────────────────────── */
.search-wrapper {
  position: relative;
  margin-bottom: 16px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  font-size: 16px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  background: white;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.search-input:focus {
  outline: none;
  border-color: var(--gold-light);
  box-shadow: 0 0 0 3px rgba(30,132,73,0.12), var(--shadow);
}
.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  margin-top: 4px;
  display: none;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--gray-100);
}
.search-result-item:hover { background: var(--gray-100); }
.search-result-item:last-child { border-bottom: none; }

/* ── MEMBER LIST ─────────────────────────────────── */
.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
  cursor: pointer;
}
.member-item:last-child { border-bottom: none; }
.member-item:hover { background: var(--gray-100); }
.member-item.alert-absence {
  background: linear-gradient(90deg, rgba(231,76,60,0.06), transparent);
  border-left: 3px solid var(--red);
}
.member-item.top5 {
  background: linear-gradient(90deg, rgba(30,132,73,0.07), transparent);
  border-left: 3px solid var(--gold-light);
}
.member-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--gray-200);
  flex-shrink: 0;
}
.member-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--navy-light), var(--navy));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.member-info { flex: 1; min-width: 0; }
.member-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-stats {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.stat-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.chip-green { background: #d4edda; color: #155724; }
.chip-red { background: #fde2e2; color: #8b1a1a; }
.chip-orange { background: #fff3cd; color: #7a5200; }
.chip-purple { background: #e8d9f5; color: #5c2d91; }
.chip-gray { background: var(--gray-200); color: var(--gray-600); }
.member-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── PRESENCE TOGGLE ─────────────────────────────── */
.presence-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}
.presence-row:last-child { border-bottom: none; }
.presence-toggle-group {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.p-btn {
  width: 34px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--gray-300);
  background: white;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'DM Sans', sans-serif;
  color: var(--gray-500);
}
.p-btn:hover { transform: scale(1.08); }
.p-btn.active-P { background: var(--teal); border-color: var(--teal); color: white; box-shadow: 0 2px 8px rgba(26,188,156,0.35); }
.p-btn.active-A { background: var(--red); border-color: var(--red); color: white; box-shadow: 0 2px 8px rgba(231,76,60,0.35); }
.p-btn.active-R { background: var(--orange); border-color: var(--orange); color: white; box-shadow: 0 2px 8px rgba(243,156,18,0.35); }
.p-btn.active-V { background: var(--purple); border-color: var(--purple); color: white; box-shadow: 0 2px 8px rgba(155,89,182,0.35); }

/* ── STATS CARDS ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.blue::before { background: var(--navy); }
.stat-card.green::before { background: var(--teal); }
.stat-card.red::before { background: var(--red); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.gold::before { background: var(--navy-light); }
.stat-card-num {
  font-size: 32px;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.stat-card-icon {
  position: absolute;
  right: 14px;
  top: 14px;
  font-size: 24px;
  opacity: 0.12;
}

/* ── PROGRESS BAR ────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ── MODAL ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-sheet {
  background: white;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 800px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 0 0 32px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}
.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: 12px auto 0;
}
.modal-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.modal-body { padding: 20px; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── DATE PICKER ROW ─────────────────────────────── */
.date-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.date-row .form-control { flex: 1; }

/* ── PHOTO PREVIEW ───────────────────────────────── */
.photo-preview-area {
  width: 100%;
  height: 180px;
  border-radius: var(--radius);
  border: 2px dashed var(--gray-300);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  background: var(--gray-100);
  transition: var(--transition);
  position: relative;
}
.photo-preview-area:hover { border-color: var(--gold-light); background: var(--gold-pale); }
.photo-preview-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  opacity: 0;
  transition: var(--transition);
}
.photo-preview-area:hover .photo-overlay { opacity: 1; }

/* ── GUIDE ───────────────────────────────────────── */
.guide-section {
  margin-bottom: 20px;
}
.guide-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  padding: 14px 18px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  transition: var(--transition);
}
.guide-section-title:hover { background: var(--gold-pale); }
.guide-content {
  padding: 14px 18px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
  display: none;
}
.guide-content.open { display: block; }
.guide-step {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  align-items: flex-start;
}
.guide-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── TOAST ───────────────────────────────────────── */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--navy);
  color: white;
  padding: 12px 20px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 40px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--teal-dark); }
.toast.error { background: #c0392b; }
.toast.warning { background: #d68910; }

/* ── CHARTS ──────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 200px;
  margin: 10px 0;
}

/* ── REPORT BUTTONS ──────────────────────────────── */
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.report-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px;
  background: white;
  border-radius: var(--radius);
  border: 1.5px solid var(--gray-200);
  cursor: pointer;
  transition: var(--transition);
  gap: 8px;
  box-shadow: var(--shadow);
}
.report-btn:hover { border-color: var(--gold-light); background: var(--gold-pale); transform: translateY(-2px); }
.report-btn-icon { font-size: 28px; }
.report-btn-label { font-size: 13px; font-weight: 600; color: var(--navy); }
.report-btn-desc { font-size: 11px; color: var(--text-muted); }

/* ── EMPTY STATE ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 14px; }

/* ── LOADER ──────────────────────────────────────── */
.loader {
  display: flex;
  justify-content: center;
  padding: 30px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TABS ────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
  gap: 2px;
}
.tab-item {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  color: var(--gray-600);
}
.tab-item.active {
  background: white;
  color: var(--navy);
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}

/* ── ANIMATIONS ──────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.pulsing { animation: pulse 2s infinite; }

/* ── DIVIDER ─────────────────────────────────────── */
.divider { height: 1px; background: var(--gray-200); margin: 8px 0; }

/* ── SELECT STYLED ───────────────────────────────── */
.select-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.select-row .form-control { flex: 1; min-width: 100px; }

/* ── TOP5 MEMBER CARD ────────────────────────────── */
.top5-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.top5-card:last-child { border-bottom: none; }
.top5-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.rank-1 { background: #ffd700; color: #7a5200; }
.rank-2 { background: #c0c0c0; color: #333; }
.rank-3 { background: #cd7f32; color: white; }
.rank-4, .rank-5, .rank-6, .rank-7, .rank-8, .rank-9, .rank-10 { background: var(--gray-200); color: var(--gray-600); }
.top5-taux { font-size: 18px; font-weight: 700; color: var(--navy-light); min-width: 44px; text-align: right; }

/* Responsive */
@media (max-width: 380px) {
  .report-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}
