/* ==========================================================================
   CREDIPRO — Identite visuelle
   --------------------------------------------------------------------------
   Protection financiere des professionnels : credit + assurance.

   Ce fichier est une SURCHARGE. Il ne modifie aucun fichier existant :
   il redefinit les variables de :root et ajoute une couche visuelle
   au-dessus de app.css / vitrine.css, qui restent intacts.

   Parti pris : fond clair bleu tres doux, surface blanche, orange Credipro
   en unique couleur de marque. L'orange vient du logo : il ne sert qu'aux
   actions et aux reperes, jamais en aplat. Le panneau de connexion, lui,
   reste bleu nuit — c'est la seule zone de contraste elevee de l'application.

   Animations lentes (>= 9 s) et peu amples : une impression d'institution
   calme, pas un site marketing. Tout respecte prefers-reduced-motion.

   Ajout : 1 ligne <link> dans web/index.html, apres app.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. PALETTE CLAIRE — blanc bleute institutionnel
   -------------------------------------------------------------------------- */

:root,
:root[data-theme="light"] {
    color-scheme: light;

    --bg: #EDF1F7;
    --bg-2: #E3E9F2;
    --surface: #FFFFFF;
    --surface-2: #F7F9FC;
    --surface-3: #EDF2F8;
    --surface-verre: rgba(255, 255, 255, .84);

    --border: #DAE1EB;
    --border-2: #C2CEDE;

    --text: #0E1B2D;
    --text-2: #435268;
    --text-3: #616E82;
    --text-inverse: #FFFFFF;

    /* Marque : l'orange du logo. Uniquement en accent. */
    --brand: #E7873C;
    --brand-2: #F0954E;
    --brand-3: #F7B177;
    --brand-deep: #BE6520;
    --brand-soft: #FDF0E4;
    --brand-ink: #9E4F14;
    --brand-glow: rgba(231, 135, 60, .28);
    --brand-voile: rgba(231, 135, 60, .07);

    /* Accent secondaire : champagne, reserve au volet « credit ».
       Assombri pour rester lisible sur son propre fond pale. */
    --credit: #6F5723;
    --credit-soft: #F7F1E2;
    --credit-glow: rgba(111, 87, 35, .20);

    --accent: #3C6EA8;
    --accent-2: #2F5D90;
    --accent-soft: #E7EFF8;

    /* Etats : desatures, lisibles sur blanc */
    --ok: #14683D;      --ok-soft: #E1F3E9;
    --warn: #8A5806;    --warn-soft: #FBF0DC;
    --danger: #AE3330;  --danger-soft: #FBE8E7;
    --info: #235EA0;    --info-soft: #E5EFFA;
    --violet: #5E3EB0;  --violet-soft: #EEE8FB;

    --serie-1: #2A6CB5; --serie-2: #E7873C; --serie-3: #1B7F4F; --serie-4: #B8913F;
    --serie-5: #C75B84; --serie-6: #5E9A3C; --serie-7: #5B4FA8; --serie-8: #C2503F;
    --grille: #E4EAF2; --axe: #C8D2DF;
    --seq-1: #DCE9F7; --seq-2: #BBD6F1; --seq-3: #93BDE7; --seq-4: #669ED6;
    --seq-5: #3E7FC0; --seq-6: #2A6CB5; --seq-7: #1F4F85;

    /* Ombres : froides et basses. Sur fond clair, une ombre assombrit trop ;
       le page ; on utilise donc une teinte bleute, pas du noir. */
    --ombre-1: 0 1px 2px rgba(19, 38, 66, .06);
    --ombre-2: 0 1px 2px rgba(19, 38, 66, .05), 0 8px 24px -10px rgba(19, 38, 66, .16);
    --ombre-3: 0 30px 70px -24px rgba(19, 38, 66, .28), 0 2px 6px rgba(19, 38, 66, .07);
    --ombre-marque: 0 10px 28px -14px rgba(231, 135, 60, .55);
    --anneau: 0 0 0 3px rgba(231, 135, 60, .34);

    --transition: 200ms cubic-bezier(.22, .68, .3, 1);

    --cred-orb-1: #E7873C;
    --cred-orb-2: #B9703A;
    --cred-nuit-1: #16273F;
    --cred-nuit-2: #0A1420;
}

