/* =============================================================================
   CSS da casa (kit padrão) — complementa o TemaApp do MudBlazor
   Só o que o tema do MudBlazor não cobre: rail navy fixo, splash, canvas,
   borda do topbar e a barra do item de navegação ativo.
   ============================================================================= */

:root {
    --ds-navy: #0C1E2E;
    --ds-navy-2: #071A28;
    --ds-primary: #008BD0;
    --ds-primary-400: #33A2D9;

    /* Tokens do design consumidos abaixo (raio pílula da busca, peso do texto digitado,
       sombra da barra de ações, fonte mono das células técnicas). */
    --ds-radius-pill: 999px;
    --ds-radius-md: 8px;
    --ds-radius-sm: 6px;
    --ds-weight-regular: 400;
    --ds-elevation-med: 0 2px 8px rgba(12, 30, 46, .10);
    --ds-font-mono: ui-monospace, "Cascadia Code", "Consolas", "Liberation Mono", monospace;
}

html, body {
    font-family: "Jost", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.material-symbols-rounded {
    font-family: "Material Symbols Rounded";
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
}

/* ---------- Splash (pré-boot, em index.html) ---------- */
.ds-splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--ds-navy);
    color: #fff;
    z-index: 3000;
}
.ds-splash-text { margin-top: 24px; opacity: .8; }

/* ---------- Loader da marca (design system: Loading · Marca) ----------
   Ícone da marca envolto pelo anel de progresso concêntrico. Usado no splash
   pré-boot e, em runtime, pelo componente BrandLoader.razor. */
.brand-loader { display: inline-grid; place-items: center; }
.brand-loader > * { grid-area: 1 / 1; }
.brand-loader .bl-ring { display: block; width: 100%; height: 100%; animation: ds-spin 1.15s linear infinite; }
.brand-loader .bl-ring circle.track { stroke: var(--mud-palette-lines-default, rgba(0, 0, 0, .12)); opacity: .6; }
.brand-loader .bl-ring circle.ind { stroke: var(--ds-primary); stroke-linecap: round; stroke-dasharray: 150; stroke-dashoffset: 110; }
.brand-loader .bl-mark { width: 46%; height: 46%; object-fit: contain; }
.ld-94 { width: 94px; height: 94px; }
.ld-64 { width: 64px; height: 64px; }
.ld-40 { width: 40px; height: 40px; }
@keyframes ds-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .brand-loader .bl-ring { animation-duration: 2.4s; } }

