/* ════════════════════════════════════════════════════════════════════════════
   eb-ui.css — linguagem visual partilhada do eBill (CRM) e do eBill.CarWash.
   Fonte única: este ficheiro. O CarWash liga-o pelo eBill.CarWash.csproj.

   - Carrega DEPOIS do MudBlazor.min.css: as classes eb-* ganham ao Mud em empate.
   - Selectores largos (entrada por rota) vão em :where() (especificidade 0) para
     nunca tirarem a animação aos spinners e skeletons do Mud.
   - Keyframes só com "from" + fill "backwards": esconde durante o atraso e no fim
     não segura opacity/transform (forwards/both prenderiam o transform e criariam
     um containing block para filhos position:fixed).
   - Hover nunca move a área clicável: anel na cor de destaque, sem transform.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────────────────
   Cores: valor claro = o hex que as páginas usavam (modo claro fica igual).
   [data-theme] é posto no <html> pelo window.ebillTheme (eBill) ou
   window.carwashTheme (CarWash). Usar estes em vez de hex fixo. */
:root {
    --eb-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --eb-ease-in: cubic-bezier(0.4, 0, 1, 1);
    --eb-ease-sheet: cubic-bezier(0.32, 0.72, 0, 1); /* menus e folhas (BottomNav, ContaMenu) */

    --eb-radius-card: 16px;
    /* ponytail: sombras afinadas a olho no QA; mudar aqui muda a app toda. */
    --eb-shadow-rest: 0 6px 18px rgba(0, 0, 0, 0.12);
    --eb-shadow-hover: 0 14px 32px rgba(0, 0, 0, 0.22);
    --eb-line-soft: color-mix(in srgb, var(--mud-palette-lines-default) 60%, transparent);

    --eb-green: #2E7D32;
    --eb-teal: #00796B;
    --eb-orange: #E65100;
    --eb-red: #C62828;
    --eb-blue: #1565C0;
    --eb-blue-2: #1976D2;
    --eb-navy: #0D47A1;
    --eb-indigo: #1A237E;
    --eb-purple: #6A1B9A;
    --eb-cyan: #00838F;
    --eb-grey: #616161;
    --eb-slate: #455A64;

    --eb-green-bg: #E8F5E9;
    --eb-teal-bg: #E0F2F1;
    --eb-orange-bg: #FFF3E0;
    --eb-red-bg: #FFEBEE;
    --eb-blue-bg: #E3F2FD;
    --eb-indigo-bg: #E8EAF6;
    --eb-purple-bg: #F3E5F5;
    --eb-cyan-bg: #E0F7FA;
    --eb-grey-bg: #F5F5F5;
}

[data-theme="dark"] {
    --eb-green: #5CC98A;
    --eb-teal: #4DB6AC;
    --eb-orange: #FFB454;
    --eb-red: #FF6B6B;
    --eb-blue: #7FB2FF;
    --eb-blue-2: #5B9DFF;
    --eb-navy: #8AB4FF;
    --eb-indigo: #9FA8FF;
    --eb-purple: #CE93D8;
    --eb-cyan: #4DD0E1;
    --eb-grey: #AEB6C8;
    --eb-slate: #B0BEC5;

    --eb-green-bg: rgba(92, 201, 138, 0.14);
    --eb-teal-bg: rgba(77, 182, 172, 0.14);
    --eb-orange-bg: rgba(255, 180, 84, 0.14);
    --eb-red-bg: rgba(255, 107, 107, 0.14);
    --eb-blue-bg: rgba(127, 178, 255, 0.14);
    --eb-indigo-bg: rgba(159, 168, 255, 0.14);
    --eb-purple-bg: rgba(206, 147, 216, 0.14);
    --eb-cyan-bg: rgba(77, 208, 225, 0.14);
    --eb-grey-bg: rgba(255, 255, 255, 0.05);
}

/* ── Keyframes ──────────────────────────────────────────────────────────── */
@keyframes eb-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

@keyframes eb-glow {
    to {
        transform: translate3d(6%, 4%, 0) scale(1.08);
    }
}

@keyframes eb-wave {
    from {
        transform: translate3d(-90px, 0, 0);
    }

    to {
        transform: translate3d(85px, 0, 0);
    }
}

@keyframes eb-breathe {
    0%, 100% {
        opacity: 0.2;
        transform: scale(0.96);
    }

    50% {
        opacity: 1;
        transform: scale(1.04);
    }
}

@keyframes eb-fade {
    to {
        opacity: 0.35;
    }
}

@keyframes eb-slide {
    from {
        opacity: 0;
        transform: translateX(28px);
    }
}

