/* ============================================
   PRESENCE APP — Design System
   Palette: Deep navy + electric indigo + mint
   Typo: Space Grotesk (display) + Inter (body)
   ============================================ */

:root {
  /* ── Fond principal : bleu nuit profond ── */
  --navy:       #0A1628;
  --navy-800:   #0F1F3D;
  --navy-700:   #162848;
  --navy-600:   #1E3560;

  /* ── Accent principal : orange vif ── */
  --indigo:     #F97316;
  --indigo-light: #FB923C;

  /* ── Accent secondaire : bleu électrique ── */
  --mint:       #3B82F6;
  --mint-light: #60A5FA;

  /* ── États ── */
  --red:        #EF4444;
  --red-light:  #FCA5A5;
  --amber:      #FBBF24;

  /* ── Neutres ── */
  --white:      #FFFFFF;
  --gray-100:   #F1F5F9;
  --gray-200:   #E2E8F0;
  --gray-400:   #94A3B8;
  --gray-600:   #475569;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --border:     rgba(255,255,255,0.07);
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--navy);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 0 12px var(--indigo);
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px var(--indigo), 0 0 20px rgba(249,115,22,0.3); }
  50% { box-shadow: 0 0 24px var(--indigo-light), 0 0 40px rgba(249,115,22,0.4); }
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--white);
}

.tab-nav {
  display: flex;
  gap: 2px;
  background: var(--navy-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); background: var(--border); }

.tab-btn.active {
  background: var(--indigo);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(249,115,22,0.5);
}

.header-date {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== MAIN ===== */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== PANEL HEADER ===== */
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.panel-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--white);
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.today-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--indigo);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--indigo-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(249,115,22,0.45);
}

.btn-ghost {
  background: var(--navy-800);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.16);
  background: var(--navy-700);
}

.btn-danger {
  background: rgba(244,63,94,0.12);
  color: var(--red-light);
  border: 1px solid rgba(244,63,94,0.2);
}
.btn-danger:hover {
  background: rgba(244,63,94,0.22);
}

/* ===== STATS ROW ===== */
.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-chip {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip span {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.stat-present { background: rgba(16,185,129,0.12); color: var(--mint-light); border: 1px solid rgba(16,185,129,0.2); }
.stat-absent  { background: rgba(244,63,94,0.12);  color: var(--red-light);  border: 1px solid rgba(244,63,94,0.2); }
.stat-pending { background: rgba(245,158,11,0.12); color: var(--amber);      border: 1px solid rgba(245,158,11,0.2); }

/* ===== ATTENDANCE LIST ===== */
.attendance-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attendance-card {
  background: var(--navy-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
}

.attendance-card:hover { border-color: rgba(255,255,255,0.14); }

.attendance-card.is-present { border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.04); }
.attendance-card.is-absent  { border-color: rgba(244,63,94,0.3);  background: rgba(244,63,94,0.04);  }

.student-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--white);
  flex-shrink: 0;
}

.student-info { flex: 1; min-width: 0; }
.student-name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.student-meta { font-size: 12px; color: var(--text-secondary); }

.attendance-toggle {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--navy-700);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.toggle-btn:hover { transform: scale(1.08); }

.toggle-btn.active-present {
  background: rgba(16,185,129,0.2);
  border-color: var(--mint);
  color: var(--mint-light);
  box-shadow: 0 0 10px rgba(16,185,129,0.2);
}

.toggle-btn.active-absent {
  background: rgba(244,63,94,0.2);
  border-color: var(--red);
  color: var(--red-light);
  box-shadow: 0 0 10px rgba(244,63,94,0.2);
}

/* ===== SEARCH ===== */
.search-bar { margin-bottom: 20px; }

.input-field {
  width: 100%;
  background: var(--navy-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition);
  outline: none;
}

.input-field:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(249,115,22,0.18); }
.input-field::placeholder { color: var(--text-secondary); }

/* ===== TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--navy-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table th {
  background: var(--navy-700);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 16px;
  text-align: left;
}

.data-table td {
  padding: 13px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
}

.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.rate-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.rate-high   { background: rgba(16,185,129,0.15); color: var(--mint-light); }
.rate-medium { background: rgba(245,158,11,0.15); color: var(--amber); }
.rate-low    { background: rgba(244,63,94,0.15);  color: var(--red-light); }

.table-actions { display: flex; gap: 6px; }

/* ===== HISTORY ===== */
.history-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.history-filters .input-field { width: auto; flex: 1; min-width: 130px; }
.filter-sep { color: var(--text-secondary); flex-shrink: 0; }

.history-list { display: flex; flex-direction: column; gap: 16px; }

.history-session {
  background: var(--navy-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.history-session-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background var(--transition);
  gap: 12px;
  flex-wrap: wrap;
}

.history-session-header:hover { background: rgba(255,255,255,0.03); }

.session-date {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 15px;
}

.session-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.session-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
}

.badge-present { background: rgba(16,185,129,0.15); color: var(--mint-light); }
.badge-absent  { background: rgba(244,63,94,0.15);  color: var(--red-light); }

.chevron { color: var(--text-secondary); transition: transform var(--transition); font-size: 12px; }
.chevron.open { transform: rotate(180deg); }

.history-session-body { display: none; border-top: 1px solid var(--border); }
.history-session-body.open { display: block; }

.session-detail-list {
  padding: 12px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.session-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--navy-700);
}

.detail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-present { background: var(--mint); }
.dot-absent  { background: var(--red); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
}

.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-state p { margin-bottom: 16px; font-size: 15px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--navy-800);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 20px 24px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }

.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; }

.field-error { font-size: 12px; color: var(--red-light); }
.field-error.hidden { display: none; }
.input-field.error { border-color: var(--red); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--navy-700);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  box-shadow: var(--shadow);
  min-width: 240px;
  animation: toastIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.hidden { display: none; }
.toast.toast-success { border-left: 3px solid var(--mint); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--indigo); }

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .header-inner { gap: 12px; }
  .brand-name { display: none; }
  .tab-btn { padding: 6px 10px; font-size: 12px; }
  .panel-header { flex-direction: column; align-items: flex-start; }
  .today-actions { width: 100%; }
  .today-actions .btn { flex: 1; justify-content: center; }
  .data-table th:nth-child(4),
  .data-table td:nth-child(4) { display: none; }
  .session-detail-list { grid-template-columns: 1fr 1fr; }
}

/* ===== LOGOUT ===== */
.btn-logout {
  font-size: 12px;
  padding: 6px 12px;
  color: var(--text-secondary);
  gap: 6px;
  flex-shrink: 0;
  border-color: transparent;
}
.btn-logout:hover {
  color: var(--red-light);
  border-color: rgba(239,68,68,0.2);
  background: rgba(239,68,68,0.08);
}
.logout-label { font-size: 12px; }
@media (max-width: 700px) { .logout-label { display: none; } }
