/*
 * AyoSchool — surcouche admin (django-unfold)
 * Style « cadres de menu » inspiré de l'admin Django classique : chaque module
 * (app) est encadré (bordure + fond coloré), avec un bandeau de titre coloré et
 * des liens de modèles encadrés au survol. Injecté via UNFOLD["STYLES"].
 */

/* --- Cadre de module (une app = une carte encadrée) --- */
#nav-sidebar-apps .module {
    border: 1px solid #c7d2fe;                 /* indigo-200 */
    background: #f5f7ff;                        /* indigo-50 très clair */
    border-radius: 10px;
    margin: 10px 8px;
    padding: 2px 0 8px;
    box-shadow: 0 1px 2px rgba(30, 27, 75, 0.05);
}

/* --- Bandeau de titre de l'app (caption coloré, façon Django) --- */
#nav-sidebar-apps .module h2 {
    margin: 0;
}
#nav-sidebar-apps .module h2 a {
    display: block;
    background: #e0e7ff;                        /* indigo-100 */
    color: #3730a3 !important;                  /* indigo-800 */
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 6px 10px !important;
    margin: 8px 0 6px !important;
    font-size: 0.72rem !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700 !important;
}
#nav-sidebar-apps .module h2 a:hover {
    background: #c7d2fe;
    color: #312e81 !important;
}

/* --- Liens de modèles : encadré léger + accent + survol coloré --- */
#nav-sidebar-apps .module li[class^="model-"] > a,
#nav-sidebar-apps .module li[class*=" model-"] > a {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-left: 3px solid #c7d2fe;
    border-radius: 8px !important;
    margin: 2px 0 !important;
}
#nav-sidebar-apps .module li[class^="model-"] > a:hover,
#nav-sidebar-apps .module li[class*=" model-"] > a:hover {
    background: #eef2ff !important;
    border-color: #a5b4fc;
    border-left-color: #6366f1;
    color: #4338ca !important;
}

/* Modèle courant (page active) : fond plein coloré */
#nav-sidebar-apps .module li.selected > a,
#nav-sidebar-apps .module li[class*="model-"] > a.active {
    background: #6366f1 !important;
    border-color: #4f46e5 !important;
    border-left-color: #312e81 !important;
    color: #ffffff !important;
    font-weight: 600;
}

/* --- Dark mode --- */
.dark #nav-sidebar-apps .module {
    background: rgba(49, 46, 129, 0.18);        /* indigo-900 translucide */
    border-color: #3730a3;
}
.dark #nav-sidebar-apps .module h2 a {
    background: rgba(67, 56, 202, 0.35);
    border-color: #4338ca;
    color: #e0e7ff !important;
}
.dark #nav-sidebar-apps .module li[class^="model-"] > a,
.dark #nav-sidebar-apps .module li[class*=" model-"] > a {
    background: transparent;
    border-color: rgba(99, 102, 241, 0.25);
    border-left-color: #4338ca;
}
.dark #nav-sidebar-apps .module li[class^="model-"] > a:hover,
.dark #nav-sidebar-apps .module li[class*=" model-"] > a:hover {
    background: rgba(99, 102, 241, 0.18) !important;
    color: #c7d2fe !important;
}

/* --- Logo de l'en-tête : agrandi au max utile de la sidebar + CENTRÉ --- */
/* Logo natif 1086x215 (wordmark large, ratio ~5:1). La sidebar fait 288px, moins
   les paddings ≈ 250px utiles → on borne par la largeur et on centre. */
img[alt="Accueil"] {
    height: auto !important;
    max-height: 64px !important;
    max-width: 70% !important;       /* logo plus compact (demandé) */
    width: auto !important;
    margin: 10px auto !important;    /* centrage + marge haut/bas harmonieuse */
    object-fit: contain;
    display: block;
}
/* Le lien logo prend toute la largeur pour permettre le centrage de l'image */
#nav-sidebar-inner [class*="h-[65px]"] > div > a[href="/admin/"],
#nav-sidebar-inner a[href="/admin/"] {
    display: block;
    width: 100%;
}
/* En-tête de la sidebar : hauteur au contenu, marges resserrées, contenu centré
   (scopé sidebar → n'affecte pas la barre principale). Remplace le mb-6 d'unfold. */
#nav-sidebar-inner [class*="h-[65px]"] {
    height: auto !important;
    min-height: 0 !important;
    margin-bottom: 8px !important;
    padding: 10px 12px 6px !important;
    align-items: center !important;
    justify-content: center !important;
}
#nav-sidebar-inner [class*="h-[65px]"] > div {
    width: 100%;
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
#nav-sidebar-inner [class*="h-[64px]"] {
    height: auto !important;
    min-height: 0 !important;
    align-items: center !important;
}


/* ===========================================================================
 * Page de connexion — split-screen inspiré du login dashboard (/auth/login)
 * Panneau marque indigo à gauche + formulaire à droite.
 * =========================================================================== */
.ay-login-shell {
    display: flex;
    min-height: 100vh;
}