@keyframes eb-slide-back {
    from {
        opacity: 0;
        transform: translateX(-28px);
    }
}

@keyframes eb-fade-in {
    from {
        opacity: 0;
    }
}

@keyframes eb-leave {
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
}

@keyframes eb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Auth: fundo, cartão e painel de marca (AuthLayout) ──────────────────── */
/* Fundo azul-oceano com ondas na base (efeito água). Sem isolate o .auth-bg
   (z-index -1) ficava por baixo do fundo do body. */
.auth-layout {
    position: relative;
    isolation: isolate;
}

/* Fixo: páginas longas (módulos) mantêm o fundo ao fazer scroll. */
.auth-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: linear-gradient(160deg, #0B3A7E 0%, #0D47A1 50%, #185AB0 100%);
}

    /* Reflexo de luz a derivar devagar: só transform anima. */
    .auth-bg::before {
        content: "";
        position: absolute;
        inset: -20%;
        background:
            radial-gradient(35% 30% at 25% 20%, rgba(255, 255, 255, 0.07), transparent 70%),
            radial-gradient(30% 25% at 80% 45%, rgba(100, 181, 246, 0.10), transparent 70%);
        animation: eb-glow 40s ease-in-out infinite alternate;
    }

[data-theme="dark"] .auth-bg {
    background: linear-gradient(160deg, #0B1220 0%, #0F1D38 55%, #142A52 100%);
}

    [data-theme="dark"] .auth-bg::before {
        opacity: 0.6;
    }

/* Ondas: 4 camadas do mesmo path, cada uma com velocidade e atraso próprios. */
.auth-waves {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: clamp(90px, 16vh, 180px);
}

    .auth-waves use {
        animation: eb-wave 40s ease-in-out infinite alternate;
    }

        .auth-waves use:nth-child(1) { animation-delay: -4s; animation-duration: 22s; fill: rgba(255, 255, 255, 0.05); }
        .auth-waves use:nth-child(2) { animation-delay: -9s; animation-duration: 30s; fill: rgba(255, 255, 255, 0.04); }
        .auth-waves use:nth-child(3) { animation-delay: -14s; animation-duration: 38s; fill: rgba(255, 255, 255, 0.035); }
        .auth-waves use:nth-child(4) { animation-delay: -20s; animation-duration: 48s; fill: rgba(255, 255, 255, 0.045); }

.auth-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-theme-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    color: rgba(255, 255, 255, 0.85);
}

/* Acções secundárias soltas no fundo ("Terminar sessão", "Voltar"): contorno branco
   com fundo translúcido. (0,3,0) vence o .mud-button-text-inherit do Mud (cinza escuro). */
.auth-layout .mud-button-root.auth-ghost-btn {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    padding-inline: 20px;
}

    .auth-layout .mud-button-root.auth-ghost-btn:hover {
        background: rgba(255, 255, 255, 0.18);
    }

/* Conteúdo solto (splash, "Sem acesso", 404) num cartão, como o login. */
.auth-layout .auth-panel { /* (0,2,0): vence o raio de 4px do MudPaper */
    padding: 32px;
    border-radius: 20px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}

