:root {
  --c-bg: #f4f4d7;
  --c-light: #e9f0d9;
  --c-mid: #cdecb7;
  --c-accent: #4e9b91;
  --c-dark: #193f3f;
  --text-dark: #1b1b1b;
  --text-light: #f9f9f9;
}

* { 
  box-sizing: border-box;
}

html, body {
   margin: 0; padding: 0; 
}

body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--text-dark);
  line-height: 1.6;
}

img { 
  max-width: 100%; display: block; 
}

a {
   text-decoration: none; color: inherit; 
}

.container { 
  max-width: 1100px; margin: 0 auto; padding: 0 20px; 
}

.nav {
  background: var(--c-dark);
  color: var(--text-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.2rem;
}

.logo { 
  width: 42px; height: 42px; border-radius: 50%; 
}

.menu {
  display: flex;
  gap: 20px;
}

.menu a {
  color: var(--text-light);
  font-weight: 500;
  transition: color .2s, transform .2s;
}

.menu a:hover {
  color: var(--c-accent);
  transform: scale(1.05);
}

.header {
  background: linear-gradient(135deg, var(--c-light), var(--c-mid));
  text-align: center;
  padding: 80px 20px;
  border-bottom: 2px solid var(--c-accent);
}

.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.hero-logo {
  width: 120px;
  height: auto;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.15));
}

.header h1 {
  font-size: 2.2rem;
  margin: 10px 0 0;
  color: var(--c-dark);
}

.header p {
  max-width: 600px;
  color: #2a403e;
}

.cta-btn {
  background: var(--c-accent);
  color: white;
  padding: 12px 26px;
  border-radius: 50px;
  margin-top: 20px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transition: transform 0.2s, background 0.2s;
}

.cta-btn:hover {
  background: #3c7c74;
  transform: translateY(-2px);
}

.main-content {
  padding: 60px 0;
}

.intro {
  text-align: center;
  margin-bottom: 50px;
}

.intro h2 {
  color: var(--c-dark);
  font-size: 1.8rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 25px;
}

.feature-card {
  background: white;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.feature-card h3 {
  color: var(--c-accent);
  margin-top: 0;
}

.footer {
  background: var(--c-dark);
  color: var(--text-light);
  text-align: center;
  padding: 30px 0;
  margin-top: 60px;
  font-size: 0.9rem;
}

.btn-small {
  padding: 8px 14px;
  border: 1px solid var(--c-accent);
  border-radius: 999px;
}

.main-narrow {
  max-width: 720px;
  margin: 40px auto;
}

.card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.form label {
  display: block;
  font-weight: 600;
  margin: 10px 0 6px;
}

.form input,
.form select {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #d9e3dd;
  background: #fff;
}

.form button {
  margin-top: 14px;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin: 10px 0;
}

.alert-error {
  background: #ffe5e5;
  border: 1px solid #ffb3b3;
}

.alert-info {
  background: #e7f2ff;
  border: 1px solid #b9dbff;
}

.muted {
  opacity: 0.7;
}

/* overlay */
.overlay.hidden {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
}

.overlay-panel {
  position: relative;
  z-index: 51;
  width: min(92vw, 820px);
  max-height: 85vh;
  margin: 5vh auto;
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  overflow-y: auto;
}

.close-x {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.overlay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

.overlay-card {
  border: 1px solid #e5efe9;
  border-radius: 14px;
  padding: 20px;
}

.overlay-card h3 {
  margin: 0 0 6px;
  color: var(--c-accent);
}

.card-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--c-accent);
  color: #fff;
}

/* profile */
.profile .profile-card {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: 28px 0;
}

.avatar {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  object-fit: cover;
  border: 3px solid var(--c-mid);
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.file input[type=file] {
  display: none;
}

.file span {
  display: inline-block;
  padding: 10px 14px;
  border: 1px dashed var(--c-accent);
  border-radius: 10px;
  cursor: pointer;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 20px 0 40px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list li {
  padding: 10px 0;
  border-bottom: 1px solid #eef2ee;
}

.welcome-box {
  background-color: rgba(0, 102, 255, 0.1);
  border-left: 4px solid #0066ff;
  padding: 12px 18px;
  margin: 15px 0;
  border-radius: 12px;
  font-weight: 500;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logout-btn {
  background-color: #0066ff;
  color: white;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 500;
}

.logout-btn:hover {
  background-color: #0044aa;
}

/* ===========================
   Workout Coach AI — Pages Auth (login & register)
   — centrées, modernes, mêmes couleurs
=========================== */

.auth-page {
  min-height: 100dvh;
  background: linear-gradient(135deg, var(--c-light), var(--c-mid));
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--text-dark);
}

.auth-card {
  width: min(92vw, 460px);
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 18px 42px rgba(0,0,0,.12);
  border: 1px solid rgba(0,0,0,0.04);
  transition: box-shadow .25s ease, transform .15s ease;
}
.auth-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 46px rgba(0,0,0,.14);
}

.auth-header {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 14px;
  text-align: center;
}
.auth-logo {
  width: 80px; height: 80px;
  border-radius: 999px;
  object-fit: cover;
  border: 3px solid var(--c-mid);
  background: var(--c-light);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.12));
}
.auth-title {
  margin: 8px 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--c-dark);
}
.auth-subtitle {
  margin: 4px 0 0;
  font-size: .98rem;
  color: #2a403e;
  opacity: .9;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}