/* --------------------------------------------------------------------------
   1 bis. VARIANTE SOMBRE
   Le fond par defaut est clair. Si quelqu'un bascule en sombre, on ne lui
   propose pas du noir franc : un bleu nuit coherent avec le panneau de
   connexion, ou l'orange reste aussi lisible.
   -------------------------------------------------------------------------- */

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0B1523;
    --bg-2: #0E1B2C;
    --surface: #14243A;
    --surface-2: #1A2C45;
    --surface-3: #223650;
    --surface-verre: rgba(20, 36, 58, .82);

    --border: #263B55;
    --border-2: #34506F;

    --text: #F2F6FB;
    --text-2: #B9C6D7;
    --text-3: #8496AC;

    --brand: #E7873C;
    --brand-2: #F79D5C;
    --brand-3: #FFB982;
    --brand-deep: #BE6520;
    --brand-soft: #33210F;
    --brand-ink: #FFC79B;
    --brand-glow: rgba(231, 135, 60, .30);
    --brand-voile: rgba(231, 135, 60, .08);

    --credit: #D9B978;
    --credit-soft: #2B2517;
    --credit-glow: rgba(217, 185, 120, .22);

    --accent: #8FB0D8;
    --accent-2: #A9C5E6;
    --accent-soft: #1B2B40;

    --ok: #56C58C;      --ok-soft: #133223;
    --warn: #E3AE4E;    --warn-soft: #33260F;
    --danger: #E77A75;  --danger-soft: #351A1A;
    --info: #6FA5DF;    --info-soft: #16273B;
    --violet: #AE95F0;  --violet-soft: #241C3D;

    --serie-1: #6FA5DF; --serie-2: #E7873C; --serie-3: #56C58C; --serie-4: #D9B978;
    --serie-5: #DE7C9E; --serie-6: #8CC46E; --serie-7: #9C93DC; --serie-8: #DE7A6C;
    --grille: #1D3049; --axe: #334B69;
    --seq-1: #12293F; --seq-2: #17395A; --seq-3: #1D4B76; --seq-4: #236095;
    --seq-5: #3C79B4; --seq-6: #6FA5DF; --seq-7: #B9D2EE;

    --ombre-1: 0 1px 2px rgba(0, 0, 0, .45);
    --ombre-2: 0 2px 4px rgba(0, 0, 0, .35), 0 14px 34px -14px rgba(0, 0, 0, .70);
    --ombre-3: 0 36px 90px -26px rgba(0, 0, 0, .88), 0 3px 10px rgba(0, 0, 0, .45);
    --ombre-marque: 0 12px 34px -14px rgba(231, 135, 60, .55);
}

/* --------------------------------------------------------------------------
   2. FOND
   Sur fond clair, un halo orange se voit des qu'il depasse 4 %. On reste
   sous ce seuil et on laisse le bleu de fond faire le travail.
   -------------------------------------------------------------------------- */

html { background: var(--bg); }

body {
    background: var(--bg);
    background-image:
        radial-gradient(1180px 640px at 8% -8%, rgba(231, 135, 60, .05), transparent 58%),
        radial-gradient(1000px 600px at 98% 2%, rgba(42, 108, 181, .05), transparent 56%);
    background-attachment: fixed;
}

/* Trame : lignes bleutees tres espacees, derive tres lente.
   Donne l'echelle et la profondeur sans jamais distraire. */
body::before {
    content: "";
    position: fixed;
    inset: -40% -10%;
    z-index: 0;
    pointer-events: none;
    opacity: .85;
    background-image:
        linear-gradient(to right, rgba(20, 45, 80, .028) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(20, 45, 80, .028) 1px, transparent 1px);
    background-size: 88px 88px;
    -webkit-mask-image: radial-gradient(ellipse 72% 56% at 50% 30%, #000 18%, transparent 78%);
    mask-image: radial-gradient(ellipse 72% 56% at 50% 30%, #000 18%, transparent 78%);
    animation: cred-derive 150s linear infinite;
}

@keyframes cred-derive {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-88px, -88px, 0); }
}

:root[data-theme="dark"] body::before {
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, .022) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, .022) 1px, transparent 1px);
}

/* Sur fond clair, un vignettage sombre salirait la page : on le supprime
   et on remplace par un rehaut froid tres leger. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(130% 95% at 50% 0%, rgba(255, 255, 255, .5), transparent 55%);
}

:root[data-theme="dark"] body::after {
    background: radial-gradient(120% 90% at 50% 0%, transparent 52%, rgba(0, 0, 0, .5) 100%);
}

.app, .menu-lateral, .principal { position: relative; z-index: 1; }

/* --------------------------------------------------------------------------
   3. PANNEAU DE CONNEXION
   Seul endroit en bleu nuit : c'est la vitrine de marque, et elle doit
   trancher avec le formulaire blanc pour guider l'oeil vers la saisie.
   -------------------------------------------------------------------------- */

.connexion {
    background: var(--surface);
    overflow: hidden;
}