/* Cartão do Login / Recuperar senha: marca à esquerda, formulário à direita. */
.auth-card {
    display: flex;
    width: min(100%, 960px);
    min-height: 560px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

/* Azul fixo (não a primária, que no escuro é azul claro e apagava o texto branco). */
.auth-brand {
    position: relative;
    isolation: isolate;
    flex: 0 0 42%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    padding: 40px 36px 24px;
    color: #fff;
    background: linear-gradient(135deg, #0D47A1 0%, #1976D2 100%);
}

[data-theme="dark"] .auth-brand {
    background: linear-gradient(135deg, #0B2A63 0%, #1A4A9E 100%);
}

    /* Anéis nos cantos, eco do anel do logótipo. */
    .auth-brand::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        pointer-events: none;
        background:
            radial-gradient(circle at 100% 0, transparent 119px, rgba(255, 255, 255, 0.08) 120px 121px, transparent 122px 179px, rgba(255, 255, 255, 0.05) 180px 181px, transparent 182px),
            radial-gradient(circle at 0 100%, transparent 139px, rgba(255, 255, 255, 0.06) 140px 141px, transparent 142px);
    }

.auth-logo {
    margin-top: auto;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.05);
}

    .auth-logo svg {
        display: block;
        width: 96px;
        height: 96px;
    }

.auth-logo-ring {
    transform-box: fill-box;
    transform-origin: center;
    animation: eb-spin 20s linear infinite;
}

.auth-brand-name {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.auth-brand-tagline {
    margin: 4px 0 0;
    opacity: 0.85;
}

.auth-brand-footer {
    margin-top: auto;
    padding-top: 16px;
    font-size: 0.75rem;
    opacity: 0.7;
}

.auth-form {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 56px;
}

    /* O iOS amplia inputs < 16px ao focar. (0,2,0) vence o .mud-input do MudBlazor. */
    .auth-form .mud-input {
        font-size: 1rem;
    }

/* Login ↔ Recuperar senha: o cartão fica (AuthCardLayout) e só o formulário entra a
   deslizar, para a frente ou para trás. O overflow do cartão evita scroll lateral. */
.auth-form-body,
.auth-step {
    animation: eb-slide 0.42s var(--eb-ease-out) backwards;
}

    .auth-form-body[data-dir="back"] {
        animation-name: eb-slide-back;
    }

/* O subtítulo da marca troca com um fade (@key no AuthBrand). */
.auth-brand-tagline {
    animation: eb-fade-in 0.4s ease backwards;
}

/* Splash (Home e arranque do circuito): logo do login sobre as ondas, tudo centrado. */
.auth-splash {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(100%, 420px);
    text-align: center;
    color: #fff;
    /* Fixa: antes do MudThemeProvider o body ainda está em Helvetica (salto de fonte). */
    font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
    animation: eb-rise 0.55s var(--eb-ease-out) backwards;
}

    .auth-splash .auth-logo {
        position: relative;
        margin: 0 0 20px;
    }

        /* Halo a "respirar" à volta do logo. */
        .auth-splash .auth-logo::after {
            content: "";
            position: absolute;
            inset: -10px;
            border-radius: 50%;
            border: 1px solid rgba(255, 255, 255, 0.25);
            animation: eb-breathe 3s ease-in-out infinite;
        }

    /* O anel gira mais depressa: é o indicador de carregamento. */
    .auth-splash .auth-logo-ring {
        animation-duration: 2.4s;
    }

.auth-splash-title {
    margin: 0 0 6px;
    font-size: clamp(1.8rem, 6vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.auth-splash-sub {
    margin: 0 0 18px;
    color: rgba(255, 255, 255, 0.75);
    text-wrap: balance;
}

.auth-splash-wait {
    margin: 0;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.6);
    animation: eb-fade 1.8s ease-in-out infinite alternate;
}

/* Breakpoint md do Mud: a marca vira faixa compacta no topo do cartão. */
@media (max-width: 959.98px) {
    .auth-card {
        flex-direction: column;
        width: min(100%, 480px);
        min-height: 0;
    }

    .auth-brand {
        flex: none;
        flex-direction: row;
        text-align: left;
        padding: 16px 20px;
    }

    .auth-brand .auth-logo {
        margin: 0;
        width: 52px;
        height: 52px;
        box-shadow: none;
    }

        .auth-brand .auth-logo svg {
            width: 46px;
            height: 46px;
        }

    .auth-brand-name {
        font-size: 1.2rem;
    }

    .auth-brand-tagline {
        font-size: 0.8rem;
        margin: 0;
    }

    .auth-brand-footer {
        display: none;
    }

    .auth-form {
        padding: 28px 24px 32px;
    }
}

@media (max-width: 600px) {
    /* Espaço em cima para o botão de tema não tapar o cartão nem o título. */
    .auth-container {
        padding: 60px 12px 20px;
    }

    .auth-form {
        padding: 24px 18px 28px;
    }
}

.auth-card,
.auth-panel,
.select-title,
.select-subtitle,
.select-status {
    animation: eb-rise 0.55s var(--eb-ease-out) backwards;
}

.select-subtitle {
    animation-delay: 0.06s;
}

.select-status {
    animation-delay: 0.12s;
}

/* Saída antes de navegar (Login -> escritórios/módulos, escritórios -> módulos).
   O Login marca o form com .auth-leaving; o cartão vive no AuthCardLayout, daí o :has.
   0.22s = Task.Delay do Login.razor e do SelectOffice.razor. */
.auth-card:has(.auth-leaving),
.select-page--leaving {
    animation: eb-leave 0.22s var(--eb-ease-in) forwards;
}

/* Wrapper do spinner/skeleton de página (a raiz do MudProgressCircular já usa
   animation para rodar: envolver numa div, nunca pôr a classe no spinner).
   Só aparece se a carga passar de 0.4s: cargas rápidas não mostram o spinner a piscar. */
.auth-wait,
.eb-wait {
    animation: eb-fade-in 0.3s ease 0.4s backwards;
}

/* ── Páginas de selecção (escritórios, módulos, sistemas CRM) sobre o AuthLayout ── */
.select-page {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 0;
}

.select-title {
    color: #fff;
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
    margin: 0 0 6px;
}

.select-subtitle {
    color: rgba(255, 255, 255, 0.72);
    text-align: center;
    margin: 0 0 28px;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
}

/* Poucos cartões (ex.: 2 sistemas CRM) ficam centrados e não esticam. */
.module-grid.module-grid--few {
    grid-template-columns: repeat(auto-fit, minmax(230px, 300px));
    justify-content: center;
}

/* A entrar (escritório escolhido): cartões visíveis mas sem clique. O teclado é
   travado no código, pointer-events não o apanha. */
.module-grid--busy {
    pointer-events: none;
    opacity: 0.55;
    transition: opacity 0.2s ease;
}

.select-status {
    max-width: 760px;
    margin: 0 auto 28px;
}

@media (max-width: 600px) {
    .select-page { padding: 16px 0; }
    .select-title { font-size: 1.8rem; }
    .select-subtitle { font-size: .85rem; margin-bottom: 16px; }
    .module-grid,
    .module-grid.module-grid--few {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

/* ── Cartão de selecção (ModuleCard.razor; Escritorio do CarWash) ────────────
   <button> nativo: cursor, foco e teclado correctos. O hover não move o cartão —
   mover a área clicável fazia-a fugir debaixo do ponteiro na borda. */
.module-card {
    all: unset;
    --eb-accent: var(--mud-palette-primary);
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    min-height: 210px;
    padding: 28px 20px 24px;
    border-radius: var(--eb-radius-card);
    cursor: pointer;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: var(--eb-shadow-rest);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
    -webkit-tap-highlight-color: transparent;
    /* Depois do "all: unset", que a apagaria. Acaba sem transform: o hover continua a não mover. */
    animation: eb-rise .5s var(--eb-ease-out) .08s backwards;
}

    /* Entrada escalonada na grelha. */
    .module-card:nth-child(2) { animation-delay: .13s; }
    .module-card:nth-child(3) { animation-delay: .18s; }
    .module-card:nth-child(4) { animation-delay: .23s; }
    .module-card:nth-child(5) { animation-delay: .28s; }
    .module-card:nth-child(n+6) { animation-delay: .33s; }

    .module-card:hover {
        border-color: color-mix(in srgb, var(--eb-accent) 55%, transparent);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--eb-accent) 18%, transparent), var(--eb-shadow-hover);
    }

    .module-card:focus-visible {
        outline: 3px solid color-mix(in srgb, var(--eb-accent) 70%, white);
        outline-offset: 3px;
    }

    .module-card:active {
        background: color-mix(in srgb, var(--eb-accent) 6%, var(--mud-palette-surface));
    }

.mc-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    margin-bottom: 10px;
    border-radius: 50%;
    color: var(--eb-accent);
    background: color-mix(in srgb, var(--eb-accent) 12%, transparent);
    transition: background-color .2s ease;
    pointer-events: none;
}

.module-card:hover .mc-icon {
    background: color-mix(in srgb, var(--eb-accent) 20%, transparent);
}

.mc-icon .mud-icon-root {
    font-size: 2.6rem;
}

.mc-icon img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    -webkit-user-drag: none;
    user-select: none;
}

.mc-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.3;
}

