@import "tokens.css";

/* =========================================================================
   AP'titudes — app.css
   Mobile-first. Utilise exclusivement les variables de tokens.css.
   Aucune dépendance externe (pas de CDN, pas de police/icône distante).
   ========================================================================= */

/* --- 1. Reset / base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: var(--ap-font);
  color: var(--ap-text);
  background: var(--ap-gray-light);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
img { max-width: 100%; display: block; }
a { color: var(--ap-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; font-weight: 700; line-height: 1.2; }
p { margin: 0 0 .75em; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }
:focus-visible {
  outline: 2px solid var(--ap-blue);
  outline-offset: 2px;
}

.ap-text-muted { color: var(--ap-text-muted); }
.ap-link-muted { color: var(--ap-text-muted); font-size: .875rem; }
.ap-link-muted[aria-disabled="true"] { pointer-events: none; opacity: .6; text-decoration: none; }

.ap-empty { color: var(--ap-text-muted); font-style: italic; padding: .5rem 0; }
.ap-empty--sm { font-size: .8rem; padding: .25rem 0; }

.ap-back-link {
  display: inline-block;
  margin-bottom: var(--ap-space);
  font-size: .9rem;
  color: var(--ap-text-muted);
}

/* --- 2. Layout shell ------------------------------------------------------ */
.ap-shell {
  min-height: 100%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "top"
    "main"
    "bottom";
}
.ap-shell::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 57px 0 0;
  pointer-events: none;
  background: url("/static/img/aptitudes-accueil.png") center / cover no-repeat;
  opacity: .065;
}
.ap-shell > * { position: relative; z-index: 1; }

.ap-topbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--ap-space);
  padding: .625rem var(--ap-space);
  background: var(--ap-white);
  border-bottom: 1px solid var(--ap-border);
}
.ap-topbar__brand { flex-shrink: 0; line-height: 0; }
.ap-topbar__logo { height: 34px; width: auto; }
.ap-topbar__title {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ap-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-topbar__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.ap-topbar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--ap-radius-sm);
  background: var(--ap-gray-light);
  font-size: 1rem;
  text-decoration: none;
}
.ap-topbar__icon-btn:hover { background: var(--ap-blue-soft); text-decoration: none; }

.ap-user-pill {
  display: none;
  align-items: center;
  gap: .5rem;
  padding: .3rem .7rem .3rem .5rem;
  border-radius: 999px;
  background: var(--ap-gray-light);
}
.ap-user-pill__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ap-user-pill__text { display: flex; flex-direction: column; line-height: 1.15; }
.ap-user-pill__name { font-size: .8rem; font-weight: 600; }
.ap-user-pill__role { font-size: .7rem; color: var(--ap-text-muted); }

.ap-main {
  grid-area: main;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding-bottom: calc(var(--ap-nav-h) + var(--ap-space));
}
.ap-container {
  width: 100%;
  max-width: var(--ap-maxw);
  min-width: 0;
  margin: 0 auto;
  padding: var(--ap-space);
  display: flex;
  flex-direction: column;
  gap: var(--ap-space);
}
.ap-container > * {
  min-width: 0;
  max-width: 100%;
}

/* Sidebar (desktop) hidden on mobile */
.ap-sidebar { display: none; }