/* --- Panneau marque (gauche) --- */
.ay-login-brand {
    position: relative;
    overflow: hidden;
    flex: 0 0 42%;
    /* Dégradé moderne indigo → violet + jeux de lumière + texture pointillée */
    background:
        radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1.6px) 0 0 / 22px 22px,
        radial-gradient(1100px 480px at 12% -12%, rgba(255, 255, 255, 0.20), transparent 60%),
        radial-gradient(900px 620px at 115% 118%, rgba(217, 70, 239, 0.42), transparent 55%),
        linear-gradient(135deg, #4338ca 0%, #6a63e7 48%, #7c3aed 100%);
    color: #fff;
    padding: 2.5rem 2.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
}
/* Forme lumineuse décorative supplémentaire (blob bas-gauche) */
.ay-login-brand::after {
    content: "";
    position: absolute;
    left: -6rem;
    bottom: -8rem;
    width: 20rem;
    height: 20rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.45), transparent 68%);
    filter: blur(6px);
    pointer-events: none;
    z-index: 0;
}
/* Fine ligne lumineuse à la jointure avec le formulaire */
.ay-login-brand::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.35), transparent);
    z-index: 1;
}
.ay-login-brand__glow {
    position: absolute;
    top: -7.5rem;
    right: -7.5rem;
    width: 22.5rem;
    height: 22.5rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(123, 125, 245, 0.35), transparent 70%);
    pointer-events: none;
}
.ay-login-brand__head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.ay-login-brand__icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: block;
}
.ay-login-brand__wordmark {
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    line-height: 1;
}
.ay-login-brand__hero {
    position: relative;
    z-index: 1;
}
.ay-login-brand__title {
    font-weight: 800;
    font-size: 3rem;
    line-height: 1.05;
    letter-spacing: -0.035em;
    margin: 0;
    color: #fff;
}
.ay-login-brand__lead {
    margin: 1.25rem 0 0;
    font-size: 1rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.72);
    max-width: 26rem;
}
.ay-login-brand__foot {
    position: relative;
    z-index: 1;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.78);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 1.125rem;
}
.ay-login-brand__chip {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    margin-right: 0.375rem;
    letter-spacing: 0.02em;
}

/* --- Panneau formulaire (droite) --- */
.ay-login-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: #ffffff;
}
.dark .ay-login-form { background: #0b1020; }
.ay-login-card {
    width: 100%;
    max-width: 26rem;
}
.login-intro { margin: 0 0 1.5rem; }
.login-intro h3 {
    margin: 0 0 0.4rem;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #111827;
}
.login-intro p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.55;
    color: #6b7280;
}
.dark .login-intro h3 { color: #e0e7ff; }
.dark .login-intro p { color: #a5b4fc; }

/* Champs de saisie : plus aérés, focus indigo doux */
.ay-login-card #login-form { display: flex; flex-direction: column; gap: 0.35rem; }
.ay-login-card #login-form input[type="text"],
.ay-login-card #login-form input[type="password"] {
    border-radius: 11px !important;
    padding-top: 0.7rem !important;
    padding-bottom: 0.7rem !important;
    border-color: #e5e7eb !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ay-login-card #login-form input[type="text"]:focus,
.ay-login-card #login-form input[type="password"]:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18) !important;
    outline: none !important;
}
.dark .ay-login-card #login-form input[type="text"],
.dark .ay-login-card #login-form input[type="password"] { border-color: #312e81 !important; }

/* Bouton principal : dégradé + relief + micro-interaction */
.ay-login-card .submit-row {
    border-radius: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    height: 3rem;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    border: none !important;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.32);
    transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.ay-login-card .submit-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(79, 70, 229, 0.42);
    filter: brightness(1.03);
}
.ay-login-card .submit-row:active { transform: translateY(0); }