.mc-desc {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--mud-palette-text-secondary);
}

.mc-go {
    position: absolute;
    top: 14px;
    right: 14px;
    color: var(--eb-accent);
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}

    .mc-go .mud-icon-root {
        font-size: 1.1rem;
    }

.module-card:hover .mc-go,
.module-card:focus-visible .mc-go {
    opacity: 1;
}

@media (max-width: 600px) {
    .module-card {
        min-height: 0;
        padding: 16px 10px 14px;
        gap: 2px;
        border-radius: 14px;
    }

    .mc-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 6px;
    }

        .mc-icon .mud-icon-root {
            font-size: 1.8rem;
        }

        .mc-icon img {
            width: 44px;
            height: 44px;
        }

    .mc-title {
        font-size: 0.95rem;
    }

    .mc-desc {
        font-size: 0.72rem;
        line-height: 1.3;
    }

    .mc-go {
        display: none;
    }
}

/* ── Entrada por rota (MainLayout / RenovacaoLayout: Class="eb-page") ─────────
   Cada página nova monta DOM novo dentro do contentor, que persiste: os filhos
   directos sobem ao montar. Mesma página com outros parâmetros não repete.
   O conteúdo que substitui um skeleton (top-level @if) também sobe ao chegar.
   :where() = especificidade 0: spinners e skeletons do Mud mantêm a animação. */
:where(.eb-page) > *,
.eb-enter {
    animation: eb-rise 0.55s var(--eb-ease-out) backwards;
}