/* Bottom nav (mobile) */
.ap-bottomnav {
  grid-area: bottom;
  position: fixed;
  left: 0;
  right: auto;
  bottom: 0;
  z-index: 20;
  width: 100vw;
  max-width: 100vw;
  min-width: 0;
  height: var(--ap-nav-h);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  overflow: hidden;
  background: var(--ap-white);
  border-top: 1px solid var(--ap-border);
  box-shadow: var(--ap-shadow-lg);
}
.ap-bottomnav__link {
  min-width: 0;
  max-width: 100%;
  padding: .25rem .08rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  color: var(--ap-text-muted);
  font-size: .65rem;
  text-decoration: none;
}
.ap-bottomnav__icon { font-size: 1.15rem; }
.ap-bottomnav__label {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-bottomnav__link.is-active { color: var(--ap-blue); }
.ap-bottomnav__link.is-active .ap-bottomnav__icon { transform: translateY(-1px); }

/* --- 3. Buttons ------------------------------------------------------------ */
.ap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.1rem;
  border-radius: var(--ap-radius-sm);
  border: 1px solid transparent;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.ap-btn:hover { text-decoration: none; }
.ap-btn--primary { background: var(--ap-blue); color: var(--ap-white); }
.ap-btn--primary:hover { background: var(--ap-blue-dark); }
.ap-btn--secondary { background: var(--ap-white); color: var(--ap-blue); border-color: var(--ap-blue); }
.ap-btn--secondary:hover { background: var(--ap-blue-soft); }
.ap-btn--ghost { background: transparent; color: var(--ap-text); border-color: var(--ap-border); }
.ap-btn--ghost:hover { background: var(--ap-gray-light); }
.ap-btn--danger { background: var(--ap-danger); color: var(--ap-white); }
.ap-btn--danger:hover { opacity: .9; }
.ap-btn--sm { padding: .4rem .75rem; font-size: .8rem; }
.ap-btn--block { display: flex; width: 100%; }
.ap-btn--icon { padding: .4rem; width: 34px; height: 34px; }
.ap-btn--link { padding: 0; border: 0; background: transparent; color: var(--ap-blue); font-size: .78rem; }
.ap-btn--link:hover { text-decoration: underline; background: transparent; }

/* --- 4. Forms --------------------------------------------------------------- */
.ap-form { display: flex; flex-direction: column; gap: var(--ap-space); }
.ap-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--ap-space) var(--ap-space);
}
.ap-field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.ap-field--full { grid-column: 1 / -1; }
.ap-field__label { font-size: .8rem; font-weight: 600; color: var(--ap-text-muted); }

.ap-control {
  width: 100%;
  padding: .6rem .7rem;
  font-size: .9rem;
  font-family: inherit;
  color: var(--ap-text);
  background: var(--ap-white);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
}
.ap-control:focus { border-color: var(--ap-blue); }
select.ap-control { cursor: pointer; }
textarea.ap-control { resize: vertical; min-height: 4.5em; }
.ap-control--sm { padding: .35rem .45rem; font-size: .8rem; }

.ap-checkbox-field { flex-direction: row; align-items: center; }
.ap-checkbox { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .9rem; }
.ap-checkbox input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ap-blue); cursor: pointer; }

.ap-form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .25rem; }

.ap-inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.ap-filterbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
  padding: var(--ap-space);
  background: var(--ap-white);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
}
.ap-filterbar .ap-btn { align-self: end; }

.ap-page-header { display: flex; flex-direction: column; gap: var(--ap-space); }
.ap-topbar-search { display:flex; align-items:center; border:1px solid var(--ap-border); border-radius:999px; overflow:hidden; background:#fff; }
.ap-topbar-search input { border:0; outline:0; padding:.45rem .2rem .45rem .75rem; width:145px; font:inherit; }
.ap-topbar-search button { border:0; background:transparent; cursor:pointer; padding:.45rem .65rem; }
@media (max-width: 760px) { .ap-topbar-search { display:none; } }

/* Add-record panels built with <details> */
.ap-details {
  background: var(--ap-white);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  overflow: hidden;
}
.ap-details__summary {
  list-style: none;
  cursor: pointer;
  padding: .85rem var(--ap-space);
  font-weight: 700;
  color: var(--ap-blue);
  display: flex;
  align-items: center;
}
.ap-details__summary::-webkit-details-marker { display: none; }
.ap-details[open] .ap-details__summary { border-bottom: 1px solid var(--ap-border); }
.ap-details > form { padding: var(--ap-space); }
.ap-details > p { padding: 0 var(--ap-space); margin-top: var(--ap-space); }

.ap-statut-form { margin: 0; }

.ap-month-form { display: flex; align-items: end; gap: .75rem; flex-wrap: wrap; }
.ap-month-form__label { color: var(--ap-text-muted); font-size: .85rem; padding-bottom: .5rem; }

/* --- 5. Cards --------------------------------------------------------------- */
.ap-card {
  background: var(--ap-white);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  padding: var(--ap-space);
}
.ap-card__title { font-size: 1rem; margin-bottom: .75rem; }
.ap-card__title--spaced { margin-top: 1.25rem; }

.ap-two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--ap-space);
  align-items: start;
}

