/* EduGest — design system partagé (admin, espace famille, plateforme, site) */
:root {
  --c-primary: #4f46e5;
  --c-primary-2: #7c3aed;
  --c-accent: #06b6d4;
  --c-success: #10b981;
  --c-warning: #f59e0b;
  --c-danger: #ef4444;
  --c-ink: #0f172a;
  --c-text: #334155;
  --c-muted: #64748b;
  --c-line: #e2e8f0;
  --c-bg: #f5f7fb;
  --c-surface: #ffffff;
  --c-side: #0b1023;
  --c-side-2: #141a35;
  --grad: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .05);
  --shadow-lg: 0 30px 60px -20px rgba(79, 70, 229, .35);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: #4338ca;
  --bs-link-hover-color-rgb: 67, 56, 202;
}
a { text-underline-offset: 3px; }
.theme-famille { --c-primary: #059669; --c-primary-2: #0d9488; --bs-primary: #059669; --bs-primary-rgb: 5, 150, 105; --bs-link-color: #059669; --bs-link-color-rgb: 5, 150, 105; --bs-link-hover-color-rgb: 4, 120, 87; --shadow-lg: 0 30px 60px -20px rgba(5, 150, 105, .35); }
.theme-plateforme { --c-primary: #0f172a; --c-primary-2: #4f46e5; }

body { font-family: var(--bs-body-font-family); background: var(--c-bg); color: var(--c-text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { color: var(--c-ink); font-weight: 700; letter-spacing: -.02em; }
::selection { background: rgba(79, 70, 229, .18); }

/* ---------- Coque applicative ---------- */
.app-shell { display: grid; grid-template-columns: 268px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 14px;
  background: radial-gradient(120% 60% at 0% 0%, #1e1b4b 0%, transparent 60%), linear-gradient(180deg, var(--c-side), var(--c-side-2));
  color: #c7d2fe; display: flex; flex-direction: column; gap: 18px; z-index: 1040;
}
.theme-famille .sidebar { background: radial-gradient(120% 60% at 0% 0%, #064e3b 0%, transparent 60%), linear-gradient(180deg, #03140f, #0b2a22); color: #a7f3d0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem;
  background: var(--grad); box-shadow: 0 8px 24px -6px rgba(124, 58, 237, .7); animation: logo-float 6s var(--ease) infinite;
}
.brand-name { font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; line-height: 1.1; }
.brand-sub { font-size: .75rem; color: rgba(255, 255, 255, .55); font-weight: 500; }
.side-school { margin: 0 6px; padding: 12px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); }
.side-school strong { color: #fff; display: block; font-size: .9rem; }
.side-school small { color: rgba(255, 255, 255, .55); }
.side-nav { display: flex; flex-direction: column; gap: 2px; position: relative; }
.side-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(255, 255, 255, .35); padding: 10px 14px 4px; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  color: rgba(255, 255, 255, .72); text-decoration: none; font-weight: 500; font-size: .92rem;
  transition: color .25s var(--ease), background .25s var(--ease), transform .25s var(--ease);
}
.side-link i { font-size: 1.05rem; width: 20px; text-align: center; transition: transform .35s var(--ease-spring); }
.side-link:hover { color: #fff; background: rgba(255, 255, 255, .06); transform: translateX(3px); }
.side-link:hover i { transform: scale(1.18) rotate(-6deg); }
.side-link.active { color: #fff; background: linear-gradient(90deg, rgba(124, 58, 237, .45), rgba(79, 70, 229, .15)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.theme-famille .side-link.active { background: linear-gradient(90deg, rgba(16, 185, 129, .45), rgba(13, 148, 136, .12)); }
.side-link.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: #a5b4fc; animation: grow-y .5s var(--ease); }
.theme-famille .side-link.active::before { background: #6ee7b7; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .05); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--grad); flex-shrink: 0; }
.side-user .who { line-height: 1.2; min-width: 0; }
.side-user .who strong { color: #fff; font-size: .88rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who small { color: rgba(255, 255, 255, .5); }
.side-user a { margin-left: auto; color: rgba(255, 255, 255, .6); font-size: 1.1rem; transition: color .2s, transform .3s var(--ease-spring); }
.side-user a:hover { color: #fca5a5; transform: translateX(3px); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 14px; padding: 14px 32px;
  background: rgba(245, 247, 251, .78); backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid rgba(226, 232, 240, .7);
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar .crumb { font-size: .78rem; color: var(--c-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; border: 0; background: var(--c-surface); width: 40px; height: 40px; border-radius: 10px; box-shadow: var(--shadow-sm); font-size: 1.2rem; }
.content { padding: 28px 32px 48px; flex: 1; }
.content > h3, .content > p + h3 { font-size: clamp(1.35rem, 2.2vw, 1.75rem); font-weight: 800; margin-bottom: 1.25rem; }
.content > h3 small { font-size: .55em; font-weight: 500; }

/* Pastilles d'état d'abonnement */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill-essai { background: #fef3c7; color: #92400e; }
.pill-actif { background: #d1fae5; color: #065f46; }
.pill-expire, .pill-suspendu { background: #fee2e2; color: #991b1b; }
.pill-neutre { background: #eef2ff; color: #3730a3; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse-dot 2s infinite; }

/* Bandeau d'essai */
.trial-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 22px; border-radius: var(--radius);
  background: linear-gradient(110deg, #312e81, #6d28d9 55%, #0891b2); background-size: 200% 100%; color: #fff; animation: gradient-pan 10s ease infinite;
  box-shadow: var(--shadow-lg);
}
.trial-banner .btn { margin-left: auto; }

/* ---------- Composants Bootstrap restylés ---------- */
.card { border: 1px solid rgba(226, 232, 240, .8); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--c-surface); transition: transform .35s var(--ease), box-shadow .35s var(--ease); }
.card:hover { box-shadow: var(--shadow); }
.card-stat { position: relative; overflow: hidden; }
.card-stat:hover { transform: translateY(-4px); }
.card-stat::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--grad); opacity: .08; transition: transform .6s var(--ease); }
.card-stat:hover::after { transform: scale(1.5); }
.card-stat .display-6 { font-weight: 800; color: var(--c-ink); font-size: 2rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; color: #fff; background: var(--grad); margin-bottom: 12px; box-shadow: 0 10px 20px -8px rgba(79, 70, 229, .6); }

.btn { border-radius: var(--radius-sm); font-weight: 600; padding: .55rem 1rem; position: relative; overflow: hidden; transition: transform .2s var(--ease), box-shadow .3s var(--ease), background .3s, color .3s, border-color .3s; }
.btn:active { transform: scale(.97); }
.btn-sm { padding: .35rem .7rem; border-radius: 8px; }
.btn-primary, .btn-success { border: 0; background: var(--grad); box-shadow: 0 8px 18px -8px rgba(var(--bs-primary-rgb), .75); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 8px 18px -8px rgba(16, 185, 129, .7); }
.btn-primary:hover, .btn-success:hover { transform: translateY(-1px); box-shadow: 0 14px 26px -10px rgba(var(--bs-primary-rgb), .8); filter: brightness(1.05); }
.btn-outline-primary { --bs-btn-color: var(--c-primary); --bs-btn-border-color: rgba(var(--bs-primary-rgb), .35); --bs-btn-hover-bg: var(--c-primary); --bs-btn-hover-border-color: var(--c-primary); }
.btn-light { background: #fff; border: 1px solid var(--c-line); }
.btn .ripple { position: absolute; border-radius: 50%; transform: scale(0); background: rgba(255, 255, 255, .5); animation: ripple .6s linear; pointer-events: none; }
.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading::after { content: ''; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-outline-primary.is-loading::after, .btn-outline-secondary.is-loading::after, .btn-outline-danger.is-loading::after, .btn-light.is-loading::after { border-color: rgba(79, 70, 229, .25); border-top-color: var(--c-primary); }

.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--c-line); padding: .6rem .85rem; transition: border-color .2s, box-shadow .25s var(--ease), background .2s; }
.form-control-sm, .form-select-sm { padding: .35rem .6rem; border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), .12); }
.form-label { font-weight: 600; font-size: .85rem; color: var(--c-ink); }
.form-check-input:checked { background-color: var(--c-primary); border-color: var(--c-primary); }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.content > .table, .content > .table-responsive, .content > form > .table, .table-card {
  background: var(--c-surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid rgba(226, 232, 240, .8); overflow: hidden;
}
.content > .table, .content > form > .table { display: table; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); font-weight: 700; background: #f8fafc; border-bottom: 1px solid var(--c-line); padding: .85rem .9rem; }
.table > tbody td { padding: .8rem .9rem; border-color: #f1f5f9; vertical-align: middle; }
.table-hover > tbody > tr { transition: background .2s; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(var(--bs-primary-rgb), .04); }
.badge { font-weight: 600; padding: .4em .7em; border-radius: 999px; }
.badge.bg-success { background: #d1fae5 !important; color: #065f46; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569; }
.badge.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.alert { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info { background: #eff6ff; color: #1e40af; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger { background: #fef2f2; color: #991b1b; }
.list-group-item { border-color: #f1f5f9; }
details > summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '\F4FE'; font-family: 'bootstrap-icons'; transition: transform .3s var(--ease-spring); }
details[open] > summary::before { transform: rotate(45deg); }
details[open] > form { animation: fade-up .45s var(--ease) both; }
form.row.g-2 { background: var(--c-surface); padding: 16px 12px 16px 4px; margin-left: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid rgba(226, 232, 240, .8); }
form.row.g-2.mb-3:not(:has(button)) { background: transparent; box-shadow: none; border: 0; padding: 0; }

/* ---------- Toasts ---------- */
.toast-zone { position: fixed; top: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.app-toast {
  display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 420px; padding: 14px 16px; border-radius: 14px; background: #fff;
  box-shadow: 0 20px 40px -12px rgba(15, 23, 42, .3); border-left: 4px solid var(--c-success); color: var(--c-ink); font-weight: 500;
  animation: toast-in .55s var(--ease-spring) both; position: relative; overflow: hidden;
}
.app-toast::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .25; transform-origin: left; animation: toast-timer 5s linear forwards; }
.app-toast i { font-size: 1.3rem; color: var(--c-success); }
.app-toast-danger { border-left-color: var(--c-danger); } .app-toast-danger i { color: var(--c-danger); }
.app-toast-warning { border-left-color: var(--c-warning); } .app-toast-warning i { color: var(--c-warning); }
.app-toast-info { border-left-color: var(--c-accent); } .app-toast-info i { color: var(--c-accent); }
.app-toast.leaving { animation: toast-out .4s var(--ease) forwards; }
.app-toast-close { margin-left: auto; border: 0; background: none; font-size: 1.3rem; color: var(--c-muted); line-height: 1; }

/* ---------- Animations d'entrée ---------- */
.reveal { opacity: 0; transform: translateY(16px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .7s var(--ease), transform .7s var(--ease); transition-delay: calc(var(--i, 0) * 60ms); }
.stagger-rows tbody tr { animation: fade-up .5s var(--ease) both; animation-delay: calc(var(--r, 0) * 35ms); }

@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px) scale(.95); } }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 currentColor; } 50% { box-shadow: 0 0 0 4px transparent; } }
@keyframes gradient-pan { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes logo-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3px) rotate(-4deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes blob { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(40px, -30px) scale(1.1); } 66% { transform: translate(-30px, 20px) scale(.92); } }
@keyframes shine { from { transform: translateX(-120%) skewX(-20deg); } to { transform: translateX(220%) skewX(-20deg); } }
@keyframes word-in { from { opacity: 0; transform: translateY(.6em) rotate(4deg); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes border-spin { to { --angle: 360deg; } }
@keyframes check-pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Pages d'authentification ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--c-bg); }
.auth-visual { position: relative; overflow: hidden; padding: 48px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(80% 60% at 20% 10%, #6d28d9 0%, transparent 60%), radial-gradient(70% 60% at 90% 90%, #0891b2 0%, transparent 60%), #0b1023; }
.theme-famille .auth-visual { background: radial-gradient(80% 60% at 20% 10%, #059669 0%, transparent 60%), radial-gradient(70% 60% at 90% 90%, #0d9488 0%, transparent 60%), #03140f; }
.auth-visual h2 { color: #fff; font-size: clamp(1.8rem, 3vw, 2.6rem); font-weight: 800; max-width: 520px; }
.auth-visual p { color: rgba(255, 255, 255, .7); max-width: 460px; }
.auth-visual .orb { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .55; animation: blob 14s ease-in-out infinite; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 420px; animation: fade-up .8s var(--ease) both; }
.auth-card h1 { font-size: 1.7rem; font-weight: 800; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--c-muted); transition: color .2s; }
.input-icon .form-control { padding-left: 42px; }
.input-icon:focus-within i { color: var(--c-primary); }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; width: 36px; height: 36px; border-radius: 8px; color: var(--c-muted); display: grid; place-items: center; transition: color .2s, background .2s; }
.pw-toggle:hover { color: var(--c-primary); background: rgba(var(--bs-primary-rgb), .08); }
.input-icon .pw-toggle i { position: static; transform: none; }
.floating-card { position: relative; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); backdrop-filter: blur(10px); border-radius: 18px; padding: 18px; animation: float 7s ease-in-out infinite; max-width: 360px; }

/* ---------- Paiement simulé ---------- */
.checkout { max-width: 920px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; }
.op-choice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.op-choice label { cursor: pointer; border: 2px solid var(--c-line); border-radius: 12px; padding: 12px 6px; text-align: center; font-weight: 700; font-size: .8rem; transition: all .25s var(--ease); }
.op-choice input { display: none; }
.op-choice input:checked + label { border-color: var(--c-primary); background: rgba(79, 70, 229, .06); transform: translateY(-2px); box-shadow: var(--shadow); }
.op-dot { display: block; width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 6px; }
.success-mark { width: 92px; height: 92px; margin: 0 auto; border-radius: 50%; background: #d1fae5; display: grid; place-items: center; animation: check-pop .6s var(--ease-spring) both; }
.success-mark svg path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .6s .35s var(--ease) forwards; }
.plan-card { position: relative; border-radius: 22px; padding: 2px; background: conic-gradient(from var(--angle, 0deg), #6366f1, #a855f7, #06b6d4, #6366f1); animation: border-spin 6s linear infinite; }
.plan-card > .inner { border-radius: 20px; background: #fff; padding: 28px; height: 100%; }
@property --angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .45s var(--ease); box-shadow: 30px 0 60px rgba(0, 0, 0, .3); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1035; animation: fade-up .3s; }
  .menu-btn { display: grid; place-items: center; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .checkout { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .reveal { opacity: 1; transform: none; }
}
@media print {
  .sidebar, .topbar, .no-print, .toast-zone, .trial-banner { display: none !important; }
  .app-shell { display: block; } .content { padding: 0; } body { background: #fff; }
  .card, .table { box-shadow: none !important; }
}