/* Escalonamento: só o atraso, nunca o shorthand (não pisar animações do Mud). */
:where(.eb-page > :nth-child(2)) { animation-delay: 0.04s; }
:where(.eb-page > :nth-child(3)) { animation-delay: 0.08s; }
:where(.eb-page > :nth-child(n+4)) { animation-delay: 0.12s; }

/* Tabs: no MudTabs, PanelClass="eb-tabs". O painel activo é re-inserido a cada troca. */
:where(.eb-tabs) > [role="tabpanel"] {
    animation: eb-fade-in 0.25s ease backwards;
}

/* Recarga com conteúdo já visível: bloqueia o clique já, escurece só se passar de 0.3s.
   transition e não animation: o shorthand pisava o eb-rise dos filhos de .eb-page e,
   ao sair do busy, a entrada voltava a correr. Sem transition no estado normal: volta já. */
.eb-busy {
    pointer-events: none;
    opacity: 0.55;
    transition: opacity 0.2s ease 0.3s;
}

/* ── Superfícies ────────────────────────────────────────────────────────────
   overflow: clip (não hidden): não cria scroll container, o sticky lá dentro funciona. */
.eb-card {
    --eb-accent: var(--mud-palette-primary);
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--eb-radius-card);
    box-shadow: var(--eb-shadow-rest);
    overflow: clip;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.eb-card__head,
.eb-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.eb-card__head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--eb-line-soft);
}

.eb-card__foot {
    padding: 14px 20px;
    border-top: 1px solid var(--eb-line-soft);
    background: color-mix(in srgb, var(--mud-palette-primary) 4%, var(--mud-palette-surface));
}

.eb-filter {
    background: var(--mud-palette-surface);
    border: 1px solid var(--eb-line-soft);
    border-radius: var(--eb-radius-card);
}

/* Banner de estado / cabeçalho de entidade: tint da cor de destaque, legível nos dois temas. */
.eb-hero {
    --eb-accent: var(--mud-palette-primary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 16px 20px;
    border-radius: var(--eb-radius-card);
    color: var(--mud-palette-text-primary);
    border: 1px solid color-mix(in srgb, var(--eb-accent) 25%, var(--mud-palette-lines-default));
    background: linear-gradient(135deg, color-mix(in srgb, var(--eb-accent) 10%, var(--mud-palette-surface)), var(--mud-palette-surface));
}

    .eb-hero > .eb-icon-chip {
        --eb-chip: 48px;
    }

/* ── Stat cards (KPIs) ──────────────────────────────────────────────────── */
.eb-stat {
    --eb-accent: var(--mud-palette-primary);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 100%;
    min-height: 100px;
    padding: 16px 18px;
    border-radius: var(--eb-radius-card);
    border: 1px solid color-mix(in srgb, var(--eb-accent) 20%, var(--mud-palette-lines-default));
    background: linear-gradient(135deg, color-mix(in srgb, var(--eb-accent) 8%, var(--mud-palette-surface)), var(--mud-palette-surface));
    box-shadow: var(--eb-shadow-rest);
    color: var(--mud-palette-text-primary);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

/* display:block: dentro de <button> usar <span> (conteúdo de frase) com estas classes. */
.eb-stat__title,
.eb-stat__value,
.eb-stat__caption {
    display: block;
}

.eb-stat__title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--eb-accent);
    margin-bottom: 4px;
}

.eb-stat__value {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    color: var(--eb-accent);
}

.eb-stat__unit {
    font-size: .6em;
    font-weight: 700;
    opacity: .7;
    margin-left: 3px;
}

.eb-stat__caption {
    font-size: .75rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 2px;
}

.eb-stat .eb-icon-chip { --eb-chip: 46px; }

/* Cartão de filtro activo (KPIs que filtram a lista). */
.eb-stat.is-active {
    border-color: var(--eb-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--eb-accent) 18%, transparent), var(--eb-shadow-rest);
}

.eb-stat--lg { min-height: 130px; padding: 20px; }
.eb-stat--lg .eb-stat__value { font-size: 1.6rem; }
.eb-stat--lg .eb-icon-chip { --eb-chip: 52px; }

/* Compacto: uma linha de KPIs que não rouba altura ao conteúdo (extrato do cliente, CRM). */
.eb-stat--sm { min-height: 0; padding: 10px 14px; gap: 10px; }
.eb-stat--sm .eb-stat__title { font-size: .65rem; margin-bottom: 2px; }
.eb-stat--sm .eb-stat__value { font-size: 1.15rem; }
.eb-stat--sm .eb-stat__caption { font-size: .7rem; margin-top: 0; }
.eb-stat--sm .eb-icon-chip { --eb-chip: 34px; }