.auth-field { display: grid; gap: 8px; }
.auth-label {
  font-weight: 600;
  font-size: .95rem;
  color: var(--c-dark);
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #d9e3dd;
  background: #fff;
  color: var(--text-dark);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .1s ease;
}
.auth-input::placeholder { color: #98a5a1; }
.auth-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 4px rgba(78,155,145,.15);
}

/* Boutons */
.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .2px;
  color: #fff;
  background: linear-gradient(135deg, var(--c-accent), #3c7c74);
  box-shadow: 0 10px 22px rgba(0,0,0,.08);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.auth-btn:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 14px 28px rgba(0,0,0,.12);
  filter: brightness(1.02);
}
.auth-btn:active { transform: scale(.99); }

/* Lien secondaire */
.auth-meta {
  margin-top: 10px;
  text-align: center;
  font-size: .95rem;
  color: #2a403e;
}
.auth-link {
  color: var(--c-accent);
  text-decoration: none;
  font-weight: 600;
}
.auth-link:hover { text-decoration: underline; }

/* Alertes */
.auth-alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin: 6px 0 2px;
  font-size: .95rem;
  line-height: 1.4;
}
.auth-alert.error {
  background: #ffe5e5;
  border: 1px solid #ffb3b3;
  color: #9a1c1c;
}
.auth-alert.info {
  background: #e7f2ff;
  border: 1px solid #b9dbff;
  color: #0d3f8a;
}
.auth-alert.success {
  background: #e7fde7;
  border: 1px solid #b7f0be;
  color: #1f6b2a;
}

/* Accessibilité focus visible */
.auth-card :is(.auth-input, .auth-btn):focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 420px) {
  .auth-card { padding: 22px; }
  .auth-title { font-size: 1.2rem; }
  .auth-logo { width: 70px; height: 70px; }
}


/* ===========================
   Profile — Workout Coach AI
   (entête, listes programmes/diètes, responsive)
=========================== */

.profile-wrapper {
  display: grid;
  gap: 24px;
  margin: 32px 0 48px;
}

/* En-tête profil */
.profile-header {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 18px;
}

.profile-header img {
  width: 100px;
  height: 100px;
  border-radius: 999px;
  object-fit: cover;
  border: 3px solid var(--c-mid);
  background: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.profile-header h1 {
  margin: 0 0 6px;
  color: var(--c-dark);
  font-size: 1.5rem;
}

.profile-header p {
  margin: 2px 0;
  color: #2a403e;
}

/* Sections historiques */
.history-section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-section h2 {
  margin: 0;
  color: var(--c-dark);
  font-size: 1.2rem;
}

.history-list {
  display: grid;
  gap: 16px;
}

/* Carte d’élément historique (programme/diète) */
.history-item {
  border: 1px solid #e5efe9;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.04);
  transition: transform .15s ease, box-shadow .2s ease;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}

.history-item > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.history-item strong {
  color: var(--c-accent);
  font-weight: 700;
}

.history-item span {
  color: #2a403e;
  margin-left: 6px;
  font-weight: 500;
}

.history-item small {
  color: #6b7c78;
}

/* Contenu généré (préserve sa mise en forme) */
.history-item pre {
  background: #f8fbf6;
  border: 1px solid #e1ecdf;
  border-radius: 12px;
  padding: 12px;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #243c38;
}

/* État vide */
.empty-state {
  margin: 8px 0 2px;
  background: #f0f7f5;
  border: 1px dashed #b9dbd3;
  color: #335a56;
  border-radius: 12px;
  padding: 12px 14px;
}

/* Responsive */
@media (max-width: 640px) {
  .profile-header {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .profile-header img {
    margin: 0 auto;
  }
  .history-item > header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ===========================
   Dropdown (Programmes & Diètes)
=========================== */

.history-item {
  border: 1px solid #e5efe9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.04);
  transition: transform .15s ease, box-shadow .2s ease;
  overflow: hidden;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  color: var(--c-dark);
  background: linear-gradient(135deg, var(--c-light), var(--c-mid));
  user-select: none;
}

.history-header:hover {
  background: var(--c-mid);
}

.history-toggle {
  transition: transform 0.3s ease;
}
.history-item.open .history-toggle {
  transform: rotate(90deg);
}

.history-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 0;
  padding: 0 18px;
}

.history-item.open .history-content {
  max-height: 800px; /* grande valeur pour autoriser le déploiement */
  opacity: 1;
  padding: 14px 18px 18px;
}

/* pour le texte */
.history-content pre {
  background: #f8fbf6;
  border: 1px solid #e1ecdf;
  border-radius: 12px;
  padding: 12px;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #243c38;
}