:root {
  --primary: #0d47a1;
  --primary-dark: #002171;
  --primary-light: #5472d3;
  --accent: #ff6f00;
  --success: #2e7d32;
  --danger: #c62828;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-light: #5f6368;
  --border: #e0e0e0;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  padding-bottom: 80px;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

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

#splash {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.splash-content .logo {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.splash-content h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.splash-content p {
  opacity: 0.85;
  margin-bottom: 2.5rem;
  line-height: 1.4;
}

.header {
  background: var(--primary);
  color: white;
  padding: 1.25rem 1.25rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 1.35rem;
  font-weight: 600;
}

.header .subtitle {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

.header.with-back {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.content {
  padding: 1.25rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h2, .card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--primary-dark);
}

.card.highlight {
  background: #fff3e0;
  border-left: 4px solid var(--accent);
}

.card.highlight h3 {
  color: var(--accent);
}

.progress-bar {
  height: 10px;
  background: #e3e8ef;
  border-radius: 5px;
  overflow: hidden;
  margin: 0.75rem 0;
}

.progress-bar.small {
  height: 6px;
  margin: 0.5rem 0 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 5px;
  transition: width 0.4s ease;
}

.progress-card p {
  font-size: 0.95rem;
  color: var(--text-light);
}

.bloc-list {
  list-style: none;
}

.bloc-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.bloc-list li:last-child {
  border-bottom: none;
}

.module-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.15s;
}

.module-card:active {
  transform: scale(0.98);
}

.module-icon {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  background: #e3f2fd;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.module-info h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.module-info p {
  font-size: 0.85rem;
  color: var(--text-light);
}

.module-status {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  background: #e8f5e9;
  color: var(--success);
  white-space: nowrap;
  align-self: center;
}

.module-status.todo {
  background: #f5f5f5;
  color: var(--text-light);
}

.lesson-section {
  margin-bottom: 1.5rem;
}

.lesson-section h3 {
  font-size: 1.05rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #e3f2fd;
}

.lesson-section p, .lesson-section li {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.lesson-section ul {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.checklist li::before {
  content: "☐";
  color: var(--primary);
  font-size: 1.1rem;
}

.tip {
  background: #e8f5e9;
  border-radius: 8px;
  padding: 0.9rem;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.tip strong {
  color: var(--success);
}

.btn-primary, .btn-secondary {
  display: inline-block;
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.btn-secondary {
  background: #eceff1;
  color: var(--text);
}

.btn-secondary:active {
  background: #cfd8dc;
}

.full {
  width: 100%;
  margin-top: 0.5rem;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: white;
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  z-index: 100;
  border-top: 1px solid var(--border);
}

.bottom-nav.hidden {
  display: none;
}

.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
}

.nav-btn .icon {
  font-size: 1.35rem;
}

.nav-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.answers {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.answer-btn {
  padding: 0.9rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}

.answer-btn:active {
  transform: scale(0.98);
}

.answer-btn.selected {
  border-color: var(--primary);
  background: #e3f2fd;
}

.answer-btn.correct {
  border-color: var(--success);
  background: #e8f5e9;
}

.answer-btn.wrong {
  border-color: var(--danger);
  background: #ffebee;
}

.quiz-progress {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-light);
}

.hidden {
  display: none !important;
}

.certificate {
  background: white;
  border: 3px solid var(--primary);
  border-radius: 8px;
  padding: 1.5rem 1.25rem;
  margin: 1rem 0;
  text-align: center;
  box-shadow: 0 4px 16px rgba(13,71,161,0.12);
}

.cert-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.cert-logo {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.cert-header h2 {
  font-size: 1.3rem;
  color: var(--primary-dark);
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
}

.cert-sub {
  font-size: 0.9rem;
  color: var(--text-light);
}

.cert-body {
  font-size: 0.95rem;
  line-height: 1.6;
}

.cert-body p {
  margin-bottom: 0.6rem;
}

.cert-name {
  font-size: 1.35rem !important;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 1rem 0 !important;
  min-height: 1.6em;
}

.cert-title {
  font-weight: 600;
  color: var(--primary);
  margin: 0.75rem 0 !important;
}

.cert-date {
  margin-top: 1.25rem !important;
  font-style: italic;
  color: var(--text-light);
}

.cert-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.4;
}

@media print {
  body * {
    visibility: hidden;
  }
  #certificate, #certificate * {
    visibility: visible;
  }
  #certificate {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: 3px solid #0d47a1;
    box-shadow: none;
  }
  .bottom-nav, .header, button, input, label {
    display: none !important;
  }
}

/* Vidéos */
.video-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: 10px;
  margin: 0.75rem 0 0.5rem;
  background: #000;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-caption {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  font-style: italic;
}