/* Compacto: KPIs secundários em páginas de listagem (a lista é o foco). */
.eb-stat.eb-stat--sm { min-height: 0; padding: 10px 14px; }
.eb-stat--sm .eb-stat__title { font-size: .65rem; margin-bottom: 2px; }
.eb-stat--sm .eb-stat__value { font-size: 1.15rem; display: inline; }
.eb-stat--sm .eb-stat__caption { display: inline; margin: 0 0 0 6px; font-size: .7rem; }
.eb-stat.eb-stat--sm .eb-icon-chip { --eb-chip: 34px; }

/* ── Clicáveis: o comportamento do ModuleCard. Nada se move. ──────────────── */
button:is(.eb-card, .eb-stat) {
    font: inherit;
    text-align: left;
    justify-content: flex-start;
    width: 100%;
    margin: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.eb-card--click {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

:is(button.eb-card, button.eb-stat, .eb-card--click):not(:disabled):hover {
    border-color: color-mix(in srgb, var(--eb-accent) 55%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--eb-accent) 18%, transparent), var(--eb-shadow-hover);
}

    :is(button.eb-card, button.eb-stat, .eb-card--click):not(:disabled):hover .eb-icon-chip {
        background: color-mix(in srgb, var(--eb-accent) 20%, transparent);
    }

:is(button.eb-card, button.eb-stat, .eb-card--click):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--eb-accent) 70%, white);
    outline-offset: 3px;
}

:is(button.eb-card, button.eb-stat, .eb-card--click):not(:disabled):active {
    background: color-mix(in srgb, var(--eb-accent) 6%, var(--mud-palette-surface));
}

:is(button.eb-card, button.eb-stat):disabled {
    opacity: .45;
    cursor: default;
}

/* ── Peças pequenas ─────────────────────────────────────────────────────── */
/* Chip redondo na cor de destaque: ícone de stat, de diálogo, de linha, estado vazio, passo. */
.eb-icon-chip {
    --eb-chip: 44px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: var(--eb-chip);
    height: var(--eb-chip);
    border-radius: 50%;
    color: var(--eb-accent, var(--mud-palette-primary));
    background: color-mix(in srgb, var(--eb-accent, var(--mud-palette-primary)) 12%, transparent);
    transition: background-color .2s ease;
}

.eb-icon-chip--xs { --eb-chip: 28px; font-size: .75rem; font-weight: 700; }
.eb-icon-chip--sm { --eb-chip: 36px; }
.eb-icon-chip--lg { --eb-chip: 64px; }

/* Linhas de lista. Não animar (tabelas e @foreach são diffados por posição). */
.eb-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-lines-default) 40%, transparent);
    transition: background-color .15s ease;
}

    .eb-row:last-child { border-bottom: 0; }
    .eb-row > .eb-icon-chip { --eb-chip: 42px; }
    .eb-row > .eb-icon-chip--sm { --eb-chip: 36px; }

.eb-row--click { cursor: pointer; }
.eb-row--click:hover { background: color-mix(in srgb, var(--mud-palette-primary) 4%, transparent); }
.eb-row__body { flex: 1; min-width: 0; }
.eb-row__end { text-align: right; min-width: fit-content; }
.eb-row--muted .eb-row__body { opacity: .65; }
.eb-row--muted .eb-row__end { text-decoration: line-through; }

/* Rótulo / valor. */
.eb-kv {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-size: .875rem;
}

    .eb-kv > :first-child { color: var(--mud-palette-text-secondary); }
    .eb-kv > :last-child { font-weight: 600; text-align: right; }

.eb-badge {
    --eb-accent: var(--mud-palette-text-secondary);
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .62rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--eb-accent);
    background: color-mix(in srgb, var(--eb-accent) 12%, transparent);
}

/* Estado vazio: chip neutro a 12% do texto secundário (vê-se no escuro, ao contrário de rgba(0,0,0,.04)). */
.eb-empty {
    --eb-accent: var(--mud-palette-text-secondary);
    padding: 48px 20px;
    text-align: center;
}

    .eb-empty > .eb-icon-chip { margin: 0 auto 12px; }

.eb-title {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ── Diálogos com cabeçalho próprio ─────────────────────────────────────── */
.eb-dlg__head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.eb-dlg__bar {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--eb-line-soft);
}

.eb-dlg__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 24px;
    border-top: 1px solid var(--eb-line-soft);
}

