/* ============================================================================
   Écran d'accueil « Pétales » (lanceur) — recréation fidèle de la maquette
   Claude Design (Pétales - Accueil, TEMPLATE émeraude). Design bespoke (hors
   MudBlazor/Material) : typo Onest (corps + titres, pas de serif), palette
   ÉMERAUDE reprenant À L'IDENTIQUE les jetons de PetalesTheme.cs (accent
   #0d9d6b, fond vert-crème #f3f6f4, cartes blanches, encre #14211c) ; thème
   clair/sombre piloté par la classe .pa-dark sur la racine .pa.
   Onest est chargée globalement par app.css (@import Google Fonts).
   ============================================================================ */

.pa {
    /* Palette — thème CLAIR (émeraude, jetons du template = PetalesTheme.cs). */
    --pa-bg: #f3f6f4;
    --pa-bar: #ffffff;              /* barre du haut BLANCHE (template) */
    --pa-card: #ffffff;
    --pa-border: #e6eae8;           /* line */
    --pa-text: #14211c;             /* ink */
    --pa-sub: #5b6a63;              /* ink-soft */
    --pa-mute: #8b958f;             /* ink-mute */
    --pa-hover: #eef4f1;
    --pa-accent: #0d9d6b;           /* émeraude — accent principal */
    --pa-accent-2: #0a7d52;         /* émeraude foncé */
    --pa-icon-bg: #e7f4ee;          /* pastille d'icône (vert très clair) */
    --pa-hover-border: #cfe6db;     /* liseré au survol d'une tuile */
    --pa-info: #1f5fb8;
    --pa-warn: #9a6a08;
    --pa-danger: #b3261e;
    --pa-danger-bg: #fbe3e3;
    --pa-success-bg: #dcf3e9;

    min-height: 100vh;
    font-family: 'Onest', system-ui, -apple-system, sans-serif;
    background: var(--pa-bg);
    color: var(--pa-text);
    -webkit-font-smoothing: antialiased;
}

.pa.pa-dark {
    /* Palette — thème SOMBRE (variante émeraude, jetons PaletteDark du template). */
    --pa-bg: #0b1410;
    --pa-bar: #0e1a15;
    --pa-card: #12211b;
    --pa-border: #1d2c25;
    --pa-text: #eaf2ee;
    --pa-sub: #9fb0a8;
    --pa-mute: #7c8d85;
    --pa-hover: #182821;
    --pa-icon-bg: #14342a;
    --pa-hover-border: #24493a;
    --pa-info: #5c9fe0;
    --pa-warn: #d0a02a;
    --pa-danger: #e05a4d;
    --pa-danger-bg: #3a201d;
    --pa-success-bg: #123528;
}

.pa * {
    box-sizing: border-box;
}

.pa ::selection {
    background: #bfe9d7;
    color: #0a3d29;
}

.pa input::placeholder {
    color: inherit;
    opacity: 0.55;
}

/* ── Barre supérieure ─────────────────────────────────────────────────────── */
.pa-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--pa-bar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--pa-border);
}

.pa-header-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 13px 28px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.pa-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pa-brand-name {
    font-family: 'Onest', system-ui, sans-serif;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.pa-badge-dev {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #b8843f;
    background: #f6ecd8;
    border: 1px solid #ecd9b0;
    padding: 3px 7px;
    border-radius: 6px;
    text-transform: uppercase;
}

/* Variante sombre : la pastille « DEV » crème détonnerait sur la barre sombre → ambre profond lisible. */
.pa-dark .pa-badge-dev {
    color: #e3bd72;
    background: #3a2f1c;
    border-color: #5a4a2a;
}

.pa-search {
    flex: 1;
    max-width: 520px;
    margin: 0 auto;
    position: relative;
}

.pa-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    stroke: var(--pa-sub);
    pointer-events: none;
}

.pa-search input {
    width: 100%;
    padding: 11px 14px 11px 40px;
    border-radius: 10px;
    border: 1px solid var(--pa-border);
    background: var(--pa-bg);
    color: var(--pa-text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.pa-search input:focus {
    border-color: var(--pa-accent);
}

.pa-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.pa-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--pa-border);
    background: var(--pa-card);
    color: var(--pa-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    position: relative;
    text-decoration: none;
    padding: 0;
}

.pa-icon-btn:hover {
    border-color: var(--pa-accent);
}

.pa-notif-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #e5484d;
    border: 2px solid var(--pa-card);
}

.pa-user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 4px 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--pa-border);
    background: var(--pa-card);
}

.pa-user-name {
    font-size: 13px;
    font-weight: 600;
}

.pa-avatar {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: #cdeadd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #0a7d52;
}

.pa-signin {
    text-decoration: none;
    color: var(--pa-text);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--pa-border);
    background: var(--pa-card);
}

.pa-signin:hover {
    border-color: var(--pa-accent);
}

.pa-logout-form {
    display: inline;
    margin: 0;
}

/* ── Contenu principal ────────────────────────────────────────────────────── */
.pa-main {
    max-width: 1360px;
    margin: 0 auto;
    padding: 34px 34px 64px;
}

.pa-greeting {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}

.pa-hello {
    font-family: 'Onest', system-ui, sans-serif;
    font-weight: 700;
    font-size: 32px;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}

.pa-sub {
    margin: 0;
    font-size: 15px;
    color: var(--pa-sub);
}

.pa-cta {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--pa-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 8px 20px -10px rgba(13, 157, 107, 0.6);
    text-decoration: none;
}