.ap-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.ap-detail-header__main { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ap-detail-header__name { margin: 0; font-size: 1.15rem; }

/* --- 6. Badges ---------------------------------------------------------------- */
.ap-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--ap-gray-light);
  color: var(--ap-text);
  white-space: nowrap;
}
.ap-badge__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.ap-badge--sm { font-size: .68rem; padding: .18rem .5rem; }
.ap-badge--muted { background: var(--ap-gray-light); color: var(--ap-text-muted); }

.ap-badge--seance-prevue { background: var(--ap-blue-soft); color: var(--ap-blue-dark); }
.ap-badge--seance-validee { background: #E4F5EB; color: var(--ap-success); }
.ap-badge--seance-absent { background: #FBE7E6; color: var(--ap-danger); }
.ap-badge--seance-annulee { background: var(--ap-gray-light); color: var(--ap-text-muted); text-decoration: line-through; }
.ap-badge--seance-reportee { background: #FCF1E0; color: var(--ap-warning); }

.ap-badge--fact-ok { background: #E4F5EB; color: var(--ap-success); }
.ap-badge--fact-en_attente { background: #FCF1E0; color: var(--ap-warning); }
.ap-badge--fact-a_relancer { background: #FBE7E6; color: var(--ap-danger); }

.ap-badge--alerte-info { background: var(--ap-blue-soft); color: var(--ap-blue-dark); }
.ap-badge--alerte-warn { background: #FCF1E0; color: var(--ap-warning); }
.ap-badge--alerte-danger { background: #FBE7E6; color: var(--ap-danger); }

/* --- 7. Tables ---------------------------------------------------------------- */
.ap-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--ap-white);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
}
.ap-table { width: 100%; border-collapse: collapse; font-size: .875rem; min-width: 560px; }
.ap-table th, .ap-table td { padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--ap-border); vertical-align: middle; }
.ap-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ap-text-muted); background: var(--ap-gray-light); white-space: nowrap; }
.ap-table tbody tr:last-child td { border-bottom: none; }
.ap-table tbody tr:hover { background: var(--ap-blue-soft); }
.ap-table__link { font-weight: 600; color: var(--ap-text); }
.ap-table__link:hover { color: var(--ap-blue); }
.ap-table tfoot td { border-top: 2px solid var(--ap-border); border-bottom: none; background: var(--ap-gray-light); }
.ap-table__total-label { text-align: right; font-weight: 600; color: var(--ap-text-muted); }
.ap-table-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.ap-table-actions form { margin: 0; }

.ap-access-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.ap-danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-color: #efb0b0;
}
.ap-danger-zone .ap-card__title,
.ap-danger-zone p { margin-top: 0; }
.ap-danger-zone p { margin-bottom: 0; }

/* --- 8. Dashboard --------------------------------------------------------------- */
.ap-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
}
.ap-stats-grid--compact { grid-template-columns: repeat(2, 1fr); }
.ap-stat-card {
  background: var(--ap-white);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.ap-stat-card--accent { background: var(--ap-blue-soft); border-color: var(--ap-blue); }
.ap-stat-card__value { font-size: 1.5rem; font-weight: 700; color: var(--ap-blue); }
.ap-stat-card--accent .ap-stat-card__value { color: var(--ap-blue-dark); }
.ap-stat-card__label { font-size: .8rem; color: var(--ap-text-muted); }

.ap-distribution__bar {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--ap-gray-light);
  margin-bottom: .75rem;
}
.ap-distribution__segment { height: 100%; }
.ap-distribution__legend { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.ap-distribution__legend-item { display: flex; align-items: center; gap: .4rem; font-size: .85rem; }

.ap-quicklinks { display: flex; flex-wrap: wrap; gap: .6rem; }

.ap-alerts { display: flex; flex-direction: column; gap: .5rem; }
.ap-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem var(--ap-space);
  border-radius: var(--ap-radius-sm);
  border-left: 4px solid transparent;
  font-size: .875rem;
}
.ap-alert--info { background: var(--ap-blue-soft); border-left-color: var(--ap-blue); }
.ap-alert--warn { background: #FCF1E0; border-left-color: var(--ap-warning); }
.ap-alert--danger { background: #FBE7E6; border-left-color: var(--ap-danger); }
.ap-alert__link { font-weight: 600; white-space: nowrap; }

.ap-notes { display: flex; flex-direction: column; gap: .4rem; margin-top: .75rem; }
.ap-note-form { margin-bottom: .5rem; }
.ap-note-form .ap-control { flex: 1; }
.ap-note-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .25rem;
  border-bottom: 1px solid var(--ap-border);
}
.ap-note-item:last-child { border-bottom: none; }
.ap-note-item__toggle { flex: 1; min-width: 0; }
.ap-note-item__toggle .ap-checkbox span { overflow-wrap: anywhere; }
.ap-note-item.is-done .ap-checkbox span { color: var(--ap-text-muted); text-decoration: line-through; }
.ap-note-item__delete { flex-shrink: 0; }

.ap-upcoming-list { display: flex; flex-direction: column; gap: .1rem; }
.ap-upcoming-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .1rem;
  border-bottom: 1px solid var(--ap-border);
  font-size: .875rem;
  flex-wrap: wrap;
}
.ap-upcoming-item:last-child { border-bottom: none; }
.ap-upcoming-item__main { display: flex; flex-direction: column; gap: 0; flex: 1; min-width: 0; }
.ap-upcoming-item__when { color: var(--ap-text-muted); font-size: .8rem; white-space: nowrap; }

/* --- 9. Planning / Cours ---------------------------------------------------------- */
.ap-week-nav {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.ap-week-nav__label { font-weight: 700; flex: 1; text-align: center; }

.ap-planning {
  display: flex;
  gap: .75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: .25rem;
  -webkit-overflow-scrolling: touch;
}
.ap-planning__day {
  scroll-snap-align: start;
  flex: 0 0 82%;
  background: var(--ap-white);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ap-planning__day.is-today { border-color: var(--ap-blue); }
.ap-planning__day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: .6rem .85rem;
  background: var(--ap-gray-light);
  font-weight: 700;
}
.ap-planning__day.is-today .ap-planning__day-header { background: var(--ap-blue-soft); color: var(--ap-blue-dark); }
.ap-planning__day-date { font-size: .78rem; font-weight: 600; color: var(--ap-text-muted); }
.ap-planning__day.is-today .ap-planning__day-date { color: var(--ap-blue-dark); }
.ap-planning__day-body { padding: .6rem; display: flex; flex-direction: column; gap: .5rem; min-height: 60px; }

.ap-seance-card {
  border-left: 4px solid var(--ap-blue);
  background: var(--ap-gray-light);
  border-radius: var(--ap-radius-sm);
  padding: .55rem .65rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .82rem;
}
.ap-seance-card__row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ap-seance-card__time { font-weight: 700; }
.ap-seance-card__eleve { font-weight: 600; color: var(--ap-text); }
.ap-seance-card__eleve:hover { color: var(--ap-blue); }
.ap-seance-card__prof { color: var(--ap-text-muted); font-size: .78rem; }
.ap-seance-card .ap-statut-form { margin-top: .2rem; }
.ap-seance-card .ap-control--sm { width: 100%; }

/* --- 10. Facturation -------------------------------------------------------------- */
.ap-tabs {
  display: flex;
  gap: .4rem;
  border-bottom: 1px solid var(--ap-border);
  overflow-x: auto;
}
.ap-tabs__link {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem .9rem;
  font-weight: 600;
  color: var(--ap-text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.ap-tabs__link:hover { text-decoration: none; color: var(--ap-text); }
.ap-tabs__link.is-active { color: var(--ap-blue); border-bottom-color: var(--ap-blue); }

/* --- 11. Paramètres --------------------------------------------------------------- */
.ap-chip-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.ap-chip {
  padding: .35rem .75rem;
  background: var(--ap-gray-light);
  border-radius: 999px;
  font-size: .82rem;
  border: 1px solid var(--ap-border);
}
.ap-settings-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* --- 12. Login --------------------------------------------------------------------- */
.ap-login-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ap-space);
  background: linear-gradient(180deg, var(--ap-blue-soft) 0%, var(--ap-gray-light) 45%);
  font-family: var(--ap-font);
  color: var(--ap-text);
  position: relative;
  isolation: isolate;
}
.ap-login-page::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: url("/static/img/aptitudes-accueil.png") center / cover no-repeat;
  opacity: .14;
}
.ap-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--ap-white);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow-lg);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .25rem;
  position: relative;
  z-index: 1;
}
.ap-login-card__logo { height: 52px; width: auto; margin-bottom: .5rem; }
.ap-login-card__baseline { color: var(--ap-text-muted); font-size: .85rem; font-style: italic; margin-bottom: .75rem; }
.ap-login-card__title { font-size: 1.05rem; margin-bottom: 1.1rem; }
.ap-login-card .ap-form { width: 100%; text-align: left; }
.ap-login-card__forgot { align-self: center; margin-top: -.25rem; }

