/* ============================================================
   WiserFlow — Perfis de Acesso
   Fiel a handoff/reference/screen_roles.jsx
   ============================================================ */

.wf-perfis {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--wf-bg);
    min-height: 0;
}

.wf-perfis-header {
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--wf-border);
    background: var(--wf-surface);
}

.wf-perfis-header-crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--wf-text-subtle);
    margin-bottom: 8px;
}

.wf-perfis-header-crumbs-cur {
    color: var(--wf-text-muted);
    font-weight: 500;
}

.wf-perfis-header-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.wf-perfis-title {
    flex: 1;
    min-width: 240px;
}

.wf-perfis-title h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--wf-text);
}

.wf-perfis-title p {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--wf-text-muted);
}

/* --- Master-detail --------------------------------------- */
.wf-perfis-md {
    flex: 1;
    min-height: 0;
    display: flex;
}

.wf-perfis-lista {
    width: 280px;
    background: var(--wf-surface);
    border-right: 1px solid var(--wf-border);
    overflow-y: auto;
    padding: 10px;
    flex-shrink: 0;
}

.wf-perfis-lista-item {
    padding: 10px 12px;
    border-radius: var(--wf-radius-md);
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    margin-bottom: 2px;
    transition: all 100ms;
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: inherit;
}

.wf-perfis-lista-item:hover {
    background: var(--wf-hover);
}

.wf-perfis-lista-item.active {
    background: var(--wf-selected);
    border-color: rgba(77, 163, 255, 0.19);
}

.wf-perfis-lista-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wf-perfis-lista-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.wf-perfis-lista-info {
    flex: 1;
    min-width: 0;
}

.wf-perfis-lista-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--wf-text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.wf-perfis-lista-count {
    font-size: 11px;
    color: var(--wf-text-subtle);
    margin-top: 2px;
}

.wf-perfis-detalhe {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 24px;
}

/* --- Detalhe do perfil ----------------------------------- */
.wf-perfil-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--wf-border);
    margin-bottom: 20px;
}

.wf-perfil-head-ico {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wf-perfil-head-body {
    flex: 1;
    min-width: 0;
}

.wf-perfil-head-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wf-perfil-head-title h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--wf-text);
    letter-spacing: -0.3px;
}

.wf-perfil-head-desc {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--wf-text-muted);
    max-width: 640px;
}

.wf-perfil-head-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* --- Stats pills ----------------------------------------- */
.wf-perfis-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.wf-perfis-stat-pill {
    padding: 10px 14px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
}

.wf-perfis-stat-bar {
    width: 4px;
    height: 28px;
    border-radius: 2px;
    flex-shrink: 0;
}

.wf-perfis-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--wf-text);
    letter-spacing: -0.3px;
    line-height: 1.1;
}

.wf-perfis-stat-label {
    font-size: 10px;
    color: var(--wf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 2px;
}

/* --- Busca ----------------------------------------------- */
.wf-perfis-busca {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-md);
    margin-bottom: 16px;
}

.wf-perfis-busca input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--wf-text);
    font-family: var(--wf-font);
}

/* --- Matriz: ModuleGroup --------------------------------- */
.wf-perm-modules {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wf-perm-module {
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-lg);
    overflow: hidden;
}

.wf-perm-module-head {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: inherit;
    border-bottom: 1px solid transparent;
}

.wf-perm-module-head.aberto {
    background: var(--wf-surface-alt);
    border-bottom-color: var(--wf-border);
}

.wf-perm-module-ico {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wf-perm-module-info {
    flex: 1;
    min-width: 0;
}

.wf-perm-module-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--wf-text);
}

.wf-perm-module-sub {
    font-size: 11px;
    color: var(--wf-text-muted);
    margin-top: 2px;
}

.wf-perm-module-prog {
    text-align: right;
}

.wf-perm-module-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--wf-text);
    font-family: var(--wf-font-mono);
}

.wf-perm-module-pct {
    font-size: 10px;
    color: var(--wf-text-subtle);
    margin-top: 1px;
}

.wf-perm-module-bar {
    width: 80px;
    height: 4px;
    background: var(--wf-bg-sunken);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.wf-perm-module-bar-fill {
    height: 100%;
    transition: width 200ms;
}

.wf-perm-module-body {
    display: flex;
    flex-direction: column;
}

/* --- Entity row ------------------------------------------ */
.wf-perm-entity {
    padding: 16px 18px;
    border-top: 1px solid var(--wf-border);
}

.wf-perm-entity:first-child {
    border-top: none;
}

.wf-perm-entity-inacessivel {
    opacity: 0.72;
}

.wf-perm-entity-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.wf-perm-entity-head-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wf-perm-entity-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--wf-text);
}

.wf-perm-entity-id {
    font-size: 11px;
    color: var(--wf-text-subtle);
    margin-top: 2px;
    font-family: var(--wf-font-mono);
}

.wf-perm-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--wf-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.wf-perm-section-label-aces {
    margin-top: 12px;
}

.wf-perm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* --- PermChip -------------------------------------------- */
.wf-perm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    height: 26px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 999px;
    white-space: nowrap;
    cursor: default;
    transition: all 120ms;
}

.wf-perm-chip-off {
    background: var(--wf-bg-sunken);
    color: var(--wf-text-muted);
    border: 1px solid var(--wf-border);
}

.wf-perm-chip-on {
    background: rgba(77, 163, 255, 0.09);
    color: var(--wf-brand-accent);
    border: 1px solid rgba(77, 163, 255, 0.33);
}

.wf-perm-chip-warning {
    background: var(--wf-warning-bg);
    color: var(--wf-warning);
    border-color: rgba(217, 119, 6, 0.33);
}

.wf-perm-chip-danger {
    background: var(--wf-danger-bg);
    color: var(--wf-danger);
    border-color: rgba(220, 38, 38, 0.33);
}

/* Botão interativo do editor de permissões */
.wf-perm-chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    height: 26px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 999px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 120ms ease-out;
    font-family: inherit;
}

.wf-perm-chip-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.wf-perm-chip-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.wf-perm-chip-btn.wf-perm-chip-off {
    background: var(--wf-bg-sunken);
    color: var(--wf-text-muted);
    border: 1px solid var(--wf-border);
}

.wf-perm-chip-btn.wf-perm-chip-on {
    background: rgba(77, 163, 255, 0.09);
    color: var(--wf-brand-accent);
    border: 1px solid rgba(77, 163, 255, 0.33);
}

.wf-perm-chip-btn.wf-perm-chip-warning {
    background: var(--wf-warning-bg);
    color: var(--wf-warning);
    border-color: rgba(217, 119, 6, 0.33);
}

.wf-perm-chip-btn.wf-perm-chip-danger {
    background: var(--wf-danger-bg);
    color: var(--wf-danger);
    border-color: rgba(220, 38, 38, 0.33);
}

@media (max-width: 768px) {
    .wf-perfis-md {
        flex-direction: column;
    }
    .wf-perfis-lista {
        width: 100%;
        max-height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--wf-border);
    }
}