.connexion-visuel {
    position: relative;
    isolation: isolate;
    background:
        radial-gradient(1000px 640px at 14% 6%, rgba(231, 135, 60, .22), transparent 60%),
        radial-gradient(860px 560px at 94% 92%, rgba(184, 145, 63, .16), transparent 58%),
        linear-gradient(158deg, #16273F 0%, #0C1828 58%, #08111C 100%);
}

/* Le pave de points d'origine occupe ::after : on le reporte sur un
   element dedie, tres attenue. */
.connexion-visuel .lien-metiers::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .05;
    background-image: radial-gradient(rgba(255, 255, 255, .95) 1px, transparent 1.2px);
    background-size: 26px 26px;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 40%, transparent);
    mask-image: linear-gradient(180deg, transparent, #000 40%, transparent);
}

/* Deux orbes : le credit et l'assurance. Elles respirent, tres lentement,
   et se rapprochent lentement — l'image du credit adosse a la protection. */
.connexion-visuel::before,
.connexion-visuel::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(48px);
}

.connexion-visuel::before {
    width: 340px; height: 340px;
    left: 6%; bottom: 8%;
    background: radial-gradient(circle at 34% 32%, var(--cred-orb-1), transparent 68%);
    opacity: .26;
    animation: cred-respire 26s ease-in-out infinite;
}

.connexion-visuel::after {
    width: 300px; height: 300px;
    right: 4%; top: 16%;
    background: radial-gradient(circle at 60% 40%, var(--cred-orb-2), transparent 70%);
    opacity: .20;
    animation: cred-respire 34s ease-in-out infinite reverse;
}

@keyframes cred-respire {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); opacity: .18; }
    50%      { transform: translate3d(26px, -30px, 0) scale(1.14); opacity: .30; }
}

/* Trait d'union entre les deux orbes : le lien protection financiere. */
.connexion-visuel .lien-metiers {
    position: absolute;
    left: 12%; right: 10%; bottom: 22%;
    height: 1px;
    z-index: 0;
    background: linear-gradient(90deg,
        transparent, rgba(231, 135, 60, .50) 26%,
        rgba(217, 185, 120, .58) 62%, transparent);
}

/* Barre de lumere qui parcourt l'ecran toutes les 11 s.
   Evocation de circuit, de flux, de credit qui circule. */
.connexion-visuel .balayage {
    position: absolute;
    top: 0; bottom: 0;
    width: 34%;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(100deg,
        transparent, rgba(231, 135, 60, .08) 42%,
        rgba(255, 255, 255, .12) 50%, transparent);
    transform: skewX(-14deg);
    animation: cred-balayage 11s cubic-bezier(.5, 0, .3, 1) infinite;
}

@keyframes cred-balayage {
    0%        { left: -40%; opacity: 0; }
    12%       { opacity: 1; }
    62%, 100% { left: 118%; opacity: 0; }
}

/* --- Bloc-marque --- */
.connexion-visuel .marque { letter-spacing: -.028em; }

.connexion-visuel .marque .logo {
    background: linear-gradient(145deg, rgba(231, 135, 60, .32), rgba(231, 135, 60, .12));
    box-shadow:
        inset 0 0 0 1px rgba(231, 135, 60, .45),
        0 10px 30px -10px rgba(231, 135, 60, .55);
    animation: cred-souffle 7s ease-in-out infinite;
}

@keyframes cred-souffle {
    0%, 100% { box-shadow: inset 0 0 0 1px rgba(231, 135, 60, .42), 0 10px 30px -10px rgba(231, 135, 60, .45); }
    50%      { box-shadow: inset 0 0 0 1px rgba(231, 135, 60, .66), 0 14px 42px -10px rgba(231, 135, 60, .75); }
}