.ap-login-demo {
  width: 100%;
  margin-top: 1.25rem;
  padding: .85rem 1rem;
  background: var(--ap-blue-soft);
  border-radius: var(--ap-radius-sm);
  text-align: left;
  font-size: .82rem;
}
.ap-login-demo__title { font-weight: 700; margin-bottom: .35rem; color: var(--ap-blue-dark); }
.ap-login-demo p { margin: 0 0 .2rem; }
.ap-login-demo code {
  background: var(--ap-white);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .8rem;
}

.ap-login-footer {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  align-items: center;
  font-size: .8rem;
  color: var(--ap-text-muted);
}
.ap-login-footer a { color: var(--ap-text-muted); }
.ap-login-footer__sep { opacity: .6; }
.ap-login-footer .ap-creator-signature {
  flex: 0 0 100%;
  margin-top: .4rem;
  text-align: center;
}

/* --- 13. Alertes génériques (réutilisées par login.html) --------------------------- */
.ap-alert--danger { color: var(--ap-danger); }

/* --- 14. Portails parent / élève / professeur et calendrier ------------ */
.ap-portal-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 150px;
  padding: 1.4rem;
  border-radius: calc(var(--ap-radius) + 2px);
  color: var(--ap-white);
  background: linear-gradient(135deg, var(--ap-blue-dark), var(--ap-blue));
  box-shadow: var(--ap-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ap-portal-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 240px;
  height: 240px;
  right: -80px;
  top: -110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
}
.ap-portal-hero--parent { background: linear-gradient(135deg, #4c2882, #7E57C2); }
.ap-portal-hero--eleve { background: linear-gradient(135deg, #00664a, #2E9E5B); }
.ap-portal-hero--calendar { background: linear-gradient(135deg, #073d78, #0071CE); }
.ap-portal-hero h2 { margin: .2rem 0 .35rem; font-size: clamp(1.45rem, 4vw, 2rem); }
.ap-portal-hero p { margin: 0; color: rgba(255, 255, 255, .88); }
.ap-portal-hero__eyebrow { font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .8); }
.ap-portal-hero__icon { font-size: 3.1rem; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .18)); }
.ap-btn--light { color: var(--ap-blue-dark); background: var(--ap-white); flex-shrink: 0; }
.ap-btn--light:hover { background: var(--ap-blue-soft); }

.ap-alert--warning,
.ap-alert--success { padding: .8rem 1rem; border-radius: var(--ap-radius-sm); border-left: 4px solid; }
.ap-alert--warning { color: #714b09; background: #fff5df; border-left-color: var(--ap-warning); }
.ap-alert--success { color: #176a3a; background: #e8f7ef; border-left-color: var(--ap-success); }
.ap-calendar-alert { margin: 0; }

.ap-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.ap-card-heading .ap-card__title { margin: 0; }
.ap-card-heading > a { font-size: .82rem; font-weight: 700; white-space: nowrap; }
.ap-card--attention { border-color: var(--ap-warning); }
.ap-page-title { margin: 0 0 .35rem; }
.ap-history-table td:first-child { white-space: nowrap; }
.ap-history-table td:last-child { min-width: 18rem; }
.ap-action-grid { display: grid; grid-template-columns: 1fr; gap: var(--ap-space); }

.ap-profile-list { display: flex; flex-direction: column; gap: .6rem; }
.ap-profile-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .7rem;
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
  color: var(--ap-text);
}
.ap-profile-card:hover { background: var(--ap-gray-light); text-decoration: none; }
.ap-profile-card small,
.ap-event-list small,
.ap-resource-mini-list small { display: block; margin-top: .12rem; color: var(--ap-text-muted); font-size: .78rem; }
.ap-profile-card__avatar {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--ap-blue-dark);
  background: var(--ap-blue-soft);
  font-weight: 800;
  font-size: .82rem;
}
.ap-profile-card__avatar--large { width: 58px; height: 58px; font-size: 1rem; }
.ap-student-identity { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.ap-student-identity p { margin: .2rem 0 0; color: var(--ap-text-muted); }

.ap-event-list { display: flex; flex-direction: column; gap: .75rem; }
.ap-event-list li { display: grid; grid-template-columns: auto 1fr; gap: .65rem; align-items: start; }
.ap-event-dot { width: 10px; height: 10px; margin-top: .32rem; border-radius: 50%; background: var(--ap-blue); }
.ap-event-dot--vacances { background: #13267a; }
.ap-event-dot--stage { background: var(--ap-success); }
.ap-event-dot--programme { background: #7E57C2; }
.ap-event-dot--atelier { background: var(--ap-danger); }
.ap-event-grid { display: grid; grid-template-columns: 1fr; gap: .75rem; }
.ap-event-card { padding: 1rem; border: 1px solid var(--ap-border); border-top: 4px solid var(--ap-blue); border-radius: var(--ap-radius-sm); background: var(--ap-white); }
.ap-event-card--vacances { border-top-color: #13267a; }
.ap-event-card--stage { border-top-color: var(--ap-success); }
.ap-event-card--programme { border-top-color: #7E57C2; }
.ap-event-card--atelier { border-top-color: var(--ap-danger); }
.ap-event-card--project { border-top-color: var(--ap-warning); border-style: dashed; }
.ap-event-card h3 { margin: .25rem 0; font-size: .95rem; }
.ap-event-card p { margin: .25rem 0 0; font-size: .82rem; color: var(--ap-text-muted); }
.ap-event-card__category { font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ap-text-muted); }
.ap-event-card__date { font-weight: 700; color: var(--ap-text) !important; }
.ap-holiday-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.ap-holiday-list span { padding: .65rem; border-radius: var(--ap-radius-sm); background: #fff5df; font-size: .8rem; }
.ap-holiday-list strong { display: block; color: #714b09; }
.ap-resource-mini-list { display: flex; flex-direction: column; gap: .7rem; }
.ap-resource-mini-list li { display: grid; grid-template-columns: auto 1fr auto; gap: .65rem; align-items: center; }
.ap-resource-mini-list a { font-size: .8rem; font-weight: 700; }
.ap-coming-soon { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.ap-coming-soon > div { display: flex; align-items: center; gap: .9rem; }
.ap-coming-soon__icon { font-size: 2rem; }
.ap-coming-soon p { margin: 0; color: var(--ap-text-muted); font-size: .85rem; }

/* =========================================================================
   14. Desktop (>= 900px) : sidebar visible, bottom nav masquée
   ========================================================================= */
@media (min-width: 900px) {
  .ap-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "top  top"
      "side main";
  }
  .ap-topbar { grid-column: 1 / -1; }
  .ap-user-pill { display: flex; }

  .ap-sidebar {
    grid-area: side;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: var(--ap-space) .75rem;
    background: var(--ap-white);
    border-right: 1px solid var(--ap-border);
    position: sticky;
    top: calc(var(--ap-nav-h) * 0 + 57px);
    align-self: start;
    height: calc(100vh - 57px);
  }
  .ap-sidebar__nav { display: flex; flex-direction: column; gap: .15rem; }
  .ap-sidebar__nav--secondary { margin-top: auto; border-top: 1px solid var(--ap-border); padding-top: .5rem; }
  .ap-sidebar__link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    border-radius: var(--ap-radius-sm);
    color: var(--ap-text);
    font-weight: 600;
    font-size: .9rem;
  }
  .ap-sidebar__link:hover { background: var(--ap-gray-light); text-decoration: none; }
  .ap-sidebar__link.is-active { background: var(--ap-blue-soft); color: var(--ap-blue-dark); }
  .ap-sidebar__icon { font-size: 1.1rem; width: 1.4em; text-align: center; }
  .ap-sidebar__baseline { font-size: .72rem; color: var(--ap-text-muted); font-style: italic; padding: .5rem .75rem 0; }

  .ap-main { padding-bottom: var(--ap-space); }
  .ap-bottomnav { display: none; }

  .ap-container { padding: 1.5rem 2rem; }

  .ap-form-grid { grid-template-columns: repeat(2, 1fr); }
  .ap-filterbar { grid-template-columns: repeat(5, 1fr) auto; align-items: end; }
  .ap-stats-grid { grid-template-columns: repeat(4, 1fr); }
  .ap-stats-grid--compact { grid-template-columns: repeat(4, 1fr); }
  .ap-two-col { grid-template-columns: 1.1fr .9fr; }

  .ap-planning { display: grid; grid-template-columns: repeat(7, 1fr); overflow: visible; }
  .ap-planning__day { flex: initial; }

  .ap-action-grid { grid-template-columns: repeat(2, 1fr); align-items: start; }
  .ap-event-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
  .ap-stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- Import Excel --------------------------------------------------------- */
.ap-info-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  color: var(--ap-text);
  font-size: .9rem;
}
.ap-info-list li { line-height: 1.45; }
input[type="file"] {
  font: inherit;
  padding: .6rem;
  border: 1px dashed var(--ap-border);
  border-radius: var(--ap-radius-sm);
  background: var(--ap-gray-light);
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
}
input[type="file"]:hover { border-color: var(--ap-blue); }

/* Sélecteur de fichier « custom » en français (masque le bouton natif anglais) */
.ap-file { display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap; cursor: pointer; }
.ap-file input[type="file"] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
.ap-file__btn {
  display: inline-block; padding: .55rem .9rem; border: 1px solid var(--ap-blue);
  border-radius: var(--ap-radius-sm); background: var(--ap-blue-soft);
  color: var(--ap-blue-dark); font-weight: 600; white-space: nowrap;
}
.ap-file:hover .ap-file__btn { background: var(--ap-blue); color: #fff; }
.ap-file__name { color: var(--ap-text-muted); font-size: .85rem; }

/* --- Gestion des utilisateurs (multi-admin) ------------------------------ */
.ap-user-list { list-style: none; margin: 0; padding: 0; }
.ap-user-item { padding: .7rem 0; border-bottom: 1px solid var(--ap-border); }
.ap-user-item:last-child { border-bottom: 0; }
.ap-user-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ap-user-row__name { margin-right: auto; }
.ap-details--sub { margin-top: .5rem; }
.ap-details--sub .ap-details__summary { font-size: .85rem; color: var(--ap-blue); }

/* --- Signature éditeur JCréation ---------------------------------------- */
.ap-creator-signature {
  margin: .65rem 0 0;
  color: var(--ap-text-muted);
  font-size: .68rem;
  line-height: 1.35;
}
.ap-creator-signature small { font-size: .62rem; }
.ap-app-signature {
  margin: 1.4rem 0 calc(var(--ap-nav-h) + .5rem);
  padding-top: .8rem;
  border-top: 1px solid rgba(120, 135, 150, .22);
  color: var(--ap-text-muted);
  font-size: .68rem;
  text-align: center;
}

@media (min-width: 900px) {
  .ap-sidebar__identity { padding-top: .25rem; }
  .ap-sidebar__identity .ap-creator-signature { display: block; padding: 0 .75rem .25rem; }
  .ap-app-signature { margin-bottom: 0; }
}