.pa-cta:hover {
    background: var(--pa-accent-2);
}

/* ── Bandeau KPI ──────────────────────────────────────────────────────────── */
.pa-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 34px;
}

.pa-kpi {
    background: var(--pa-card);
    border: 1px solid var(--pa-border);
    border-radius: 16px;
    padding: 16px 18px;
}

.pa-kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--pa-sub);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pa-kpi-value-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 7px;
    /* (D-RWD) wrap défensif : évite qu'une grosse valeur (ERP à l'échelle, montants élevés) + son
       delta ne débordent la carte sur une largeur de colonne réduite — neutre tant que ça tient
       sur une ligne (cas bureau actuel). */
    flex-wrap: wrap;
}

.pa-kpi-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.pa-kpi-delta {
    font-size: 12px;
    font-weight: 600;
}

.pa-delta-up { color: var(--pa-accent-2); }
.pa-delta-down { color: var(--pa-danger); }
.pa-delta-muted { color: var(--pa-sub); }

/* ── Corps : modules + panneau latéral ────────────────────────────────────── */
.pa-body {
    display: grid;
    grid-template-columns: 1fr 330px;
    gap: 24px;
    align-items: start;
}

.pa-body--solo {
    grid-template-columns: 1fr;
}

.pa-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}

.pa-section-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
}

.pa-section-count {
    font-size: 13px;
    color: var(--pa-sub);
}

.pa-modules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.pa-module {
    position: relative;
    text-decoration: none;
    color: inherit;
    background: var(--pa-card);
    border: 1px solid var(--pa-border);
    border-radius: 16px;
    padding: 20px 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 128px;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

a.pa-module:hover {
    transform: translateY(-3px);
    border-color: var(--pa-hover-border);
    box-shadow: 0 14px 30px rgba(20, 40, 32, 0.10);
}

.pa-module--off {
    opacity: 0.5;
    filter: grayscale(0.9);
    cursor: default;
    pointer-events: none;
}

.pa-module-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.pa-module-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--pa-icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pa-accent-2);
    transition: background 0.14s, color 0.14s;
}

/* Signature du template : au survol, la pastille d'icône se remplit d'émeraude. */
a.pa-module:hover .pa-module-icon {
    background: var(--pa-accent);
    color: #fff;
}

.pa-module-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--pa-danger);
    background: var(--pa-danger-bg);
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.pa-module-name {
    font-size: 16.5px;
    font-weight: 700;
    margin-bottom: 3px;
}

.pa-module-desc {
    font-size: 13px;
    color: var(--pa-sub);
    line-height: 1.45;
}

.pa-empty {
    text-align: center;
    padding: 40px;
    color: var(--pa-sub);
    font-size: 15px;
}

/* ── Panneau latéral ──────────────────────────────────────────────────────── */
.pa-aside {
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 88px;
}

.pa-panel {
    background: var(--pa-card);
    border: 1px solid var(--pa-border);
    border-radius: 16px;
    padding: 18px;
}

.pa-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.pa-panel-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}

.pa-pill {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--pa-accent);
    padding: 2px 8px;
    border-radius: 999px;
}

.pa-tasks {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pa-task {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 8px;
    border-radius: 9px;
}

.pa-task:hover {
    background: var(--pa-hover);
}

.pa-task-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 999px;
}

.pa-task-text {
    flex: 1;
    font-size: 13.5px;
    line-height: 1.35;
}

.pa-task-chevron {
    flex: none;
    color: var(--pa-sub);
    font-size: 14px;
}

.pa-activity {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pa-act {
    display: flex;
    gap: 11px;
}

.pa-act-glyph {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.pa-act-text {
    font-size: 13.5px;
    line-height: 1.35;
}

.pa-act-time {
    font-size: 11.5px;
    color: var(--pa-sub);
    margin-top: 2px;
}

.pa-panel-empty {
    font-size: 13px;
    color: var(--pa-sub);
    padding: 6px 2px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
    .pa-body {
        grid-template-columns: 1fr;
    }

    .pa-aside {
        position: static;
    }
}

@media (max-width: 880px) {
    .pa-kpis {
        grid-template-columns: repeat(2, 1fr);
    }

    .pa-modules-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 620px) {
    .pa-header-inner {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .pa-search {
        order: 3;
        flex-basis: 100%;
        max-width: none;
    }

    /* (D-RWD) La barre d'actions (thème, notifs, commutateur de société, admin, utilisateur,
       déconnexion) ne tient pas sur une seule ligne à 390 px pour un utilisateur authentifié
       multi-société/admin : elle passe sur sa propre ligne (héritée du wrap de l'en-tête
       ci-dessus) puis s'enroule elle-même plutôt que de déborder horizontalement la page. */
    .pa-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    /* (D-RWD) Filet de sécurité pour un nom d'utilisateur long une fois la pastille repliée sur
       elle-même : tronque au lieu de repousser la hauteur de la pastille ou de déborder. */
    .pa-user-name {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .pa-main {
        padding: 22px 16px 48px;
    }

    /* (D-RWD) Sous 620 px, 2 colonnes de KPI redeviennent trop étroites pour des montants à
       l'échelle (ERP généraliste, pas de plafond bakery) : une seule colonne pleine largeur. */
    .pa-kpis {
        grid-template-columns: 1fr;
    }

    .pa-modules-grid {
        grid-template-columns: 1fr;
    }

    .pa-hello {
        font-size: 28px;
    }
}
