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

body {
  font-family: sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #222;
  background: #f5f5f5;
}

nav {
  background: #2a7ae2;
  color: white;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
nav a { color: white; text-decoration: none; }
nav a:hover { text-decoration: underline; }
.nav-titre { font-weight: bold; margin-right: auto; }

main { padding: 2rem 1.5rem; max-width: 960px; margin: 0 auto; }

.form-center { max-width: 420px; margin: 3rem auto; }

h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }

form { display: flex; flex-direction: column; gap: 1rem; }

label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .9rem;
  font-weight: 500;
}

input, select, textarea {
  padding: .5rem .75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  width: 100%;
}
input:focus, select:focus {
  outline: 2px solid #2a7ae2;
  border-color: #2a7ae2;
}

button {
  padding: .6rem 1.2rem;
  border: none;
  border-radius: 6px;
  background: #2a7ae2;
  color: white;
  font-size: 1rem;
  cursor: pointer;
}
button:hover { background: #1a5bbf; }
button.danger { background: #c0392b; }
button.danger:hover { background: #922b21; }

.erreur {
  background: #fde8e8;
  color: #922b21;
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.succes {
  background: #e8f5e9;
  color: #1b5e20;
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

hr { border: none; border-top: 1px solid #ddd; margin: 1.5rem 0; }
details summary { cursor: pointer; color: #c0392b; margin-bottom: .5rem; }
p { margin-top: .75rem; }
a { color: #2a7ae2; }

.dashboard {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}
.dashboard-card {
  background: #f0f4fa;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.dashboard-card h2 {
  font-size: 1rem;
  font-weight: 500;
  color: #1a5bbf;
  margin-bottom: .25rem;
}
.dashboard-card a {
  font-size: .95rem;
  color: #333;
  text-decoration: none;
  padding: .25rem 0;
}
.dashboard-card a:hover { color: #2a7ae2; text-decoration: underline; }

/* Layout admin */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 48px);
}
.admin-menu {
  width: 180px;
  min-width: 180px;
  background: #f0f4fa;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border-right: 1px solid #ddd;
}
.admin-menu a {
  padding: .4rem .75rem;
  border-radius: 6px;
  color: #333;
  text-decoration: none;
  font-size: .95rem;
}
.admin-menu a:hover { background: #dce6f7; }

.admin-content { padding: 2rem; flex: 1; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: .6rem .75rem; border: 1px solid #ddd; text-align: left; }
th { background: #f0f4fa; font-weight: 500; }
tr:hover td { background: #fafafa; }
tr.desactive td { color: #aaa; font-style: italic; }

/* Code couleur statuts (même palette que le calendrier) */
tr.rdv-confirme td { background: #d4edda; color: #1b5e20; }
tr.rdv-confirme:hover td { background: #c3e6cb; }
tr.rdv-annule td   { background: #f0f0f0; color: #777; text-decoration: line-through; }
tr.rdv-annule td:last-child { text-decoration: none; }
tr.rdv-annule:hover td { background: #e4e4e4; }
tr.rdv-archive td  { background: #e9e9e9; color: #999; }
tr.rdv-archive:hover td { background: #dedede; }
tr.rdv-demande td  { background: #fff3cd; color: #7d4e00; }
tr.rdv-demande:hover td { background: #ffe8a0; }
td form {
  display: inline;
}

/* Bouton toggle aptitudes/utilisations */
button.toggle { background: #eee; color: #666; min-width: 2rem; }
button.toggle.actif { background: #2a7ae2; color: white; }

.info {
  background: #e8f0fe;
  color: #1a5bbf;
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

fieldset {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: .75rem 1rem;
}
fieldset legend {
  font-size: .9rem;
  font-weight: 500;
  padding: 0 .4rem;
}
fieldset label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .4rem;
  font-weight: 400;
  margin-bottom: .2rem;
}
fieldset input[type="checkbox"] {
  width: auto;    /* empêche le input de prendre toute la largeur */
  margin: 0;
}

/* Responsive mobile */
@media (max-width: 600px) {
  /* Navigation */
  nav { flex-wrap: wrap; gap: .4rem 1rem; padding: .6rem 1rem; }
  .nav-titre { width: 100%; margin-right: 0; }

  /* Layout admin */
  .admin-layout { flex-direction: column; }
  .admin-menu { width: 100%; flex-direction: row; flex-wrap: wrap; border-right: none;
                border-bottom: 1px solid #ddd; }
}

/* Table avec défilement horizontal (pages formateur/admin) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Table responsive en cartes (pages élève) */
@media (max-width: 640px) {
  table.responsive { border: none; }
  table.responsive thead { display: none; }
  table.responsive tbody tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
  }
  table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .5rem;
    border: none;
    border-bottom: 1px solid #eee;
    padding: .5rem .75rem;
    text-align: right;
  }
  table.responsive td:last-child { border-bottom: none; }
  table.responsive td::before {
    content: attr(data-label);
    font-weight: 500;
    color: #555;
    text-align: left;
    flex-shrink: 0;
  }
  table.responsive tr:hover td { background: inherit; }
}

.btn-lien {
  display: inline-block;
  padding: .4rem .8rem;
  background: #2a7ae2;
  color: white;
  border-radius: 6px;
  text-decoration: none;
  font-size: .9rem;
}
.btn-lien:hover { background: #1a5bbf; color: white; }

.btn-lien.danger {
  background: #c0392b;
}
.btn-lien.danger:hover {
  background: #922b21;
}

/* Calendrier semaine */
.main-large { max-width: 1200px; }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.cal-nav h1 { margin-bottom: 0; font-size: 1.2rem; text-align: center; }

.semaine {
  display: flex;
  gap: 4px;
  align-items: stretch;
}

.jour-col {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.jour-col.aujourd-hui { border-color: #2a7ae2; }

.jour-entete {
  background: #f0f4fa;
  padding: .35rem .5rem;
  text-align: center;
  border-bottom: 1px solid #ddd;
}
.jour-col.aujourd-hui .jour-entete { background: #dce6f7; }
.jour-nom  { display: block; font-weight: 600; font-size: .8rem; color: #1a5bbf; }
.jour-date { display: block; font-size: .8rem; color: #555; }

.jour-corps {
  padding: .4rem .3rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 1;
}

.cal-vide { font-size: .8rem; color: #bbb; text-align: center; margin-top: .5rem; }

.cal-evt {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  padding: .25rem .4rem;
  border-radius: 4px;
  font-size: .75rem;
  text-decoration: none;
  cursor: default;
}
.cal-evt.cal-demande { cursor: pointer; }

.cal-evt-heure  { font-weight: 600; }
.cal-evt-titre  { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-evt-detail { color: inherit; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-evt-statut { font-size: .7rem; opacity: .8; font-style: italic; }

.cal-rdv.confirme { background: #d4edda; color: #1b5e20; }
.cal-rdv.annule   { background: #f0f0f0; color: #777; text-decoration: line-through; }
.cal-rdv.annule .cal-evt-detail,
.cal-rdv.annule .cal-evt-statut { text-decoration: none; }
.cal-rdv.archive  { background: #e9e9e9; color: #999; }
.cal-demande                { background: #fff3cd; color: #7d4e00; border: 1px solid #ffe08a; }
.cal-demande:hover          { background: #ffe8a0; }
.cal-demande-inactive       { opacity: .55; cursor: default; }
.cal-demande-inactive:hover { background: #fff3cd; }

.cal-legende {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}
.cal-legende .cal-evt { cursor: default; }
.cal-legende .cal-demande:hover { background: #fff3cd; }

/* Calendrier — vue liste mobile */
.cal-liste { display: none; }

@media (max-width: 640px) {
  .semaine { display: none; }
  .cal-liste { display: block; }

  .cal-liste-jour { margin-bottom: 1.5rem; }

  .cal-liste-entete {
    font-weight: 600;
    font-size: 1rem;
    color: #1a5bbf;
    background: #f0f4fa;
    border-radius: 6px;
    padding: .4rem .75rem;
    margin-bottom: .5rem;
  }

  .cal-liste .cal-evt {
    font-size: .95rem;
    margin-bottom: .35rem;
    padding: .4rem .75rem;
  }
}