/* Branding GIE I2DS */
.splash-logo {
  width: 120px;
  height: auto;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: white;
  padding: 6px;
}

.splash-org {
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.95;
  margin-bottom: 0.25rem;
}

.splash-slogan {
  font-size: 0.9rem;
  opacity: 0.85;
  font-style: italic;
  margin-bottom: 0.75rem;
}

.splash-info {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 1.75rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: white;
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
}

.cert-logo-img {
  width: 90px;
  height: auto;
  margin-bottom: 0.6rem;
  background: white;
  border-radius: 6px;
  padding: 4px;
}

.cert-org {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.2rem;
}

/* ========== Auth / Comptes ========== */
.auth-content {
  max-width: 380px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  text-align: center;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin: 1.25rem 0 1.5rem;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.75);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: white;
  color: var(--primary);
}

.auth-form {
  text-align: left;
}

.form-group {
  margin-bottom: 0.9rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: rgba(255,255,255,0.9);
}

.form-group input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  font-size: 1rem;
  background: rgba(255,255,255,0.95);
  color: #1a1a1a;
}

.form-group input:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
}

.form-error {
  background: #ffebee;
  color: #c62828;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.auth-note {
  font-size: 0.78rem;
  opacity: 0.7;
  margin-top: 1.25rem;
  color: white;
}

/* Auth screen uses splash-like background */
#auth {
  background: linear-gradient(160deg, #1b5e20 0%, #0d3b12 50%, #0d47a1 100%);
  color: white;
  min-height: 100vh;
  overflow-y: auto;
}

#auth .splash-logo {
  margin-top: 1rem;
}

#auth h1 {
  color: white;
  font-size: 1.5rem;
  margin: 0.5rem 0 0.25rem;
}

/* User bar on home */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: rgba(0,0,0,0.06);
  font-size: 0.9rem;
  gap: 0.5rem;
}

#user-display-name {
  font-weight: 600;
  color: var(--primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  border: none;
  background: #ffebee;
  color: #c62828;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: #ffcdd2;
}

.header-brand {
  padding-bottom: 0.25rem;
}

/* Header with user bar */
#home .header {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 0;
}

#home .header-brand {
  padding: 0.85rem 1rem 0.5rem;
}

#home .user-bar {
  border-top: 1px solid rgba(0,0,0,0.06);
  margin: 0;
  border-radius: 0;
}

/* Success message */
.auth-success {
  background: rgba(255,255,255,0.95);
  color: #1a1a1a;
  border-radius: 12px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  margin-bottom: 1rem;
}

.auth-success .success-icon {
  width: 56px;
  height: 56px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 auto 1rem;
}

.auth-success h3 {
  color: #2e7d32;
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.auth-success p {
  font-size: 0.95rem;
  color: #546e7a;
  margin-bottom: 1.25rem;
}

.btn-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255,255,255,0.9);
  font-size: 0.9rem;
  margin-top: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.4rem;
}

.btn-link:hover {
  color: white;
}

.forgot-intro {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
  margin-bottom: 1rem;
  text-align: left;
}

/* Payment card on home */
.pay-card {
  border-left: 4px solid #1c64f2;
  background: #f0f7ff;
}

.pay-card h2 {
  color: #1565c0;
  margin-bottom: 0.4rem;
}

.pay-desc {
  font-size: 0.95rem;
  margin-bottom: 0.9rem;
  color: var(--text);
}

.btn-wave {
  display: block;
  background: #1c64f2;
  color: white !important;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
  margin-bottom: 0.5rem;
}

.btn-wave:hover {
  background: #1557d0;
}

.btn-wa {
  display: block;
  background: #25D366;
  color: white !important;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
}

.btn-wa:hover {
  background: #1da851;
}

.pay-hint {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.75rem;
  line-height: 1.4;
}

.btn-wave.full, .btn-wa.full {
  width: 100%;
}

.admin-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: #e8f5e9;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  flex-shrink: 0;
}
.admin-link:hover { background: #c8e6c9; }

/* Modules payants verrouillés */
.module-locked {
  opacity: 0.85;
  border: 1px dashed #90a4ae;
}
.module-status.locked {
  background: #fff3e0;
  color: #e65100;
  font-size: 0.75rem;
}
.free-badge {
  display: inline-block;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  vertical-align: middle;
}