/* Bouton secondaire (mot de passe oublié) : discret */
.ay-login-card .password-reset-link {
    border-radius: 11px !important;
    font-weight: 500 !important;
    color: #4f46e5 !important;
}
.ay-login-card .password-reset-link:hover { background: #eef2ff !important; }

/* --- Responsive : empilé sous 860px --- */
@media (max-width: 860px) {
    .ay-login-shell { flex-direction: column; }
    .ay-login-brand {
        flex: 0 0 auto;
        padding: 1.5rem 1.25rem 1.75rem;
        gap: 1.25rem;
    }
    .ay-login-brand__title { font-size: 1.6rem; }
    .ay-login-brand__lead { font-size: 0.8125rem; }
    .ay-login-brand__foot { display: none; }
    .ay-login-form { padding: 1.75rem 1.25rem 3rem; }
}

/* Bloc explicatif 2FA (login admin) — affiché au-dessus du champ code, dans le
   style unfold/indigo. Ne s'affiche que si le champ OTP est présent (2FA requis). */
.ay-2fa-hint {
    margin: 0.5rem 0 0.85rem;
    padding: 0.75rem 0.9rem;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-left: 3px solid #6366f1;
    border-radius: 10px;
}
.ay-2fa-hint h4 {
    margin: 0 0 0.2rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #3730a3;
    letter-spacing: -0.01em;
}
.ay-2fa-hint p {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #4b5563;
}
.dark .ay-2fa-hint { background: rgba(99, 102, 241, 0.12); border-color: #3730a3; }
.dark .ay-2fa-hint h4 { color: #c7d2fe; }
.dark .ay-2fa-hint p { color: #a5b4fc; }

/* Sélecteur de device masqué (bruit visuel pour un seul appareil) — toujours soumis. */
.ay-otp-device { display: none; }

/* Bouton afficher/masquer le mot de passe (login admin) */
.ay-pwd-holder { position: relative; }
.ay-pwd-holder input { padding-right: 2.75rem !important; }
.ay-pwd-toggle {
    position: absolute;
    top: 50%;
    right: 0.6rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    line-height: 0;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}
.ay-pwd-toggle:hover { color: #4f46e5; background: #eef2ff; }
.ay-pwd-toggle .material-symbols-outlined { font-size: 1.25rem; }
.dark .ay-pwd-toggle { color: #9ca3af; }
.dark .ay-pwd-toggle:hover { color: #c7d2fe; background: rgba(99, 102, 241, 0.15); }

/* ===========================================================================
 * Assistant d'enrôlement 2FA TOTP self-service (/admin/setup-2fa/)
 * Réutilise le shell split-screen du login (.ay-login-*).
 * =========================================================================== */
.ay-setup-card { max-width: 30rem; }

.ay-setup-error {
    margin: 0 0 1rem;
    padding: 0.7rem 0.9rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 3px solid #ef4444;
    border-radius: 10px;
    font-size: 0.85rem;
    color: #b91c1c;
}
.dark .ay-setup-error { background: rgba(239, 68, 68, 0.12); border-color: #7f1d1d; color: #fecaca; }

/* Encadré d'information / avertissement (setup + codes de secours) */
.ay-setup-note {
    margin: 0 0 1.1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    font-size: 0.83rem;
    line-height: 1.5;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-left: 3px solid #6366f1;
    color: #3730a3;
}
.ay-setup-note--warn {
    background: #fffbeb;
    border-color: #fde68a;
    border-left-color: #f59e0b;
    color: #92400e;
}
.dark .ay-setup-note { background: rgba(99, 102, 241, 0.12); border-color: #3730a3; color: #c7d2fe; }
.dark .ay-setup-note--warn { background: rgba(245, 158, 11, 0.12); border-color: #78350f; color: #fcd34d; }

.ay-setup-steps {
    margin: 0 0 1.25rem;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    line-height: 1.55;
    color: #4b5563;
}
.ay-setup-steps li { margin-bottom: 0.3rem; }
.dark .ay-setup-steps { color: #a5b4fc; }

.ay-setup-qr {
    display: flex;
    justify-content: center;
    padding: 0.9rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 1rem;
}
.ay-setup-qr img { display: block; width: 200px; height: 200px; }

.ay-setup-secret {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
    text-align: center;
}
.ay-setup-secret__label { font-size: 0.78rem; color: #6b7280; }
.ay-setup-secret__value {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #3730a3;
    background: #eef2ff;
    border: 1px dashed #c7d2fe;
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    word-break: break-all;
}
.dark .ay-setup-secret__label { color: #a5b4fc; }
.dark .ay-setup-secret__value { background: rgba(99, 102, 241, 0.12); color: #c7d2fe; border-color: #3730a3; }

.ay-setup-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.4rem;
}
.dark .ay-setup-label { color: #e0e7ff; }

.ay-setup-input {
    width: 100%;
    box-sizing: border-box;
    border-radius: 11px;
    border: 1px solid #e5e7eb;
    padding: 0.75rem 0.9rem;
    font-size: 1.3rem;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    letter-spacing: 0.5em;
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ay-setup-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
    outline: none;
}
.dark .ay-setup-input { background: #0b1020; color: #e0e7ff; border-color: #312e81; }

.ay-setup-submit {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 1.1rem;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 11px;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.32);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.ay-setup-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(79, 70, 229, 0.42);
    filter: brightness(1.03);
}
.ay-setup-submit:active { transform: translateY(0); }
.ay-setup-submit--link { margin-top: 1.5rem; }

/* Aides sous le formulaire de vérification 2FA */
.ay-verify-help {
    margin: 1rem 0 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #6b7280;
}
.dark .ay-verify-help { color: #a5b4fc; }
.ay-verify-cancel {
    display: inline-block;
    margin-top: 1.25rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: #4f46e5;
    text-decoration: none;
}
.ay-verify-cancel:hover { text-decoration: underline; }
.dark .ay-verify-cancel { color: #a5b4fc; }

/* Codes de secours (page done) */
.ay-backup-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin: 0.5rem 0 0.5rem;
}
.ay-backup-code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-align: center;
    color: #3730a3;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 0.55rem 0.3rem;
}
.dark .ay-backup-code { background: rgba(99, 102, 241, 0.12); color: #c7d2fe; border-color: #3730a3; }