/* Conteúdo centralizado do overlay (loader + rótulo branco) */
.brand-loader-overlay { display: grid; place-items: center; }
.brand-loader-overlay .bl-label { margin-top: 16px; font-weight: 500; font-size: 13.5px; color: #fff; text-align: center; }

/* No splash (sobre o navy) o anel de fundo é branco translúcido */
.ds-splash .brand-loader .bl-ring circle.track { stroke: rgba(255, 255, 255, .25); opacity: 1; }

/* ---------- Rail navy (MudDrawer Class="ds-drawer") — sempre navy, claro e escuro ---------- */
.mud-drawer.ds-drawer,
.mud-drawer.ds-drawer .mud-drawer-content {
    background-color: var(--ds-navy) !important;
    color: #9DB4C6;
}
/* Empurra o trocador de tenant para o rodapé do rail */
.ds-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}
/* Barra do item de navegação ativo */
.ds-drawer .mud-nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--ds-primary-400);
}
.ds-drawer .mud-nav-link { position: relative; }
.ds-drawer .mud-nav-link { color: #9DB4C6; }
.ds-drawer .mud-nav-link:hover { background-color: rgba(255, 255, 255, .06); color: #EAF3FA; }
.ds-drawer .mud-nav-link.active {
    background-color: rgba(51, 162, 217, .18);
    color: #fff;
}
.ds-drawer .mud-nav-link .mud-nav-link-icon { color: inherit; }
.ds-drawer .mud-nav-group .mud-nav-link { color: #9DB4C6; }

/* Rótulo de seção do menu (Principal / Operação / Sistema) */
.ds-nav-section {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #4F6B81;
    padding: 18px 16px 9px;
}

/* Cabeçalho da marca no topo do rail */
.ds-brand {
    display: flex;
    align-items: center;
    min-height: 64px;
    padding: 0 16px;
}
.ds-brand img { height: 28px; }

.ds-drawer.mud-drawer--closed.mud-drawer-mini .ds-brand {
    justify-content: center;
    padding: 0;
}
.ds-drawer.mud-drawer--closed.mud-drawer-mini .mud-nav-link {
    justify-content: center;
    padding-inline: 0;
}
.ds-drawer.mud-drawer--closed.mud-drawer-mini .ds-nav-section {
    height: 1px;
    padding: 0;
    margin: 16px 20px 12px;
    font-size: 0;
    letter-spacing: 0;
    background-color: rgba(255, 255, 255, .09);
}

/* ---------- Trocador de tenant (rodapé do rail) ---------- */
.ds-tenant { padding: 12px; margin-top: auto; }
.ds-tenant-current {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .09);
    transition: background .12s;
}
.ds-tenant-current:hover { background: rgba(255, 255, 255, .10); }
/* Avatar redondo do tenant: a imagem preenche todo o avatar (object-fit: cover) */
.ds-tenant-avatar { flex-shrink: 0; background: #fff; }
.ds-tenant-avatar .mud-image { width: 100%; height: 100%; }
.ds-tenant-logo { background: #fff; border-radius: 4px; padding: 2px; flex-shrink: 0; }
.ds-tenant-info { flex: 1; min-width: 0; }
.ds-tenant-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #EAF3FA;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ds-tenant-meta { font-size: 11px; color: #7F98AC; }
.ds-tenant-mini { padding: 6px; }
.ds-tenant-mini .ds-tenant-current { justify-content: center; padding: 6px; }

/* ---------- Topbar (MudAppBar Class="ds-topbar") ---------- */
.mud-appbar.ds-topbar {
    border-bottom: 1px solid var(--mud-palette-divider);
}

/* ---------- Canvas (largura máxima de conteúdo) ---------- */
.ds-canvas {
    max-width: 1440px;
    margin-inline: auto;
    width: 100%;
}

/* ---------- Busca global no topbar (design: .tb-search — pílula) ---------- */
.ds-search { max-width: 380px; }
.ds-search.mud-input-control .mud-input-outlined-border { border-radius: var(--ds-radius-pill); }
.ds-search.mud-input-control .mud-input.mud-input-outlined { border-radius: var(--ds-radius-pill); }

/* ---------- Texto digitado em inputs/selects: peso REGULAR ----------
   O mockup usa peso regular (400) no valor dos campos; sem esta regra o texto
   preenchido renderiza mais pesado ("negrito") em todos os formulários. */
.mud-input-slot,
.mud-input-root input,
.mud-input-root textarea,
.mud-select-input .mud-input-slot { font-weight: var(--ds-weight-regular) !important; }

/* ---------- Blocos reutilizáveis do design (StatCard, FormSection, matriz, células) ---------- */
.ds-statcard { border-radius: 12px; }
.ds-statcard-icon { width: 40px; height: 40px; border-radius: var(--ds-radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ds-statcard-value { font-weight: 600; letter-spacing: -.4px; line-height: 1; }
.ds-stat-primary { background: rgba(0, 139, 208, .12); color: var(--mud-palette-primary); }
.ds-stat-success { background: rgba(46, 155, 91, .16); color: var(--mud-palette-success); }
.ds-stat-warning { background: rgba(224, 161, 6, .18); color: var(--mud-palette-warning); }
.ds-stat-error   { background: rgba(214, 69, 69, .14); color: var(--mud-palette-error); }

.ds-formsection { border-radius: 12px; overflow: hidden; }
.ds-formsection-head { display: flex; align-items: center; gap: 13px; padding: 16px 20px; border-bottom: 1px solid var(--mud-palette-divider); }
.ds-formsection-num { width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 139, 208, .12); color: var(--mud-palette-primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.ds-formsection-title { font-weight: 600; font-size: 15px; line-height: 1.2; }
.ds-formsection-sub { font-size: 12.5px; color: var(--mud-palette-text-secondary); margin-top: 2px; }
.ds-formsection-body { padding: 20px; }
.ds-formsection-head-recolhido { border-bottom: none; }
.ds-formsection-alternar { flex-shrink: 0; }

.ds-formgrid-aside { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; align-self: flex-start; }
.ds-actionbar { background: var(--mud-palette-surface); border: 1px solid var(--mud-palette-lines-default); border-radius: 12px; box-shadow: var(--ds-elevation-med); padding: 13px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
@media (max-width: 1279.98px) { .ds-formgrid-aside { position: static; } }

.ds-usercell { display: inline-flex; align-items: center; gap: 11px; }
.ds-usercell-name { font-weight: 500; line-height: 1.25; }
.ds-usercell-mail { font-size: 12px; color: var(--mud-palette-text-secondary); }
.ds-mono { font-family: var(--ds-font-mono); font-size: 12.5px; color: var(--mud-palette-text-secondary); }

/* Matriz de permissões por recurso (cards): um card por recurso, exibindo apenas as ações
   existentes para ele como chips-toggle que quebram linha — sem células "—" e sem estouro
   de largura da tabela recurso × ação. */
.ds-matrix-ic { width: 26px; height: 26px; border-radius: var(--ds-radius-sm); background: rgba(0, 139, 208, .12); color: var(--mud-palette-primary); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ds-permcard { border-radius: 12px; padding: 12px 14px 14px; height: 100%; }
.ds-permcard-head { margin-bottom: 11px; }
.ds-permcard-title { flex: 1; min-width: 0; }
.ds-permcard-name { font-weight: 600; line-height: 1.2; }
.ds-permcard-count { color: var(--mud-palette-text-secondary); }

.ds-prow { padding: 7px 12px; border: 1px solid var(--mud-palette-lines-default); border-radius: var(--ds-radius-md); margin-bottom: 7px; }
.ds-prow-name { flex: 1; font-size: 13.5px; }
.ds-pgroup-head { font-weight: 600; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--mud-palette-text-secondary); padding: 14px 4px 8px; }

/* ---------- Login (split: arte à esquerda, formulário à direita) ---------- */
.ds-login {
    min-height: 100vh;
    align-items: stretch;
}
.ds-login-art {
    flex: 1.1 1 0;
    position: relative;
    background:
        url("../images/produtos/login-qualidade-fiscal.png") center / cover no-repeat,
        radial-gradient(120% 120% at 0% 0%, #0F2A3D 0%, var(--ds-navy) 55%, var(--ds-navy-2) 100%);
    background-color: var(--ds-navy);
    padding: 64px;
    overflow: hidden;
}
.ds-login-art::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(4, 37, 58, .25) 0%, rgba(4, 37, 58, .05) 38%, rgba(4, 37, 58, .78) 100%);
    pointer-events: none;
}
.ds-login-art > * { position: relative; z-index: 1; }
.ds-login-mark { align-self: flex-start; }
.ds-login-eyebrow { color: rgba(255, 255, 255, .72); }
.ds-login-title { color: #fff; font-weight: 600; }
.ds-login-description { color: rgba(255, 255, 255, .78); max-width: 42ch; }
.ds-login-footer { color: rgba(255, 255, 255, .6); margin-top: 24px; }
.ds-login-form {
    flex: 1 1 0;
    position: relative;
    padding: 32px;
    background: var(--mud-palette-background);
}
.ds-login-toggle { position: absolute; top: 16px; right: 16px; }
.ds-login-card { padding: 8px 4px; background: transparent; }

@media (max-width: 960px) {
    .ds-login-art { display: none !important; }
}

.mud-data-grid .mud-table-cell.justify-end > .column-header { justify-content: flex-end; }
.mud-data-grid .mud-table-cell.justify-center > .column-header { justify-content: center; }
.mud-data-grid .mud-table-cell .mud-tooltip-root {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}
.mud-data-grid .mud-table-cell > .mud-icon-root { vertical-align: middle; }

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .5rem;
}