/* Ecrã inteiro no telemóvel: <MudDialog Class="eb-dlg--fs"> (a classe cai no .mud-dialog). */
@media (max-width: 600px) {
    .mud-dialog-container:has(.eb-dlg--fs) {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
    }

    .mud-dialog.eb-dlg--fs {
        margin: 0;
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

        .mud-dialog.eb-dlg--fs .mud-dialog-content {
            flex: 1 1 auto;
            max-height: none;
            overflow-y: auto;
        }
}

/* Ecrã inteiro em qualquer largura: <MudDialog Class="eb-dlg--full">.
   O bloco com .eb-dlg__grow ocupa o espaço e faz scroll; o resto (cabeçalho,
   totais, botões) fica fixo em cima/em baixo. */
.mud-dialog-container:has(.eb-dlg--full) {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

.mud-dialog.eb-dlg--full {
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

    .mud-dialog.eb-dlg--full .mud-dialog-content {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

        .mud-dialog.eb-dlg--full .mud-dialog-content > * {
            flex-shrink: 0;
        }

        .mud-dialog.eb-dlg--full .mud-dialog-content > .eb-dlg__grow {
            flex: 1 1 auto;
            min-height: 0;
            max-height: none;
            overflow-y: auto;
        }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .eb-stat { min-height: 85px; padding: 12px; }
    .eb-stat__value { font-size: 1.1rem; }
    .eb-stat .eb-icon-chip { --eb-chip: 38px; }
    .eb-row { padding: 12px 14px; gap: 10px; }
    .eb-dlg__bar { padding: 16px; }
    .eb-dlg__actions { padding: 12px 16px; }
}

/* ── Tons: definem a cor de destaque. No fim para vencer os defaults acima. ── */
.eb-tone-primary { --eb-accent: var(--mud-palette-primary); }
.eb-tone-blue { --eb-accent: var(--eb-blue); }
.eb-tone-blue2 { --eb-accent: var(--eb-blue-2); }
.eb-tone-navy { --eb-accent: var(--eb-navy); }
.eb-tone-indigo { --eb-accent: var(--eb-indigo); }
.eb-tone-teal { --eb-accent: var(--eb-teal); }
.eb-tone-cyan { --eb-accent: var(--eb-cyan); }
.eb-tone-green { --eb-accent: var(--eb-green); }
.eb-tone-orange { --eb-accent: var(--eb-orange); }
.eb-tone-red { --eb-accent: var(--eb-red); }
.eb-tone-purple { --eb-accent: var(--eb-purple); }
.eb-tone-grey { --eb-accent: var(--eb-grey); }
.eb-tone-slate { --eb-accent: var(--eb-slate); }

/* ── Movimento reduzido ─────────────────────────────────────────────────────
   Lista explícita: um "*" universal congelava os spinners do Mud.
   .eb-busy fica de fora: é só um fade de opacidade. */
@media (prefers-reduced-motion: reduce) {
    .auth-bg::before,
    .auth-waves use,
    .auth-form-body,
    .auth-step,
    .auth-brand-tagline,
    .auth-logo-ring,
    .auth-splash,
    .auth-splash .auth-logo::after,
    .auth-splash-wait,
    .auth-card,
    .auth-panel,
    .select-title,
    .select-subtitle,
    .select-status,
    .auth-card:has(.auth-leaving),
    .select-page--leaving,
    .auth-wait,
    .eb-wait,
    :where(.eb-page) > *,
    .eb-enter,
    :where(.eb-tabs) > [role="tabpanel"],
    .module-card {
        animation: none;
    }

    .module-grid--busy,
    .module-card,
    .mc-icon,
    .mc-go,
    .eb-card,
    .eb-stat,
    .eb-icon-chip,
    .eb-row {
        transition: none;
    }
}

/* O MudPicker aplica o Style do campo (ex.: width:175px) também ao papel do calendário no popover,
   cortando-o à largura do campo. O calendário fica sempre com a largura natural (310px por mês). */
.mud-picker-inline-paper > .mud-picker-paper {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
}

/* Date pickers em ecrãs baixos (laptops): sem toolbar e com scroll, para caber no viewport.
   Ano/mês continuam acessíveis pelo cabeçalho do calendário. */
@media (max-height: 820px) {
    .mud-popover .mud-picker-datepicker-toolbar {
        display: none;
    }

    .mud-picker-popover-paper,
    .mud-popover:has(.mud-picker) {
        max-height: calc(100vh - 16px);
        overflow-y: auto;
    }
}

/* ── Agenda do CRM (/crm/agenda): grelha mensal de 7 colunas, chips por actividade. ── */
.crm-cal {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--eb-line-soft);
    border-radius: var(--eb-radius-card);
    overflow: hidden;
    background: var(--mud-palette-surface);
}

.crm-cal__dow {
    padding: 6px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    opacity: 0.7;
    border-bottom: 1px solid var(--eb-line-soft);
}

.crm-cal__dia {
    min-height: 104px;
    padding: 4px;
    border-right: 1px solid var(--eb-line-soft);
    border-bottom: 1px solid var(--eb-line-soft);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.crm-cal__dia:nth-child(7n) { border-right: none; }
.crm-cal__dia:hover { background: var(--eb-grey-bg); }
.crm-cal__dia--fora { opacity: 0.45; }

.crm-cal__num {
    font-size: 0.78rem;
    font-weight: 600;
    align-self: flex-end;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
}

.crm-cal__dia--hoje .crm-cal__num {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.crm-cal__item {
    font-size: 0.72rem;
    line-height: 1.25;
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--eb-blue-bg);
    color: var(--eb-blue);
}

.crm-cal__item--atrasada { background: var(--eb-red-bg); color: var(--eb-red); }
.crm-cal__item--concluida { background: var(--eb-green-bg); color: var(--eb-green); text-decoration: line-through; }
.crm-cal__item--cancelada { background: var(--eb-grey-bg); color: var(--eb-grey); text-decoration: line-through; }
.crm-cal__item--repete { border: 1px dashed currentColor; }
.crm-cal__mais { font-size: 0.7rem; opacity: 0.7; padding-left: 6px; }

@media (max-width: 599.98px) {
    .crm-cal__dia { min-height: 64px; }
    .crm-cal__item { font-size: 0; padding: 0; height: 6px; border-radius: 3px; }
    .crm-cal__mais { display: none; }
}

/* ── Pipeline do CRM (/crm/pipeline): colunas do Kanban com scroll horizontal. ── */
.crm-kanban {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    align-items: flex-start;
}

/* Cor da coluna vem da classe eb-tone-* (etapa.Cor); sem tom, usa a primária. */
.crm-kanban__col {
    flex: 0 0 260px;
    border-radius: var(--eb-radius-card);
    border: 1px solid var(--eb-line-soft);
    border-top: 3px solid var(--eb-accent, var(--mud-palette-primary));
    background: var(--mud-palette-surface);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 290px);
}

.crm-kanban__head { padding: 8px 10px 6px; border-bottom: 1px solid var(--eb-line-soft); }
.crm-kanban__tot { font-size: .72rem; color: var(--mud-palette-text-secondary); }
.crm-kanban__zona { flex: 1; min-height: 80px; padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

.crm-kanban__card {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--eb-line-soft);
    background: color-mix(in srgb, var(--eb-accent, var(--mud-palette-primary)) 5%, var(--mud-palette-surface));
    cursor: grab;
    font-size: .82rem;
}

.crm-kanban__card:hover { border-color: color-mix(in srgb, var(--eb-accent, var(--mud-palette-primary)) 50%, transparent); }
.crm-kanban__titulo { font-weight: 700; line-height: 1.25; }
.crm-kanban__conta, .crm-kanban__muted { color: var(--mud-palette-text-secondary); font-size: .75rem; }
.crm-kanban__atraso { color: var(--eb-red); font-size: .75rem; font-weight: 600; }

@media (max-width: 599.98px) {
    .crm-kanban__col { flex-basis: 82vw; max-height: none; }
}

/* ── Timeline 360º do cliente (aba CRM). ── */
.crm-tl {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 6px;
    border-bottom: 1px solid var(--eb-line-soft);
    font-size: .85rem;
}

.crm-tl:hover { background: var(--eb-grey-bg); }
.crm-tl__hora { font-size: .72rem; color: var(--mud-palette-text-secondary); margin-left: 4px; }
.crm-tl__det { font-size: .78rem; color: var(--mud-palette-text-secondary); overflow-wrap: anywhere; }
.crm-tag {
    font-size: .65rem;
    font-weight: 600;
    padding: 0 6px;
    border-radius: 999px;
    color: var(--eb-accent);
    border: 1px solid var(--eb-accent);
}

/* ── Dashboard do CRM: barras horizontais de uma série (CrmBarras). ── */
.crm-barras { display: flex; flex-direction: column; gap: 8px; }

.crm-barras__linha {
    display: grid;
    grid-template-columns: minmax(80px, 32%) 1fr auto;
    align-items: center;
    gap: 10px;
    font-size: .82rem;
}

.crm-barras__rotulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mud-palette-text-primary); }
.crm-barras__pista { height: 10px; border-radius: 4px; background: var(--eb-grey-bg); overflow: hidden; }
.crm-barras__barra { display: block; height: 100%; border-radius: 4px; background: var(--mud-palette-primary); }
.crm-barras__valor { font-variant-numeric: tabular-nums; color: var(--mud-palette-text-secondary); white-space: nowrap; }
.crm-barras__linha:hover .crm-barras__barra { filter: brightness(1.15); }