.connexion-visuel h1 {
    letter-spacing: -.038em;
    text-wrap: balance;
    background: linear-gradient(178deg, #FFFFFF 30%, #DCE6F2 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.connexion-visuel .accroche p { opacity: .78; letter-spacing: .002em; }

.connexion-visuel .villes span {
    background: rgba(255, 255, 255, .06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .11);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background var(--transition), box-shadow var(--transition);
}

.connexion-visuel .villes span:hover {
    background: rgba(231, 135, 60, .16);
    box-shadow: inset 0 0 0 1px rgba(231, 135, 60, .45);
}

.connexion-visuel .carte-deco {
    background: rgba(255, 255, 255, .05);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .09),
        0 30px 70px -24px rgba(0, 0, 0, .85);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    animation: cred-flotte 18s ease-in-out infinite;
}

@keyframes cred-flotte {
    0%, 100% { transform: rotate(-8deg) translateY(0); }
    50%      { transform: rotate(-8deg) translateY(-9px); }
}

/* --- Colonne formulaire : blanche, nette, sans degrade --- */
.connexion-form {
    background: var(--surface);
    display: grid;
    place-items: center;
}

.connexion-form h2 { color: var(--text); }

.connexion input[type="text"],
.connexion input[type="password"],
.connexion input[type="email"],
input.champ, input[type="password"] {
    background: var(--surface-2) !important;
    border-color: var(--border-2) !important;
    box-shadow: inset 0 1px 2px rgba(19, 38, 66, .05) !important;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.connexion input:focus,
input.champ:focus {
    background: #FFFFFF !important;
    border-color: var(--brand) !important;
    box-shadow: inset 0 1px 2px rgba(19, 38, 66, .04), 0 0 0 4px rgba(231, 135, 60, .18) !important;
    outline: none !important;
}

/* --------------------------------------------------------------------------
   4. SURFACIES
   -------------------------------------------------------------------------- */

.menu-lateral, .topbar, .barre {
    background: rgba(255, 255, 255, .88) !important;
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border-color: var(--border) !important;
}

:root[data-theme="dark"] .menu-lateral,
:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .barre {
    background: rgba(20, 36, 58, .86) !important;
}

.carte, .tuile {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    box-shadow: var(--ombre-2) !important;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.carte, .tuile { position: relative; overflow: hidden; }

.carte::before, .tuile::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--brand), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.carte:hover::before, .tuile:hover::before { opacity: 1; }

.carte:hover, .tuile:hover {
    border-color: var(--brand) !important;
    box-shadow: var(--ombre-2), var(--ombre-marque) !important;
}

/* --------------------------------------------------------------------------
   5. BOUTONS ET ETATS
   Attention : .principal est le conteneur de contenu de l'application,
   pas un bouton. Seuls les vrais boutons sont concernes ici.
   -------------------------------------------------------------------------- */

.btn, .bouton, button, .btn-primaire {
    transition: filter var(--transition), box-shadow var(--transition),
                transform var(--transition), background var(--transition);
}

.btn-primaire {
    background: linear-gradient(140deg, var(--brand-2), var(--brand) 58%, var(--brand-deep)) !important;
    color: #1A0D03 !important;
    font-weight: 650 !important;
    box-shadow: 0 8px 22px -10px rgba(231, 135, 60, .85) !important;
}

.btn-primaire:hover {
    filter: brightness(1.06);
    box-shadow: 0 14px 34px -12px rgba(231, 135, 60, .95) !important;
    transform: translateY(-1px);
}

.btn-primaire:active { transform: translateY(0); }

:focus-visible {
    outline: 2px solid var(--brand) !important;
    outline-offset: 2px !important;
    border-radius: 6px;
}

a { transition: color var(--transition); }
/* --brand-deep sur le fond clair plafonne a 4,43: sous le seuil AA de
   4,5. --brand-ink descend a 5,17 et reste lisible. */
a:hover { color: var(--brand-ink); }

/* --------------------------------------------------------------------------
   6. DETAIL
   -------------------------------------------------------------------------- */

::selection { background: rgba(231, 135, 60, .28); color: #0E1B2D; }

* { scrollbar-color: var(--border-2) transparent; scrollbar-width: thin; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border: 3px solid var(--bg);
    border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* Chiffres alignes des que l'on compare des montants */
.montant, .valeur, .kpi, [data-montant], td.num, .tabular {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

h1 { letter-spacing: -.025em; }
h2 { letter-spacing: -.018em; }

/* --------------------------------------------------------------------------
   7. LOGO
   L'ancien « P » inline est remplace par le disque Credipro. Cibles
   ecrites ici plutot qu'en dur dans app.css, qui reste intact.
   -------------------------------------------------------------------------- */

.logo img.logo-marque,
.logo svg.logo-marque,
.logo-marque {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
    border-radius: 50%;
}

.connexion-visuel .marque .logo img.logo-marque,
.connexion-visuel .marque .logo .logo-marque {
    width: 30px;
    height: 30px;
}

.v-logo {
    background-image: url("/img/logo-credipro.svg");
    box-shadow: 0 8px 20px -8px rgba(231, 135, 60, .60);
}

/* --------------------------------------------------------------------------
   8. ACCESSIBILITE
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    body::before,
    .connexion-visuel::before,
    .connexion-visuel::after,
    .connexion-visuel .balayage,
    .connexion-visuel .carte-deco,
    .connexion-visuel .marque .logo {
        animation: none !important;
    }
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
    .connexion-visuel .balayage { display: none; }
}

@media (max-width: 900px) {
    .connexion-visuel::before { width: 240px; height: 240px; left: -6%; bottom: 2%; }
    .connexion-visuel::after { width: 210px; height: 210px; right: -8%; top: 6%; }
    .connexion-visuel .lien-metiers { display: none; }
    body::before { opacity: .5; }
}