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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fa;
  color: #102a43;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: #fff;
  border-bottom: 1.5px solid #e2e8f0;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.app-header-left h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #102a43;
  line-height: 1.3;
}

.app-header-brand {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.header-logo {
  height: 60px;
  width: 94px;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.header-school-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-bottom: 2px;
}

.header-school {
  font-size: 0.7rem;
  font-weight: 700;
  color: #102a43;
  letter-spacing: 0.05em;
  line-height: 1.4;
}

main {
  padding: 1rem;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.class-selector,
.date-row {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

label {
  font-size: 0.9rem;
  color: #486581;
}

input[type="text"],
input[type="date"],
select {
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #d9e2ec;
  font-size: 1rem;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-color: #136f63;
  box-shadow: 0 0 0 2px rgba(19, 111, 99, 0.2);
}

.students-section {
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.06);
  margin-top: 1rem;
  overflow: hidden;
}

.students-header {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 0.75rem 1rem;
  background: #edf2f7;
  font-size: 0.9rem;
  font-weight: 600;
  color: #486581;
}

.students-list {
  list-style: none;
  max-height: 60vh;
  overflow-y: auto;
}

.lessons-section {
  margin-top: 0.75rem;
}

.lessons-list {
  list-style: none;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lesson-item {
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.75rem;
  border-radius: 0.6rem;
  background: #ffffff;
  border: 1px solid #d9e2ec;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.lesson-item-time {
  font-size: 0.85rem;
  color: #627d98;
}

.lesson-item-subject {
  font-size: 0.95rem;
  font-weight: 600;
  color: #102a43;
}



.lesson-item.selected {
  border-color: #136f63;
  background: #e6fffa;
}

.lessons-collapsed .lesson-item {
  display: none;
}

.lessons-collapsed .lesson-item.selected {
  display: flex;
}

.lesson-item:active {
  transform: scale(0.98);
}

.student-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid #edf2f7;
}

.student-name {
  font-size: 1rem;
}

.btn-group {
  display: flex;
  gap: 5px;
  align-items: center;
}

.state-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #d9e2ec;
  background: #fff;
  color: #9fb3c8;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
}

.state-btn:active {
  transform: scale(0.9);
}

/* P — présent */
.state-btn[data-state="P"].active {
  background: #136f63;
  color: #fff;
  border-color: #136f63;
}

/* A — absent */
.state-btn[data-state="A"].active {
  background: #c53030;
  color: #fff;
  border-color: #c53030;
}

/* E — excusé */
.state-btn[data-state="E"].active {
  background: #b7791f;
  color: #fff;
  border-color: #b7791f;
}

/* Reporté — carried from prior lesson, subtle visual only */
.state-btn.active.carried {
  opacity: 0.5;
}

.student-row[data-source="reporté"] .student-name::after {
  content: " ↩";
  font-size: 0.75rem;
  color: #9fb3c8;
}

.primary-btn {
  background: #136f63;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.primary-btn.wide {
  width: 100%;
  margin-top: 1rem;
}

.primary-btn:active {
  transform: scale(0.97);
}

.actions {
  margin-top: 0.5rem;
}

.status-message {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #2b6cb0;
}

@media (min-width: 640px) {
  .app-header h1 {
    font-size: 1.4rem;
  }

  .primary-btn {
    font-size: 1rem;
  }
}

.secondary-btn {
  background: #fff;
  color: #136f63;
  border: 1.5px solid #136f63;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:active { transform: scale(0.97); }
.secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }



/* ================= ONBOARDING SCREEN ================= */

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
}

.onboarding-box {
  background: #fff;
  border-radius: 1rem;
  padding: 2rem 1.5rem;
  max-width: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.onboarding-logo {
  height: 60px;
  width: auto;
  margin-bottom: 0.5rem;
}

.onboarding-box h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #102a43;
  margin: 0;
}

.onboarding-box p {
  font-size: 0.9rem;
  color: #486581;
  line-height: 1.6;
  margin: 0;
}

#init-progress-wrap {
  width: 100%;
}

#init-progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

#init-progress-fill {
  height: 100%;
  width: 0%;
  background: #136f63;
  border-radius: 999px;
  transition: width 0.4s ease;
}

#init-progress-fill.indeterminate {
  width: 30%;
  animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { margin-left: 0%;  width: 30%; }
  50%  { margin-left: 60%; width: 30%; }
  100% { margin-left: 0%;  width: 30%; }
}

#init-progress-text {
  font-size: 0.85rem;
  color: #627d98;
  margin: 0;
}

.init-error {
  font-size: 0.85rem;
  color: #c53030;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* ================= CACHE INFO ================= */

.cache-info {
  font-size: 0.75rem;
  color: #9fb3c8;
  margin-top: 0.25rem;
  text-align: center;
}

/* ================= SUMMARY BAR ================= */

.summary-bar {
  padding: 0.4rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #486581;
  background: #f0f4f8;
  border-bottom: 1px solid #e2e8f0;
  letter-spacing: 0.03em;
  min-height: 1.8rem;
}
